Пример #1
0
 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);
     }
 }
Пример #2
0
        public void Save(object sender, EventArgs e)
        {
            try
            {
                SendKeys.SendWait("{ENTER}");
                if (tabControl1.SelectedTabIndex == 0)
                {
                    for (int i = 0; i < dataGridViewX1.Rows.Count; i++)
                    {
                        if (!string.IsNullOrEmpty(dataGridViewX1.Rows[i].Cells[1].ErrorText))
                        {
                            UIHelper.ToastNotify(false, "保存失败,正式生产表中存在不合理数据,请重新检查!", tabControl1);
                            //MessageBox.Show("保存失败,正式生产表中存在不合理数据,请重新检查!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            Log4netHelper.Error(this.GetType(), string.Format("正式生产表中存在不合理数据,请重新检查!第{0}行,第{1}列,原因是:{2}", i, 1, dataGridViewX1.Rows[i].Cells[1].ErrorText));
                            return;
                        }
                    }
                    DataTable     formal_dt      = ((DataTable)dataGridViewX1.DataSource).Copy();
                    StringBuilder Formal_strconn = DgdDealHelper.GetCombineInfo(formal_dt);
                    sqlconnection.ExecuteDataTable(Constant.strConnectSQL_T, CommandType.Text, string.Format("update {0} set lcbominfo='{1}' where lcbom_meaid='{2}'", Constant.MainBom_sqlname, Formal_strconn, UniqueID), null);
                    DgdDealHelper.Deal_DifDgdValue(this.Text, NotModify_dt1, dataGridViewX1, "正式表");
                    NotModify_dt1 = formal_dt;
                    UIHelper.ToastNotify(true, "已提交,正式表数据保存成功!", tabControl1);
                }
                else
                {
                    for (int j = 0; j < dataGridViewX2.Rows.Count; j++)
                    {
                        if (!string.IsNullOrEmpty(dataGridViewX2.Rows[j].Cells[1].ErrorText))
                        {
                            UIHelper.ToastNotify(false, "保存失败,样机生产表中存在不合理数据,请重新检查!", tabControl1);
                            //MessageBox.Show("保存失败,样机生产表中存在不合理数据,请重新检查!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            Log4netHelper.Error(this.GetType(), string.Format("样机生产表中存在不合理数据,请重新检查!第{0}行,第{1}列,原因是:{2}", j, 1, dataGridViewX1.Rows[j].Cells[1].ErrorText));
                            return;
                        }
                    }

                    DataTable     test_dt      = ((DataTable)dataGridViewX2.DataSource).Copy();
                    StringBuilder Test_strconn = DgdDealHelper.GetCombineInfo(test_dt);
                    sqlconnection.ExecuteDataTable(Constant.strConnectSQL_T, CommandType.Text, string.Format("update {0} set lcbominfo_test='{1}' where lcbom_meaid='{2}'", Constant.MainBom_sqlname, Test_strconn, UniqueID), null);
                    DgdDealHelper.Deal_DifDgdValue(this.Text, NotModify_dt2, dataGridViewX2, "样机表");
                    NotModify_dt2 = test_dt;
                    UIHelper.ToastNotify(true, "已提交,样机表数据保存成功!", tabControl1);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("保存时发生异常:" + ex.Message);
            }
        }