[其他]代码库
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Import/approval/GetData',
params: {
handle: opstatus,
condition: condition
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
Ext.Msg.show({
title: '提示',
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
}
var data = result.data;
this.formEdit.getForm().reset();
// if (data.ex_ == "") { data.OilLrDate = currdate.format('yyyy-MM-dd') };
this.formEdit.getForm().setValues(data);
var sql = 'app_id=' + data.id;
if (this.opStatus != 'add') {
this.storeUsing.load({
params: { start: 0, limit: 500, sort: '', condition: sql },
//params: { condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
===============================================
public ContentResult GetData(string handle, string condition)
{
approvalmb head = null;
if (handle == "edit")
{
var list = approvalDAL.GetDataList(condition);
if (list.Count > 0)
head = list[0];
}
if (head == null)
{
head = new approvalmb();
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult GetDataList(int start, int limit, string sort, string condition)
{
var dataList = approvalDAL.GetDataList(condition);
var list = dataList.Skip(start).Take(limit);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
//
// GET:/Import/approval/GetData/
static public List<approvalmb> GetDataList(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append(" SELECT a.*,cp.name companyname, ");
strSql.Append(" c.country,u.used,u.selected, u.remain,u.canbeused, ");
strSql.Append(" ci.code,ci.name,ciq.ciqcode,ciq.ciqname, ");
strSql.Append(" (select EnumValueName from tSysEnumValue ");
strSql.Append(" where LangId=0 and EnumTypeID=10 and EnumValueID=a.SLJG) as portRef, ");
strSql.Append(" (select EnumValueName from tSysEnumValue ");
strSql.Append(" where LangId=0 and EnumTypeID=0 and EnumValueID=a.isdeleted) as isdeletedRef ");
strSql.Append(" FROM [Import_approval] a ");
strSql.Append(" left join import_cargoinfo ci on ci.id=a.cargoinfo_id ");
strSql.Append(" left join code_country c on a.[Countryid]=c.[Countryid] ");
strSql.Append(" left join vMsAppUsed U on U.[app_id]=a.[id] ");
strSql.Append(" left join import_cargociq ciq on ciq.id=a.cargociq_id ");
strSql.Append(" left join company cp on cp.gid=a.company ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
return SetData(strSql);
}
private static List<approvalmb> SetData(StringBuilder strSql)
{
var headList = new List<approvalmb>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
approvalmb data = new approvalmb();
#region Set DB data to Object
data.id = Convert.ToString(reader["id"]);
data.gid = Convert.ToString(reader["gid"]);
data.APPNO = Convert.ToString(reader["APPNO"]);
data.SQDH = Convert.ToString(reader["SQDH"]);
data.SLJG = Convert.ToString(reader["SLJG"]);
data.portRef = Convert.ToString(reader["portRef"]);
data.Countryid = Convert.ToString(reader["Countryid"]);
data.Country = Convert.ToString(reader["Country"]);
data.Weight = Convert.ToString(reader["Weight"]);
data.used = Convert.ToString(reader["used"]);
data.selected = Convert.ToString(reader["selected"]);
data.remain = Convert.ToString(reader["remain"]);
data.canbeused = Convert.ToString(reader["canbeused"]);
data.ValidDate = Convert.ToString(reader["ValidDate"]);
data.cargoinfo_id = Convert.ToString(reader["cargoinfo_id"]);
data.cargociq_id = Convert.ToString(reader["cargociq_id"]);
data.AppName = Convert.ToString(reader["AppName"]);
data.code = Convert.ToString(reader["code"]);
data.name = Convert.ToString(reader["name"]);
data.ciqcode = Convert.ToString(reader["ciqcode"]);
data.ciqname = Convert.ToString(reader["ciqname"]);
data.isdeletedRef = Convert.ToString(reader["isdeletedRef"]);
data.isdeleted = Convert.ToString(reader["isdeleted"]);
data.company = Convert.ToString(reader["company"]);
data.companyname = Convert.ToString(reader["companyname"]);
data.depot = Convert.ToString(reader["depot"]);
data.usedweight = Convert.ToString(reader["usedweight"]);
data.JustWriteoffs = Convert.ToString(reader["JustWriteoffs"]);
data.REMARK = Convert.ToString(reader["REMARK"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}