/// <summary> /// 覆盖方案事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn_Save_Click(object sender, EventArgs e) { try { //获取面板中最后一个用户控件 int ContrNum = Pal_FlCtner.Controls.Count; UsrContr_Filter Filter = (UsrContr_Filter)Pal_FlCtner.Controls[ContrNum - 1]; if (((SearchLookUpEdit)Filter.Controls["SLkUp_ColNams"]).EditValue != null) { if (BracketsMatch(GetFltSltDtl())) { DialogResult Result = XtraMessageBox.Show("您是否需要覆盖本过滤方案!", "提醒", MessageBoxButtons.OKCancel); if (Result == DialogResult.OK) { //EditFltSlt(); if (SltEditNode != null) { List <DTSerializer <string, object> > List_DTObj = GetFltSltDtl(); foreach (DTSerializer <string, object> DTObj2 in List_DTObj) { DTObj2.Add("FSltID", SltEditNode.GetValue("FSltID").ToString()); DTObj2.Add("FSltType", "0"); } //开始事务 ComClient.BeginTransaction(); ComClient.SaveFltSlt1(OperType.Delete, Serializer.SerializeDTToXml <List <DTSerializer <string, object> > >(List_DTObj), "t_ADMM_FltSltforDtl", " FSltID='" + SltEditNode.GetValue("FSltID").ToString() + "'"); ComClient.SaveFltSlt1(OperType.AddSave, Serializer.SerializeDTToXml <List <DTSerializer <string, object> > >(List_DTObj), "t_ADMM_FltSltforDtl", ""); //提交事务 ComClient.CommitTransaction(); //将树节点切换成不可编辑模式 TrList_FltSlt.OptionsBehavior.Editable = false; } } } else { return; } } else { Common.ShowMsg("字段名称不能为空!"); } } catch (Exception Ex) { Common.ShowMsg(Ex.Message); } }
/// <summary> /// 删除方案事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn_Drop_Click(object sender, EventArgs e) { try { //获取当前选择的方案名称 string FSltID = TrList_FltSlt.FocusedNode.GetValue("FSltID").ToString(); ComClient.BeginTransaction(); ComClient.SaveFltSlt1(OperType.Delete, "", "t_ADMM_FltSltList", " FSltID='" + FSltID + "'"); ComClient.SaveFltSlt1(OperType.Delete, "", "t_ADMM_FltSltforDtl", " FSltID='" + FSltID + "'"); ComClient.CommitTransaction(); TrList_FltSlt.DataSource = Serializer.DeserializeXMLToDT(ComClient.GetFltSlt(CurUsrID, FrmNam)); TrList_FltSlt.ExpandAll(); } catch (Exception Ex) { Common.ShowMsg(Ex.Message); } }
/// <summary> /// 保存过滤方案 /// </summary> /// <param name="operType">操作类型</param> /// <param name="TabName">表名称</param> /// <param name="ParentID">父方案ID</param> /// <param name="SltType">过滤方案类型</param> /// <param name="KeyWords">查询关键字</param> private void AddFltSlt(OperType operType, string ParentID, string SltType, string KeyWords, List <DTSerializer <string, object> > List_DTObj) { try { //获取当前最大的方案ID string MaxSltID = ComClient.GetMaxSltID(FrmNam, SltType, ParentID); DTSerializer <string, object> DTObj1 = new DTSerializer <string, object>(); List <DTSerializer <string, object> > List_DTObj1 = new List <DTSerializer <string, object> >(); DTObj1.Add("FSltID", MaxSltID); DTObj1.Add("FSltName", Txt_SltName.Text.Trim()); DTObj1.Add("FParentID", ParentID); DTObj1.Add("FUsrID", CurUsrID); DTObj1.Add("FFrmName", FrmNam); DTObj1.Add("FSltType", SltType); List_DTObj1.Add(DTObj1); //开始SQL事务 ComClient.BeginTransaction(); ComClient.SaveFltSlt1(operType, Serializer.SerializeDTToXml <List <DTSerializer <string, object> > >(List_DTObj1), "t_ADMM_FltSltList", KeyWords); //向查询方案明细中追加方案ID和方案类型 foreach (DTSerializer <string, object> DTObj2 in List_DTObj) { DTObj2.Add("FSltID", MaxSltID); DTObj2.Add("FSltType", SltType); } //增加/修改/删除过滤方案明细 ComClient.SaveFltSlt1(operType, Serializer.SerializeDTToXml <List <DTSerializer <string, object> > >(List_DTObj), "t_ADMM_FltSltforDtl", KeyWords); //提交事务 ComClient.CommitTransaction(); } catch (Exception Ex) { Common.ShowMsg(Ex.Message); } }
/// <summary> /// 保存用户组资料数据 /// </summary> /// <returns>1:保存成功;0:保存失败</returns> public override int SaveData() { string TabNam = "t_ADMM_GrpMst"; string PriKey = "fGrpCode"; //string FrmNam = "DiousEPortal.FrmUserGroup"; FocColNam = "分组代号"; if (BtnName == BtnNam.Add || BtnName == BtnNam.Copy) { FocColVal = Txt_Grpcode.Text; } else { //初始化FocColVal,方便后续新增数据定位行用 FocColVal = (string)((IDictionary <string, object>)((ExpandoObject)View_Common2.GetFocusedRow()))[FocColNam]; } //初始化主键控件名称 string ContrNam = KeyContrNam[0]; try { string SQL = ""; List <DTSerializer <string, object> > List_DTObj = new List <DTSerializer <string, object> >(); List <DTSerializer <string, object> > List_DTObj1 = new List <DTSerializer <string, object> >(); List <ExpandoObject> List_EObj; //开始SQL事务 ComClient.BeginTransaction(); //只有不重复才往下执行 if (BtnName == BtnNam.Add && ComClient.RepeatCheck(TabNam, PriKey, Txt_Grpcode.Text) == 0) { //1.查询哪些表需要更新(输出表名、面板名、窗体实例名) List <ExpandoObject> List_UpTab = LoadData(ComClient.GetTabByFrmNam(FrmNam)); foreach (dynamic UpTab in List_UpTab) { //2.根据表名和窗体实例名查询出更新表需要的关键信息 List_EObj = LoadData(ComClient.GetTabStrc(UpTab.FTblNm, FrmNam, OperType.AddSave, "", UpTab.FPanelNam, "", "")); //获取执行SQL foreach (ExpandoObject EObj in List_EObj) { var IDObj = (IDictionary <string, object>)EObj; SQL = (string)IDObj["SQL"]; } List <List <ExpandoObject> > List_PanelObjs = new List <List <ExpandoObject> >(); //根据面板名称读取该面板内所有相关字段信息 List <ExpandoObject> List_Panel4EObj = Serializer.DeserializeXMLToEObject(ComClient.GetColsByPanelNam("Panel4", FrmNam, UpTab.FTblNm)); List_PanelObjs.Add(List_Panel4EObj); List <ExpandoObject> List_Panel3EObj = Serializer.DeserializeXMLToEObject(ComClient.GetColsByPanelNam("Panel3", FrmNam, UpTab.FTblNm)); List_PanelObjs.Add(List_Panel3EObj); List <ExpandoObject> List_Panel7EObj = Serializer.DeserializeXMLToEObject(ComClient.GetColsByPanelNam("Panel7", FrmNam, UpTab.FTblNm)); List_PanelObjs.Add(List_Panel7EObj); List <ExpandoObject> List_Panel8EObj = Serializer.DeserializeXMLToEObject(ComClient.GetColsByPanelNam("Panel8", FrmNam, UpTab.FTblNm)); List_PanelObjs.Add(List_Panel8EObj); List <ExpandoObject> List_Panel9EObj = Serializer.DeserializeXMLToEObject(ComClient.GetColsByPanelNam("Panel9", FrmNam, UpTab.FTblNm)); List_PanelObjs.Add(List_Panel9EObj); List <ExpandoObject> List_Panel10EObj = Serializer.DeserializeXMLToEObject(ComClient.GetColsByPanelNam("Panel10", FrmNam, UpTab.FTblNm)); List_PanelObjs.Add(List_Panel10EObj); List <ExpandoObject> List_Panel11EObj = Serializer.DeserializeXMLToEObject(ComClient.GetColsByPanelNam("Panel11", FrmNam, UpTab.FTblNm)); List_PanelObjs.Add(List_Panel11EObj); List <ExpandoObject> List_Panel12EObj = Serializer.DeserializeXMLToEObject(ComClient.GetColsByPanelNam("Panel12", FrmNam, UpTab.FTblNm)); List_PanelObjs.Add(List_Panel12EObj); //用于存储该表在所有面板内的字段值 DTSerializer <string, object> DTObj = new DTSerializer <string, object>(); foreach (List <ExpandoObject> List_PanelObj in List_PanelObjs) { if (List_PanelObj.Count != 0) { var Query = from Obj in List_PanelObj where EObjToIDObj(Obj)["FPanelNam"].ToString() == "Panel3" select Obj; //Panel3面板中是网格控件,则按照以下逻辑单独处理 if (Query.Count <ExpandoObject>() > 0) { //遍历View_Common1数据源获取每个字段的值 foreach (ExpandoObject EObj3 in (BindingList <ExpandoObject>)View_Common1.DataSource) { IDictionary <string, object> IDObj = (IDictionary <string, object>)EObj3; DTSerializer <string, object> DTObj1 = new DTSerializer <string, object>(); foreach (string Key in IDObj.Keys) { //利用LinQ将中文字段名转换成英文字段名 var Query1 = from Obj in List_PanelObj where EObjToIDObj(Obj)["FRemark"].ToString() == Key select EObjToIDObj(Obj)["FColNm"].ToString(); string Key1 = ""; foreach (var key in Query1) { Key1 = key.ToString(); } if (Key1 != "") { if (Key1 == PriKey) { DTObj1.Add(Key1, Panel4.Controls[ContrNam].Text); } else { DTObj1.Add(Key1, IDObj[Key].ToString()); } } } //3.循环完Panel3面板的每一行字段后,生成更新对象列表 List_DTObj1.Add(DTObj1); } //4.服务端根据接收到的对象列表更新数据库 //ComClient.SaveData(Serializer.SerializeDTToXml<List<DTSerializer<string, object>>>(List_DTObj1), SQL, OperType.AddSave); ComClient.SaveData1(Serializer.SerializeDTToXml <List <DTSerializer <string, object> > >(List_DTObj1), SQL); } //非Panel3面板,则按照以下逻辑单独处理 else { //根据面板内的字段信息自动生成更新对象列表 foreach (dynamic EObj in List_PanelObj) { //如果该字段绑定了指定控件,则按照控件指定值更新 if (EObj.FContrNam != "") { if (EObj.FColNm == "fCFlag") { DTObj.Add(EObj.FColNm, Panel4.Controls[EObj.FContrNam].Text == "已审核" ? 1 : 0); } else if (EObj.FColNm == "fIfUse") { DTObj.Add(EObj.FColNm, Panel4.Controls[EObj.FContrNam].Text == "已启用" ? 1 : 0); } else { if (EObj.FPanelNam == "Panel4") { DTObj.Add(EObj.FColNm, Panel4.Controls[EObj.FContrNam].Text); } else if (EObj.FPanelNam == "Panel7") { DTObj.Add(EObj.FColNm, Panel7.Controls[EObj.FContrNam].Text); } else if (EObj.FPanelNam == "Panel8") { DTObj.Add(EObj.FColNm, Panel8.Controls[EObj.FContrNam].Text); } else if (EObj.FPanelNam == "Panel9") { DTObj.Add(EObj.FColNm, Panel9.Controls[EObj.FContrNam].Text); } else if (EObj.FPanelNam == "Panel10") { DTObj.Add(EObj.FColNm, Panel10.Controls[EObj.FContrNam].Text); } else if (EObj.FPanelNam == "Panel11") { DTObj.Add(EObj.FColNm, Panel11.Controls[EObj.FContrNam].Text); } else if (EObj.FPanelNam == "Panel12") { DTObj.Add(EObj.FColNm, Panel12.Controls[EObj.FContrNam].Text); } } } //如果该字段没有绑定任何控件,则按照默认值更新 else { //如果该字段的默认数据类型是DateTime,则默认值是当天 if (EObj.FColNm == "fCDate") { DTObj.Add(EObj.FColNm, DateTime.Now.ToString()); } else if (EObj.FColNm == "fCreatorID") { DTObj.Add(EObj.FColNm, CurUsrID); } else if (EObj.FColNm == "fCreator") { DTObj.Add(EObj.FColNm, CurUsrName); } else { DTObj.Add(EObj.FColNm, EObj.FDefValue); } } } //3.循环完所有面板的字段后,生成更新对象列表 List_DTObj.Add(DTObj); //4.服务端根据接收到的对象列表更新数据库 //ComClient.SaveData(Serializer.SerializeDTToXml<List<DTSerializer<string, object>>>(List_DTObj), SQL, OperType.AddSave); ComClient.SaveData1(Serializer.SerializeDTToXml <List <DTSerializer <string, object> > >(List_DTObj), SQL); } } } } //提交事务 ComClient.CommitTransaction(); BtnName = BtnNam.Null; //重新刷新网格数据 Grip_Common2.DataSource = LoadData(UsrGroupClient.GetUsrGrpsToChCol("#Tmp_" + CurUsrID + "_" + DateTime.Now.Second.ToString(), "0", "")); return(1); } else if (BtnName == BtnNam.Copy && ComClient.RepeatCheck(TabNam, PriKey, Txt_Grpcode.Text) == 0) { //1.查询哪些表需要更新(输出表名、面板名、窗体实例名) List <ExpandoObject> List_UpTab = LoadData(ComClient.GetTabByFrmNam(FrmNam)); foreach (dynamic UpTab in List_UpTab) { //2.根据表名和窗体实例名查询出更新表需要的关键信息 List_EObj = LoadData(ComClient.GetTabStrc(UpTab.FTblNm, FrmNam, OperType.AddSave, "", UpTab.FPanelNam, "", "")); //获取执行SQL foreach (ExpandoObject EObj in List_EObj) { var IDObj = (IDictionary <string, object>)EObj; SQL = (string)IDObj["SQL"]; } List <List <ExpandoObject> > List_PanelObjs = new List <List <ExpandoObject> >(); //根据面板名称读取该面板内所有相关字段信息 List <ExpandoObject> List_Panel4EObj = Serializer.DeserializeXMLToEObject(ComClient.GetColsByPanelNam("Panel4", FrmNam, UpTab.FTblNm)); List_PanelObjs.Add(List_Panel4EObj); List <ExpandoObject> List_Panel3EObj = Serializer.DeserializeXMLToEObject(ComClient.GetColsByPanelNam("Panel3", FrmNam, UpTab.FTblNm)); List_PanelObjs.Add(List_Panel3EObj); List <ExpandoObject> List_Panel7EObj = Serializer.DeserializeXMLToEObject(ComClient.GetColsByPanelNam("Panel7", FrmNam, UpTab.FTblNm)); List_PanelObjs.Add(List_Panel7EObj); List <ExpandoObject> List_Panel8EObj = Serializer.DeserializeXMLToEObject(ComClient.GetColsByPanelNam("Panel8", FrmNam, UpTab.FTblNm)); List_PanelObjs.Add(List_Panel8EObj); List <ExpandoObject> List_Panel9EObj = Serializer.DeserializeXMLToEObject(ComClient.GetColsByPanelNam("Panel9", FrmNam, UpTab.FTblNm)); List_PanelObjs.Add(List_Panel9EObj); List <ExpandoObject> List_Panel10EObj = Serializer.DeserializeXMLToEObject(ComClient.GetColsByPanelNam("Panel10", FrmNam, UpTab.FTblNm)); List_PanelObjs.Add(List_Panel10EObj); List <ExpandoObject> List_Panel11EObj = Serializer.DeserializeXMLToEObject(ComClient.GetColsByPanelNam("Panel11", FrmNam, UpTab.FTblNm)); List_PanelObjs.Add(List_Panel11EObj); List <ExpandoObject> List_Panel12EObj = Serializer.DeserializeXMLToEObject(ComClient.GetColsByPanelNam("Panel12", FrmNam, UpTab.FTblNm)); List_PanelObjs.Add(List_Panel12EObj); //用于存储该表在所有面板内的字段值 DTSerializer <string, object> DTObj = new DTSerializer <string, object>(); foreach (List <ExpandoObject> List_PanelObj in List_PanelObjs) { if (List_PanelObj.Count != 0) { var Query = from Obj in List_PanelObj where EObjToIDObj(Obj)["FPanelNam"].ToString() == "Panel3" select Obj; //Panel3面板中是网格控件,则按照以下逻辑单独处理 if (Query.Count <ExpandoObject>() > 0) { //遍历View_Common1数据源获取每个字段的值 foreach (ExpandoObject EObj3 in (BindingList <ExpandoObject>)View_Common1.DataSource) { IDictionary <string, object> IDObj = (IDictionary <string, object>)EObj3; DTSerializer <string, object> DTObj1 = new DTSerializer <string, object>(); foreach (string Key in IDObj.Keys) { //利用LinQ将中文字段名转换成英文字段名 var Query1 = from Obj in List_PanelObj where EObjToIDObj(Obj)["FRemark"].ToString() == Key select EObjToIDObj(Obj)["FColNm"].ToString(); string Key1 = ""; foreach (var key in Query1) { Key1 = key.ToString(); } if (Key1 != "") { if (Key1 == PriKey) { DTObj1.Add(Key1, Panel4.Controls[ContrNam].Text); } else { DTObj1.Add(Key1, IDObj[Key].ToString()); } } } //3.循环完Panel3面板的每一行字段后,生成更新对象列表 List_DTObj1.Add(DTObj1); } //4.服务端根据接收到的对象列表更新数据库 //ComClient.SaveData(Serializer.SerializeDTToXml<List<DTSerializer<string, object>>>(List_DTObj1), SQL, OperType.AddSave); ComClient.SaveData1(Serializer.SerializeDTToXml <List <DTSerializer <string, object> > >(List_DTObj1), SQL); } //非Panel3面板,则按照以下逻辑单独处理 else { //根据面板内的字段信息自动生成更新对象列表 foreach (dynamic EObj in List_PanelObj) { //如果该字段绑定了指定控件,则按照控件指定值更新 if (EObj.FContrNam != "") { if (EObj.FColNm == "fCFlag") { DTObj.Add(EObj.FColNm, Panel4.Controls[EObj.FContrNam].Text == "已审核" ? 1 : 0); } else if (EObj.FColNm == "fIfUse") { DTObj.Add(EObj.FColNm, Panel4.Controls[EObj.FContrNam].Text == "已启用" ? 1 : 0); } else { if (EObj.FPanelNam == "Panel4") { DTObj.Add(EObj.FColNm, Panel4.Controls[EObj.FContrNam].Text); } else if (EObj.FPanelNam == "Panel7") { DTObj.Add(EObj.FColNm, Panel7.Controls[EObj.FContrNam].Text); } else if (EObj.FPanelNam == "Panel8") { DTObj.Add(EObj.FColNm, Panel8.Controls[EObj.FContrNam].Text); } else if (EObj.FPanelNam == "Panel9") { DTObj.Add(EObj.FColNm, Panel9.Controls[EObj.FContrNam].Text); } else if (EObj.FPanelNam == "Panel10") { DTObj.Add(EObj.FColNm, Panel10.Controls[EObj.FContrNam].Text); } else if (EObj.FPanelNam == "Panel11") { DTObj.Add(EObj.FColNm, Panel11.Controls[EObj.FContrNam].Text); } else if (EObj.FPanelNam == "Panel12") { DTObj.Add(EObj.FColNm, Panel12.Controls[EObj.FContrNam].Text); } } } //如果该字段没有绑定任何控件,则按照默认值更新 else { //如果该字段的默认数据类型是DateTime,则默认值是当天 if (EObj.FColNm == "fCDate") { DTObj.Add(EObj.FColNm, DateTime.Now.ToString()); } //if (EObj.FColNm == "fAppDate") //{ // DTObj.Add(EObj.FColNm, DateTime.Now.ToString()); //} else if (EObj.FColNm == "fCreatorID") { DTObj.Add(EObj.FColNm, CurUsrID); } else if (EObj.FColNm == "fCreator") { DTObj.Add(EObj.FColNm, CurUsrName); } else { DTObj.Add(EObj.FColNm, EObj.FDefValue); } } } //3.循环完所有面板的字段后,生成更新对象列表 List_DTObj.Add(DTObj); //4.服务端根据接收到的对象列表更新数据库 //ComClient.SaveData(Serializer.SerializeDTToXml<List<DTSerializer<string, object>>>(List_DTObj), SQL, OperType.AddSave); ComClient.SaveData1(Serializer.SerializeDTToXml <List <DTSerializer <string, object> > >(List_DTObj), SQL); //提交事务 ComClient.CommitTransaction(); } } } BtnName = BtnNam.Null; //重新刷新网格数据 Grip_Common2.DataSource = LoadData(UsrGroupClient.GetUsrGrpsToChCol("#Tmp_" + CurUsrID + "_" + DateTime.Now.Second.ToString(), "0", "")); } return(1); } else if (BtnName == BtnNam.Delete) { //1.查询哪些表需要更新(输出表名、面板名、窗体实例名) List <ExpandoObject> List_UpTab = LoadData(ComClient.GetTabByFrmNam(FrmNam)); //获取当前选择行的数据 IDictionary <string, object> IDObj = (IDictionary <string, object>)View_Common2.GetFocusedRow(); foreach (dynamic UpTab in List_UpTab) { List_EObj = LoadData(ComClient.GetTabStrc(UpTab.FTblNm, FrmNam, OperType.Delete, PriKey + " ='" + IDObj[ComClient.GetChColByEnCol(TabNam, PriKey)].ToString() + "'", UpTab.FPanelNam, "", "")); //获取执行SQL foreach (ExpandoObject EObj in List_EObj) { var IDObj1 = (IDictionary <string, object>)EObj; SQL = (string)IDObj1["SQL"]; } //ComClient.SaveData(Serializer.SerializeDTToXml<List<DTSerializer<string, object>>>(List_DTObj), SQL, OperType.Delete); ComClient.SaveData1("", SQL); } //提交事务 ComClient.CommitTransaction(); BtnName = BtnNam.Null; //重新刷新网格数据 Grip_Common2.DataSource = LoadData(UsrGroupClient.GetUsrGrpsToChCol("#Tmp_" + CurUsrID + "_" + DateTime.Now.Second.ToString(), "0", "")); return(1); } else if (BtnName == BtnNam.Edit) { //1.查询哪些表需要更新(输出表名、面板名、窗体实例名) List <ExpandoObject> List_UpTab = LoadData(ComClient.GetTabByFrmNam(FrmNam)); //获取当前选择行的数据 IDictionary <string, object> IDObj1 = (IDictionary <string, object>)View_Common2.GetFocusedRow(); foreach (dynamic UpTab in List_UpTab) { //判断更新表归属于哪个面板 if (UpTab.FPanelNam != "Panel3") { //2.根据表名和窗体实例名查询出更新表需要的关键信息 List_EObj = LoadData(ComClient.GetTabStrc(UpTab.FTblNm, FrmNam, OperType.EditSave, PriKey + " ='" + IDObj1[ComClient.GetChColByEnCol(TabNam, PriKey)].ToString() + "'", UpTab.FPanelNam, "", "")); //获取执行SQL foreach (ExpandoObject EObj in List_EObj) { var IDObj = (IDictionary <string, object>)EObj; SQL = (string)IDObj["SQL"]; } } else { //2.根据表名和窗体实例名查询出更新表需要的关键信息 List_EObj = LoadData(ComClient.GetTabStrc(UpTab.FTblNm, FrmNam, OperType.Delete, PriKey + " ='" + IDObj1[ComClient.GetChColByEnCol(TabNam, PriKey)].ToString() + "'", UpTab.FPanelNam, "", "")); //获取执行SQL foreach (ExpandoObject EObj in List_EObj) { var IDObj = (IDictionary <string, object>)EObj; SQL = (string)IDObj["SQL"]; } //先执行删除数据操作 //ComClient.SaveData(Serializer.SerializeDTToXml<List<DTSerializer<string, object>>>(List_DTObj1), SQL, OperType.Delete); ComClient.SaveData1("", SQL); //2.根据表名和窗体实例名查询出更新表需要的关键信息 List_EObj = LoadData(ComClient.GetTabStrc(UpTab.FTblNm, FrmNam, OperType.AddSave, "", UpTab.FPanelNam, "", "")); //获取执行SQL foreach (ExpandoObject EObj in List_EObj) { var IDObj = (IDictionary <string, object>)EObj; SQL = (string)IDObj["SQL"]; } } List <List <ExpandoObject> > List_PanelObjs = new List <List <ExpandoObject> >(); //根据面板名称读取该面板内所有相关字段信息 List <ExpandoObject> List_Panel4EObj = Serializer.DeserializeXMLToEObject(ComClient.GetColsByPanelNam("Panel4", FrmNam, UpTab.FTblNm)); List_PanelObjs.Add(List_Panel4EObj); List <ExpandoObject> List_Panel3EObj = Serializer.DeserializeXMLToEObject(ComClient.GetColsByPanelNam("Panel3", FrmNam, UpTab.FTblNm)); List_PanelObjs.Add(List_Panel3EObj); List <ExpandoObject> List_Panel7EObj = Serializer.DeserializeXMLToEObject(ComClient.GetColsByPanelNam("Panel7", FrmNam, UpTab.FTblNm)); List_PanelObjs.Add(List_Panel7EObj); List <ExpandoObject> List_Panel8EObj = Serializer.DeserializeXMLToEObject(ComClient.GetColsByPanelNam("Panel8", FrmNam, UpTab.FTblNm)); List_PanelObjs.Add(List_Panel8EObj); List <ExpandoObject> List_Panel9EObj = Serializer.DeserializeXMLToEObject(ComClient.GetColsByPanelNam("Panel9", FrmNam, UpTab.FTblNm)); List_PanelObjs.Add(List_Panel9EObj); List <ExpandoObject> List_Panel10EObj = Serializer.DeserializeXMLToEObject(ComClient.GetColsByPanelNam("Panel10", FrmNam, UpTab.FTblNm)); List_PanelObjs.Add(List_Panel10EObj); List <ExpandoObject> List_Panel11EObj = Serializer.DeserializeXMLToEObject(ComClient.GetColsByPanelNam("Panel11", FrmNam, UpTab.FTblNm)); List_PanelObjs.Add(List_Panel11EObj); List <ExpandoObject> List_Panel12EObj = Serializer.DeserializeXMLToEObject(ComClient.GetColsByPanelNam("Panel12", FrmNam, UpTab.FTblNm)); List_PanelObjs.Add(List_Panel12EObj); //用于存储该表在所有面板内的字段值 DTSerializer <string, object> DTObj = new DTSerializer <string, object>(); foreach (List <ExpandoObject> List_PanelObj in List_PanelObjs) { if (List_PanelObj.Count != 0) { var Query = from Obj in List_PanelObj where EObjToIDObj(Obj)["FPanelNam"].ToString() == "Panel3" select Obj; //Panel3面板中是网格控件,则按照以下逻辑单独处理 if (Query.Count <ExpandoObject>() > 0) { //遍历View_Common1数据源获取每个字段的值 foreach (ExpandoObject EObj3 in (BindingList <ExpandoObject>)View_Common1.DataSource) { IDictionary <string, object> IDObj = (IDictionary <string, object>)EObj3; DTSerializer <string, object> DTObj1 = new DTSerializer <string, object>(); foreach (string Key in IDObj.Keys) { //利用LinQ将中文字段名转换成英文字段名 var Query1 = from Obj in List_PanelObj where EObjToIDObj(Obj)["FRemark"].ToString() == Key select EObjToIDObj(Obj)["FColNm"].ToString(); string Key1 = ""; foreach (var key in Query1) { Key1 = key.ToString(); } if (Key1 != "") { if (Key1 == PriKey) { DTObj1.Add(Key1, Panel4.Controls[ContrNam].Text); } else { DTObj1.Add(Key1, IDObj[Key].ToString()); } } } //3.循环完Panel3面板的每一行字段后,生成更新对象列表 List_DTObj1.Add(DTObj1); } //4.服务端根据接收到的对象列表更新数据库 //ComClient.SaveData(Serializer.SerializeDTToXml<List<DTSerializer<string, object>>>(List_DTObj1), SQL, OperType.AddSave); ComClient.SaveData1(Serializer.SerializeDTToXml <List <DTSerializer <string, object> > >(List_DTObj1), SQL); } //非Panel3面板,则按照以下逻辑单独处理 else { //根据面板内的字段信息自动生成更新对象列表 foreach (dynamic EObj in List_PanelObj) { //如果该字段绑定了指定控件,则按照控件指定值更新 if (EObj.FContrNam != "") { if (EObj.FColNm == "fCFlag") { DTObj.Add(EObj.FColNm, Panel4.Controls[EObj.FContrNam].Text == "已审核" ? 1 : 0); } else if (EObj.FColNm == "fIfUse") { DTObj.Add(EObj.FColNm, Panel4.Controls[EObj.FContrNam].Text == "已启用" ? 1 : 0); } else { if (EObj.FPanelNam == "Panel4") { DTObj.Add(EObj.FColNm, Panel4.Controls[EObj.FContrNam].Text); } else if (EObj.FPanelNam == "Panel7") { DTObj.Add(EObj.FColNm, Panel7.Controls[EObj.FContrNam].Text); } else if (EObj.FPanelNam == "Panel8") { DTObj.Add(EObj.FColNm, Panel8.Controls[EObj.FContrNam].Text); } else if (EObj.FPanelNam == "Panel9") { DTObj.Add(EObj.FColNm, Panel9.Controls[EObj.FContrNam].Text); } else if (EObj.FPanelNam == "Panel10") { DTObj.Add(EObj.FColNm, Panel10.Controls[EObj.FContrNam].Text); } else if (EObj.FPanelNam == "Panel11") { DTObj.Add(EObj.FColNm, Panel11.Controls[EObj.FContrNam].Text); } else if (EObj.FPanelNam == "Panel12") { DTObj.Add(EObj.FColNm, Panel12.Controls[EObj.FContrNam].Text); } } } //如果该字段没有绑定任何控件,则按照默认值更新 else { //如果该字段的默认数据类型是DateTime,则默认值是当天 if (EObj.FColNm == "fCDate") { DTObj.Add(EObj.FColNm, IDObj1["建立日期"].ToString()); } else if (EObj.FColNm == "fModiDate") { DTObj.Add(EObj.FColNm, DateTime.Now.ToString()); } else if (EObj.FColNm == "fModifier") { DTObj.Add(EObj.FColNm, CurUsrName); } else if (EObj.FColNm == "fModifierID") { DTObj.Add(EObj.FColNm, CurUsrID); } else if (EObj.FColNm == "fCreatorID") { DTObj.Add(EObj.FColNm, IDObj1["建立人代号"].ToString()); } else if (EObj.FColNm == "fCreator") { DTObj.Add(EObj.FColNm, IDObj1["建立人姓名"].ToString()); } else { DTObj.Add(EObj.FColNm, EObj.FDefValue); } } } //3.循环完所有面板的字段后,生成更新对象列表 List_DTObj.Add(DTObj); //4.服务端根据接收到的对象列表更新数据库 //ComClient.SaveData(Serializer.SerializeDTToXml<List<DTSerializer<string, object>>>(List_DTObj), SQL, OperType.AddSave); ComClient.SaveData1(Serializer.SerializeDTToXml <List <DTSerializer <string, object> > >(List_DTObj), SQL); ComClient.CommitTransaction(); } } } BtnName = BtnNam.Null; //重新刷新网格数据 Grip_Common2.DataSource = LoadData(UsrGroupClient.GetUsrGrpsToChCol("#Tmp_" + CurUsrID + "_" + DateTime.Now.Second.ToString(), "0", "")); } return(1); } else if (BtnName == BtnNam.Unapprove || BtnName == BtnNam.Approve || BtnName == BtnNam.Disable || BtnName == BtnNam.Enable) { //获取当前选择行的数据 IDictionary <string, object> IDObj1 = (IDictionary <string, object>)View_Common2.GetFocusedRow(); if (BtnName == BtnNam.Unapprove) { //根据表名和窗体实例名查询出更新表需要的关键信息 List_EObj = LoadData(ComClient.GetTabStrc(TabNam, FrmNam, OperType.UnApprove, PriKey + " ='" + IDObj1[ComClient.GetChColByEnCol(TabNam, PriKey)].ToString() + "'", "Panel4", CurUsrID, CurUsrName)); //获取执行SQL foreach (ExpandoObject EObj in List_EObj) { var IDObj = (IDictionary <string, object>)EObj; SQL = (string)IDObj["SQL"]; } } else if (BtnName == BtnNam.Approve) { //根据表名和窗体实例名查询出更新表需要的关键信息 List_EObj = LoadData(ComClient.GetTabStrc(TabNam, FrmNam, OperType.Approve, PriKey + " ='" + IDObj1[ComClient.GetChColByEnCol(TabNam, PriKey)].ToString() + "'", "Panel4", CurUsrID, CurUsrName)); //获取执行SQL foreach (ExpandoObject EObj in List_EObj) { var IDObj = (IDictionary <string, object>)EObj; SQL = (string)IDObj["SQL"]; } } else if (BtnName == BtnNam.Disable) { //根据表名和窗体实例名查询出更新表需要的关键信息 List_EObj = LoadData(ComClient.GetTabStrc(TabNam, FrmNam, OperType.Disable, PriKey + " ='" + IDObj1[ComClient.GetChColByEnCol(TabNam, PriKey)].ToString() + "'", "Panel4", "", "")); //获取执行SQL foreach (ExpandoObject EObj in List_EObj) { var IDObj = (IDictionary <string, object>)EObj; SQL = (string)IDObj["SQL"]; } } else if (BtnName == BtnNam.Enable) { //根据表名和窗体实例名查询出更新表需要的关键信息 List_EObj = LoadData(ComClient.GetTabStrc(TabNam, FrmNam, OperType.Enable, PriKey + " ='" + IDObj1[ComClient.GetChColByEnCol(TabNam, PriKey)].ToString() + "'", "Panel4", "", "")); //获取执行SQL foreach (ExpandoObject EObj in List_EObj) { var IDObj = (IDictionary <string, object>)EObj; SQL = (string)IDObj["SQL"]; } } //ComClient.SaveData(Serializer.SerializeDTToXml<List<DTSerializer<string, object>>>(List_DTObj), SQL, OperType.UnApprove); ComClient.SaveData1("", SQL); //提交事务 ComClient.CommitTransaction(); BtnName = BtnNam.Null; //重新刷新网格数据 Grip_Common2.DataSource = LoadData(UsrGroupClient.GetUsrGrpsToChCol("#Tmp_" + CurUsrID + "_" + DateTime.Now.Second.ToString(), "0", "")); } else { Common.ShowMsg("用户组代号不允许重复!"); return(0); } } catch (Exception Ex) { //关闭当前SQL连接 ComClient.CloseSqlCon(); Common.ShowMsg(Ex.Message); } return(0); }