//暂测试保存功能 public static void Deal_DifDgdValue(string FormName, DataTable aftersave_dt, DataGridViewX dgd, string descrip_str) { try { DataTable Judge_dt = ((DataTable)dgd.DataSource).Copy(); if (aftersave_dt != null && aftersave_dt.Rows.Count == Judge_dt.Rows.Count) { for (int i = 0; i < aftersave_dt.Rows.Count; i++) { for (int j = 0; j < aftersave_dt.Columns.Count; j++) { if (aftersave_dt.Rows[i][j] != Judge_dt.Rows[i][j]) { Log4netHelper.Info(new DgdDealHelper().GetType(), string.Format("编辑表:{0}-{1},编辑项:{2},原值:{3},变化值:{4},修改者:{5}", FormName, descrip_str, Judge_dt.Rows[i][0], aftersave_dt.Rows[i][j], Judge_dt.Rows[i][j], Constant.CurUserName())); SQliteHelper.ExecuteDataTable(Constant.strConnectSQLite, CommandType.Text, string.Format("insert into {0} (tablename,tableitem,oldvalue,newvalue,modifiedby,modifieddate,descrip)values('{1}','{2}','{3}','{4}','{5}','{6}','{7}')", Constant.RecordLog_sqlname, FormName, Judge_dt.Rows[i][0], aftersave_dt.Rows[i][j], Judge_dt.Rows[i][j], Constant.CurUserName(), DateTime.Now, descrip_str), null); } continue; } } } else { Log4netHelper.Warn(new DgdDealHelper().GetType(), string.Format("检查编辑表:{0}时发生错误,修改前后行数不一致,修改者:{1}", FormName, Constant.CurUserName())); } } catch (Exception ex) { throw ex; } }
public static void AddNode_Func(TreeNode Addnode, string change_str) { try { string formname = Addnode.Text; if (change_str == "添加传感器BOM") { string lcbom_meaid_value = Guid.NewGuid().ToString(); string Mainbom = AddBOM_Module(Addnode, change_str, lcbom_meaid_value); if (Mainbom == "") { return; } string lcbominfo_str = DgdDealHelper.GetCombineInfo(Constant.Maingage_dt).ToString(); //插入数据库 sqlconnection.ExecuteDataTable(Constant.strConnectSQL_T, CommandType.Text, string.Format("insert into {0} (lcbom_meaid,lcbom,lcassembly,lcproductclass,lcproductmodel,lcbominfo,lcbominfo_test,modifiedby,modifieddate)values('{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}')", Constant.MainBom_sqlname, lcbom_meaid_value, Constant.Add_Bom, Addnode.Text, Addnode.Parent.Parent.Text, Addnode.Parent.Text, lcbominfo_str, lcbominfo_str, Constant.CurUserName(), DateTime.Now), null); SQliteHelper.ExecuteDataTable(Constant.strConnectSQLite, CommandType.Text, string.Format("insert into {0} (tablename,oldvalue,newvalue,modifiedby,modifieddate,descrip)values('{1}','{2}','{3}','{4}','{5}','{6}')", Constant.RecordLog_sqlname, formname, "", Constant.Add_Bom, Constant.CurUserName(), DateTime.Now, change_str), null); } else { string Add_str = AddBOM_Module(Addnode, change_str); if (Add_str == "") { return; } if (change_str == "添加产品容量") { sqlconnection.ExecuteDataTable(Constant.strConnectSQL_T, CommandType.Text, string.Format("insert into {0} (lcbom_meaid,lcbom,lcassembly,lcproductclass,lcproductmodel,lcbominfo,lcbominfo_test,modifiedby,modifieddate)values('{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}')", Constant.MainBom_sqlname, Guid.NewGuid(), "0", Constant.Add_Bom, Addnode.Parent.Text, Addnode.Text, "", "", Constant.CurUserName(), DateTime.Now), null); SQliteHelper.ExecuteDataTable(Constant.strConnectSQLite, CommandType.Text, string.Format("insert into {0} (tablename,oldvalue,newvalue,modifiedby,modifieddate,descrip)values('{1}','{2}','{3}','{4}','{5}','{6}')", Constant.RecordLog_sqlname, formname, "", Constant.Add_Bom, Constant.CurUserName(), DateTime.Now, change_str), null); } else if (change_str == "添加弹性体BOM") { StringBuilder Strconn = DgdDealHelper.GetCombineInfo(Constant.Elastic_dt); sqlconnection.ExecuteDataTable(Constant.strConnectSQL_T, CommandType.Text, string.Format("insert into {0}(generic_assembly,sgelasticbom,sgelasticinfo,sgelasticinfo_test)values('{1}','{2}','{3}','{4}')", Constant.Elastic_sqlname, Addnode.Parent.Text, Constant.Add_Bom, Strconn, Strconn), null); SQliteHelper.ExecuteDataTable(Constant.strConnectSQLite, CommandType.Text, string.Format("insert into {0} (tablename,oldvalue,newvalue,modifiedby,modifieddate,descrip)values('{1}','{2}','{3}','{4}','{5}','{6}')", Constant.RecordLog_sqlname, formname, "", Constant.Add_Bom, Constant.CurUserName(), DateTime.Now, change_str), null); } else if (change_str == "添加应变片BOM") { StringBuilder Strconn = DgdDealHelper.GetCombineInfo(Constant.Sgseries_dt); sqlconnection.ExecuteDataTable(Constant.strConnectSQL_T, CommandType.Text, string.Format("insert into {0} (sgseriesbom,sgseriesinfo,sgseriesinfo_test) values ('{1}','{2}','{3}')", Constant.SGseries_sqlname, Constant.Add_Bom, Strconn, Strconn), null); SQliteHelper.ExecuteDataTable(Constant.strConnectSQLite, CommandType.Text, string.Format("insert into {0} (tablename,oldvalue,newvalue,modifiedby,modifieddate,descrip)values('{1}','{2}','{3}','{4}','{5}','{6}')", Constant.RecordLog_sqlname, formname, "", Constant.Add_Bom, Constant.CurUserName(), DateTime.Now, change_str), null); } else if (change_str == "添加应变胶BOM") { StringBuilder Strconn = DgdDealHelper.GetCombineInfo(Constant.Sgglue_dt); sqlconnection.ExecuteDataTable(Constant.strConnectSQL_T, CommandType.Text, string.Format("insert into {0} (sggluebom,sgglueinfo,sgglueinfo_test) values ('{1}','{2}','{3}')", Constant.Sgglue_sqlname, Constant.Add_Bom, Strconn, Strconn), null); SQliteHelper.ExecuteDataTable(Constant.strConnectSQLite, CommandType.Text, string.Format("insert into {0} (tablename,oldvalue,newvalue,modifiedby,modifieddate,descrip)values('{1}','{2}','{3}','{4}','{5}','{6}')", Constant.RecordLog_sqlname, formname, "", Constant.Add_Bom, Constant.CurUserName(), DateTime.Now, change_str), null); } } Log4netHelper.Info(new TreeNodeHelper().GetType(), string.Format("{0}:{1}", change_str, Constant.Add_Bom)); UIHelper.DesktopNotify(true, string.Format("{0}:{1}", change_str, Constant.Add_Bom)); } catch (Exception ex) { MessageBox.Show("添加节点时发生异常:" + ex.Message); } }
public void Save(object sender, EventArgs e) { try { SendKeys.SendWait("{ENTER}"); for (int i = 0; i < dataGridViewX1.Rows.Count; i++) { if (!string.IsNullOrEmpty(dataGridViewX1.Rows[i].Cells[1].ErrorText)) { UIHelper.ToastNotify(false, "保存失败,正式生产表中存在不合理数据,请重新检查!", tabControl1); Log4netHelper.Error(this.GetType(), string.Format("正式生产表中存在不合理数据,请重新检查!第{0}行,第{1}列,原因是:{2}", i, 1, dataGridViewX1.Rows[i].Cells[1].ErrorText)); return; } } //获取盒子名称; Boxtype_str = GetBoxtypeName(); if (Boxtype_str == "NULL") { BoxType_TextBox.Focus(); return; } //先判断是否已存在 DataTable sql_dt = sqlconnection.ExecuteDataTable(Constant.strConnectSQL_T, CommandType.Text, string.Format("select sgboxtype from {0} where sgboxtype='{1}'", Constant.Boxtype_sqlname, Boxtype_str), null); if (sql_dt.Rows.Count > 0 && !submit_flag) { UIHelper.ToastNotify(false, "该型号已存在,请不要重复创建!--" + Boxtype_str, tabControl1); return; } DataTable formal_dt = ((DataTable)dataGridViewX1.DataSource).Copy(); StringBuilder Formal_strconn = DgdDealHelper.GetCombineInfo(formal_dt); if (submit_flag) { sqlconnection.ExecuteDataTable(Constant.strConnectSQL_T, CommandType.Text, string.Format("update {0} set sgboxinfo='{1}',sgboxinfo_test='{2}' where sgboxtype='{3}'", Constant.Boxtype_sqlname, Formal_strconn, Formal_strconn, Boxtype_str), null); DgdDealHelper.Deal_DifDgdValue(this.Text, NotModify_dt1, dataGridViewX1, "正式表"); UIHelper.ToastNotify(true, "表数据修改保存成功!", tabControl1); } else { sqlconnection.ExecuteDataTable(Constant.strConnectSQL_T, CommandType.Text, string.Format("insert into {0} (sgboxtype,sgboxinfo,sgboxinfo_test)values('{1}','{2}','{3}')", Constant.Boxtype_sqlname, Boxtype_str, Formal_strconn, Formal_strconn), null); SQliteHelper.ExecuteDataTable(Constant.strConnectSQLite, CommandType.Text, string.Format("insert into {0} (tablename,modifiedby,modifieddate,descrip)values('{1}','{2}','{3}','{4}')", Constant.RecordLog_sqlname, Boxtype_str, Constant.CurUserName(), DateTime.Now, "创建Boxtype"), null); //创建节点 CreateTypeNode(parent_str, Boxtype_str); UIHelper.ToastNotify(true, "表数据创建成功!", tabControl1); Log4netHelper.Info(this.GetType(), Boxtype_str + "表数据创建成功!"); } NotModify_dt1 = formal_dt; submit_flag = true; CloseCreatForm(this.Text); } catch (Exception ex) { MessageBox.Show("保存时发生异常:" + ex.Message); } }
private void RecordLogForm_Load(object sender, EventArgs e) { try { this.dataGridViewX1.RowPostPaint += new DataGridViewRowPostPaintEventHandler(DefineDTlineNO.datagridviewLineNO_style); dtInfor = SQliteHelper.ExecuteDataTable(Constant.strConnectSQLite, CommandType.Text, string.Format("select tablename 表名,tableitem 选项名,oldvalue 修改前,newvalue 修改后,modifiedby 修改者,modifieddate 修改日期,descrip 描述 from {0} order by rowid desc", Constant.RecordLog_sqlname), null); InitDataSet(); } catch (Exception ex) { MessageBox.Show("载入时发生异常:" + ex.Message); } }
public static void ModifyNode_Func(TreeNode Modifynode, string change_str, TabControl tabcontrol) { try { string formname = Modifynode.Parent.Text + "-" + Modifynode.Text; string Old_BOM = Modifynode.Text; if (change_str == "修改传感器BOM") { string ModifyBOM_str = ModityBOM_Module(tabcontrol, Modifynode, change_str); if (ModifyBOM_str == "") { return; } //从数据库中更新; sqlconnection.ExecuteDataTable(Constant.strConnectSQL_T, CommandType.Text, string.Format("update {0} set lcbom='{1}' where lcbom_meaid='{2}'", Constant.MainBom_sqlname, ModifyBOM_str, Modifynode.Tag), null); SQliteHelper.ExecuteDataTable(Constant.strConnectSQLite, CommandType.Text, string.Format("insert into {0} (tablename,oldvalue,newvalue,modifiedby,modifieddate,descrip)values('{1}','{2}','{3}','{4}','{5}','{6}')", Constant.RecordLog_sqlname, formname, Old_BOM, Constant.Add_Bom, Constant.CurUserName(), DateTime.Now, change_str), null); } else { if (ChangeConflict_Check(Modifynode, change_str)) { string New_BOM = ModityBOM_Module(tabcontrol, Modifynode, change_str); if (New_BOM == "") { return; } if (change_str == "修改弹性体BOM") { sqlconnection.ExecuteDataTable(Constant.strConnectSQL_T, CommandType.Text, string.Format("update {0} set sgelasticbom='{1}' where sgelasticbom='{2}' and generic_assembly='{3}'", Constant.Elastic_sqlname, New_BOM, Old_BOM, Modifynode.Parent.Parent.Text), null); SQliteHelper.ExecuteDataTable(Constant.strConnectSQLite, CommandType.Text, string.Format("insert into {0} (tablename,oldvalue,newvalue,modifiedby,modifieddate,descrip)values('{1}','{2}','{3}','{4}','{5}','{6}')", Constant.RecordLog_sqlname, formname, Old_BOM, Constant.Add_Bom, Constant.CurUserName(), DateTime.Now, change_str), null); } else if (change_str == "修改应变片BOM") { sqlconnection.ExecuteDataTable(Constant.strConnectSQL_T, CommandType.Text, string.Format("update {0} set sgseriesbom='{1}' where sgseriesbom='{2}'", Constant.SGseries_sqlname, New_BOM, Old_BOM), null); SQliteHelper.ExecuteDataTable(Constant.strConnectSQLite, CommandType.Text, string.Format("insert into {0} (tablename,oldvalue,newvalue,modifiedby,modifieddate,descrip)values('{1}','{2}','{3}','{4}','{5}','{6}')", Constant.RecordLog_sqlname, formname, Old_BOM, Constant.Add_Bom, Constant.CurUserName(), DateTime.Now, change_str), null); } else if (change_str == "修改应变胶BOM") { sqlconnection.ExecuteDataTable(Constant.strConnectSQL_T, CommandType.Text, string.Format("update {0} set sggluebom='{1}' where sggluebom='{2}'", Constant.Sgglue_sqlname, New_BOM, Old_BOM), null); SQliteHelper.ExecuteDataTable(Constant.strConnectSQLite, CommandType.Text, string.Format("insert into {0} (tablename,oldvalue,newvalue,modifiedby,modifieddate,descrip)values('{1}','{2}','{3}','{4}','{5}','{6}')", Constant.RecordLog_sqlname, formname, Old_BOM, Constant.Add_Bom, Constant.CurUserName(), DateTime.Now, change_str), null); } } } Log4netHelper.Info(new TreeNodeHelper().GetType(), string.Format("{0}:{1}", change_str, Constant.Add_Bom)); UIHelper.DesktopNotify(true, string.Format("{0}:{1}", change_str, Constant.Add_Bom)); } catch (Exception ex) { MessageBox.Show("修改节点时发生异常:" + ex.Message); } }
public static void DeleteNode_Func(TreeNode deletenode, string change_str, ref TabControl tabcontrol) { try { string formname = deletenode.Parent.Text + "-" + deletenode.Text; DialogResult dr; dr = MessageBox.Show(string.Format("你确定要{0}-{1}吗?", change_str, deletenode.Text), "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr == DialogResult.No) { return; } if (change_str == "删除应变片盒子") { if (ChangeConflict_Check(deletenode, change_str, null)) { foreach (TabPage tp in tabcontrol.TabPages) { if (tp.Text.Contains(deletenode.Text)) { tabcontrol.SelectedTab = tp; tabcontrol.SelectedTab.Controls.Clear(); tabcontrol.TabPages.Remove(tabcontrol.SelectedTab); break; } } sqlconnection.ExecuteDataTable(Constant.strConnectSQL_T, CommandType.Text, string.Format("delete from {0} where sgboxtype='{1}'", Constant.Boxtype_sqlname, deletenode.Text), null); SQliteHelper.ExecuteDataTable(Constant.strConnectSQLite, CommandType.Text, string.Format("insert into {0} (tablename,oldvalue,newvalue,modifiedby,modifieddate,descrip)values('{1}','{2}','{3}','{4}','{5}','{6}')", Constant.RecordLog_sqlname, formname, deletenode.Text, "", Constant.CurUserName(), DateTime.Now, change_str), null); deletenode.Nodes.Clear(); deletenode.Remove(); Log4netHelper.Info(new TreeNodeHelper().GetType(), string.Format("{0}:{1}", change_str, deletenode.Text)); UIHelper.DesktopNotify(true, change_str); } } else if (change_str == "删除传感器BOM") { //从数据库中删除; sqlconnection.ExecuteDataTable(Constant.strConnectSQL_T, CommandType.Text, string.Format("delete from {0} where lcbom_meaid='{1}' and lcbom='{2}'", Constant.MainBom_sqlname, deletenode.Tag, deletenode.Text), null); sqlconnection.ExecuteDataTable(Constant.strConnectSQL_T, CommandType.Text, string.Format("delete from {0} where sgpos_meaid='{1}'", Constant.SGpos_sqlname, deletenode.Tag), null); sqlconnection.ExecuteDataTable(Constant.strConnectSQL_T, CommandType.Text, string.Format("delete from {0} where equipparam_meaid='{1}'", Constant.SgEquip_sqlname, deletenode.Tag), null); SQliteHelper.ExecuteDataTable(Constant.strConnectSQLite, CommandType.Text, string.Format("insert into {0} (tablename,oldvalue,newvalue,modifiedby,modifieddate,descrip)values('{1}','{2}','{3}','{4}','{5}','{6}')", Constant.RecordLog_sqlname, formname, deletenode.Text, "", Constant.CurUserName(), DateTime.Now, change_str), null); deletenode.Nodes.Clear(); deletenode.Remove(); Log4netHelper.Info(new TreeNodeHelper().GetType(), string.Format("{0}:{1}", change_str, deletenode.Text)); UIHelper.DesktopNotify(true, change_str); } else if (change_str == "删除产品容量") { //从数据库中删除; sqlconnection.ExecuteDataTable(Constant.strConnectSQL_T, CommandType.Text, string.Format("delete from {0} where lcassembly='{1}' ", Constant.MainBom_sqlname, deletenode.Text), null); sqlconnection.ExecuteDataTable(Constant.strConnectSQL_T, CommandType.Text, string.Format("delete from {0} where generic_assembly='{1}'", Constant.Elastic_sqlname, deletenode.Text), null); SQliteHelper.ExecuteDataTable(Constant.strConnectSQLite, CommandType.Text, string.Format("insert into {0} (tablename,oldvalue,newvalue,modifiedby,modifieddate,descrip)values('{1}','{2}','{3}','{4}','{5}','{6}')", Constant.RecordLog_sqlname, formname, deletenode.Text, "", Constant.CurUserName(), DateTime.Now, change_str), null); deletenode.Nodes.Clear(); deletenode.Remove(); Log4netHelper.Info(new TreeNodeHelper().GetType(), string.Format("{0}:{1}", change_str, deletenode.Text)); UIHelper.DesktopNotify(true, change_str); } else { if (ChangeConflict_Check(deletenode, change_str)) { if (change_str == "删除弹性体BOM") { sqlconnection.ExecuteDataTable(Constant.strConnectSQL_T, CommandType.Text, string.Format("delete from {0} where sgelasticbom='{1}' and generic_assembly='{2}'", Constant.Elastic_sqlname, deletenode.Text, deletenode.Parent.Parent.Text), null); SQliteHelper.ExecuteDataTable(Constant.strConnectSQLite, CommandType.Text, string.Format("insert into {0} (tablename,oldvalue,newvalue,modifiedby,modifieddate,descrip)values('{1}','{2}','{3}','{4}','{5}','{6}')", Constant.RecordLog_sqlname, formname, deletenode.Text, "", Constant.CurUserName(), DateTime.Now, change_str), null); } else if (change_str == "删除应变片BOM") { sqlconnection.ExecuteDataTable(Constant.strConnectSQL_T, CommandType.Text, string.Format("delete from {0} where sgseriesbom='{1}'", Constant.SGseries_sqlname, deletenode.Text), null); SQliteHelper.ExecuteDataTable(Constant.strConnectSQLite, CommandType.Text, string.Format("insert into {0} (tablename,oldvalue,newvalue,modifiedby,modifieddate,descrip)values('{1}','{2}','{3}','{4}','{5}','{6}')", Constant.RecordLog_sqlname, formname, deletenode.Text, "", Constant.CurUserName(), DateTime.Now, change_str), null); } else if (change_str == "删除应变胶BOM") { sqlconnection.ExecuteDataTable(Constant.strConnectSQL_T, CommandType.Text, string.Format("delete from {0} where sggluebom='{1}'", Constant.Sgglue_sqlname, deletenode.Text), null); SQliteHelper.ExecuteDataTable(Constant.strConnectSQLite, CommandType.Text, string.Format("insert into {0} (tablename,oldvalue,newvalue,modifiedby,modifieddate,descrip)values('{1}','{2}','{3}','{4}','{5}','{6}')", Constant.RecordLog_sqlname, formname, deletenode.Text, "", Constant.CurUserName(), DateTime.Now, change_str), null); } deletenode.Nodes.Clear(); deletenode.Remove(); Log4netHelper.Info(new TreeNodeHelper().GetType(), string.Format("{0}:{1}", change_str, deletenode.Text)); UIHelper.DesktopNotify(true, string.Format("{0}:{1}", change_str, deletenode.Text)); } } } catch (Exception ex) { MessageBox.Show("删除节点时发生异常:" + ex.Message); UIHelper.DesktopNotify(false, "删除节点时发生异常:" + ex.Message); } }