html:
cc1 <input id="cc1" style="width:200px" />
cc2 <input id="cc2" style="width:200px" />
cc3 <input id="cc3" style="width:200px" />
js:
$('#cc1').combobox({
onSelect: function (rec) {
//var url = '/hdk/get_fwzh_year_numb';
var getText = $('#cc1').combobox('getText');
var getValue = $('#cc1').combobox("getValue");
//alert(getText);
$.ajax({
url: '/hdk/get_fwzh_year_numb',
type: "post",
data: {
fwzh_top: getText,//数据连接字符
//tName: 'fwzh',//数据库表名
},
dataType: "json",
success: function (json) {
//alert(JSON.stringify(json));
//var result = json[0].fwzh_year;//解析json对象
//var result = JSON.stringify(json);
//alert(result);
$('#cc2').val(json[0].fwzh_year);
$('#cc3').val(json[0].MAX_FWZH_NUM);
}
});
//$('#cc1').val(name);
//$('#cc2').combobox('reload', url);
//alert(getValue);
//$('#cc2').val(getValue);
//$('#cc3').val(getText);
}
后台:
//获取发文的year和numb数据
public void get_fwzh_year_numb(string fwzh_top)
{
fwzh_top = Query<string>("fwzh_top");
string json = string.Empty;
string time_now = DateTime.Now.ToString("yyyyMMdd"); // 08:05:57
//string fwzh_year = DateTime.Now.Year.ToString();//获取年份 // 2008
string fwzh_year = "2021";//获取年份 // 2008
//MDataTable dt;
//string sql = "select * from CCH_DBML where";
string sql = "select max(fwzh_num) as max_fwzh_num from zfwd where fwzh_top='" + fwzh_top + "' and fwzh_year='" + fwzh_year +"'";
//ZH = Query<int>("ZH");
//conn = Query<string>("conn");
DataTable dt = null;
using (MAction action = new MAction(sql, "hdk")) //表名+连接字符串名,表名也可是sql语句
{
dt = action.Select().ToDataTable();
}
string max_fwzh_num = dt.Rows[0]["max_fwzh_num"].ToString();
int fwzh_num = 0;
if (max_fwzh_num == "")
{
fwzh_num = 1;
}else
{
fwzh_num = int.Parse(max_fwzh_num) + 1;
}
//添加新的列
dt.Columns.Add("fwzh_year", typeof(string));
dt.Rows[0]["fwzh_year"] = fwzh_year;
dt.Rows[0]["max_fwzh_num"] = fwzh_num;
string JsonString = JsonConvert.SerializeObject(dt);//将datatable转成json格式
Response.Write(JsonString);
//Write(JsonString);
}
标签:num,string,easyui,combobox,json,fwzh,year,dt From: https://www.cnblogs.com/xue-rui/p/17065234.html