本帖最后由 舞柯庶 于 2013-6-10 18:06 编辑
抛砖引玉:
Dictionary<int, Dictionary<int, string>> modifiedDict = xGrid.GetModifiedDict();
//获取修改后的数据集合xGrid.GetModifiedData().ToString()
string xSqls = "";
string xIdS="";
for (int i = 0, count = xGrid.Rows.Count; i < count; i++)
{
if (modifiedDict.ContainsKey(i))//当前行是否修改
{
if (xSqls == "")
{
xSqls = "Update xtable Set CL_UpdateName='"+Session["user_name"].ToString()+"',CL_UpdateDate=GetDate()";
xIdS=xGrid.DataKeys[0].ToString();
}
else
{
xSqls = xSqls + "$Update xtable Set CL_UpdateName='" + Session["user_name"].ToString() + "',CL_UpdateDate=GetDate()";
xIdS=xIdS+","+xGrid.DataKeys[0].ToString();
}
Dictionary<int, string> rowDict = modifiedDict;
//数量
if (rowDict.ContainsKey(4))//是否修改
{
xSqls = xSqls + ",CL_Num=" + Convert.ToDouble(rowDict[4]);
}
// 单重
if (rowDict.ContainsKey(9))
{
xSqls = xSqls + ",CL_Weight=" + rowDict[9].ToString();
}
// 备注
if (rowDict.ContainsKey(10))
{
xSqls = xSqls + ",CL_Meno=" + rowDict[10].ToString();
}
xSqls = xSqls + " Where Id=" + xGrid.DataKeys[0].ToString();
}
}//for
DB db = new DB();
string[] sql_arr = xSqls.Split('$');
db.Exec_Trans(sql_arr); |