Exemplo n.º 1
0
 private void dgv1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         int i = e.ColumnIndex;
         DataGridViewColumn column = dgv1.Columns[e.ColumnIndex];
         if (column.Name == "final_prediction_qty")
         {
             if (dgv1.Rows[e.RowIndex].Cells[i].Value != null)
             {
                 string rqty = dgv1.Rows[e.RowIndex].Cells[i].Value.ToString();
                 if (BaseClass.validateNum(rqty) == false)
                 {
                     MessageBox.Show("请输入数字!!!", "提示");
                     dgv1.Rows[e.RowIndex].Cells[i].Value = "";
                 }
                 else
                 {
                     string predicqty = dgv1.Rows[e.RowIndex].Cells[i - 1].Value.ToString();
                     string finalqty  = dgv1.Rows[e.RowIndex].Cells[i].Value.ToString().Trim();
                     if (predicqty != finalqty)
                     {
                         decimal modpercent = Math.Abs(decimal.Parse(finalqty) - decimal.Parse(predicqty)) / decimal.Parse(predicqty) * 100;
                         dgv1.Rows[e.RowIndex].Cells[i + 1].Value = decimal.Round(modpercent, 1);
                         if (modpercent > 10)
                         {
                             MessageBox.Show("请输入变更原因!!!", "操作提示");
                             dgv1.Rows[e.RowIndex].Selected = true;
                         }
                     }
                 }
             }
         }
     }
 }
 private void dgv1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         int i = e.ColumnIndex;
         DataGridViewColumn column = dgv1.Columns[e.ColumnIndex];
         if (column.Name == "预估量")
         {
             if (dgv1.Rows[e.RowIndex].Cells[i].Value != null)
             {
                 string rqty = dgv1.Rows[e.RowIndex].Cells[i].Value.ToString();
                 if (BaseClass.validateNum(rqty) == false)
                 {
                     MessageBox.Show("请输入数字!!!", "提示");
                     dgv1.Rows[e.RowIndex].Cells[i].Value = "";
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
        public void CheckImportData()
        {
            #region 首先检查要导入的Excel数据中ERP代码是否在ERP系统中存在
            string       txtfilename = System.Windows.Forms.Application.StartupPath + "\\错误信息.txt";
            StreamWriter sw          = new StreamWriter(txtfilename, false, Encoding.GetEncoding("gb2312"));
            int          flag        = 0;
            try
            {
                for (int i = 0; i < dgv2.Rows.Count - 1; i++)
                {
                    string partno = dgv2.Rows[i].Cells[4].Value.ToString();
                    if (!string.IsNullOrEmpty(partno))
                    {
                        InventoryPart invpartnew = InventoryPart.FindInvInfor(partno, mSite);
                        if (invpartnew == null)
                        {
                            System.Diagnostics.Trace.WriteLine("第" + (i + 1) + "行材料编码 " + partno + " 在ERP中所选择域无此材料编码,请联系ERP操作员,在ERP中添加。");
                            sw.WriteLine("第" + (i + 1) + "行材料编码 " + partno + " 在ERP中所选择域无此材料编码,请联系ERP操作员,在ERP中添加。", "温馨提示");
                            flag = 1;
                        }
                    }
                    else
                    {
                        System.Diagnostics.Trace.WriteLine("第" + (i + 1) + "行材料编码 " + partno + " 在没有填写,在ERP中添加活查询后填写。");
                        sw.WriteLine("第" + (i + 1) + "行材料编码 " + partno + " 在没有填写,在ERP中添加活查询后填写。", "温馨提示");
                        flag = 1;
                    }
                    if (!string.IsNullOrEmpty(dgv2.Rows[i].Cells[6].Value.ToString()))
                    {
                        string rqty = dgv2.Rows[i].Cells[6].Value.ToString();
                        if (BaseClass.validateNum(rqty) == false)
                        {
                            System.Diagnostics.Trace.WriteLine("请确认第" + (i + 1) + "行" + partno + " 预估数量输入数字!!!");
                            sw.WriteLine("请确认第" + (i + 1) + "行" + partno + " 预估数量输入数字!!!", "温馨提示");
                            flag = 1;
                        }
                    }
                    if (!string.IsNullOrEmpty(dgv2.Rows[i].Cells[7].Value.ToString()))
                    {
                        string rqty = dgv2.Rows[i].Cells[7].Value.ToString();
                        if (BaseClass.validateNum(rqty) == false)
                        {
                            System.Diagnostics.Trace.WriteLine("请确认第" + (i + 1) + "行 " + partno + " 第一批生产需求数量输入数字!!!");
                            sw.WriteLine("请确认第" + (i + 1) + "行 " + partno + " 第一批生产需求数量输入数字!!!", "温馨提示");
                            flag = 1;
                        }
                    }
                    else
                    {
                        System.Diagnostics.Trace.WriteLine("请确认第" + (i + 1) + "行 " + partno + " 第一批生产需求数量没有输入数字!!!");
                        sw.WriteLine("请确认第" + (i + 1) + "行 " + partno + " 第一批生产需求数量没有输入数字!!!", "温馨提示");
                        flag = 1;
                    }
                    if (!string.IsNullOrEmpty(dgv2.Rows[i].Cells[9].Value.ToString()))
                    {
                        string rqty = dgv2.Rows[i].Cells[9].Value.ToString();
                        if (BaseClass.validateNum(rqty) == false)
                        {
                            System.Diagnostics.Trace.WriteLine("请确认第" + (i + 1) + "行 " + partno + " 第一批生产需求数量输入数字!!!");
                            sw.WriteLine("请确认第" + (i + 1) + "行 " + partno + " 第一批生产需求数量输入数字!!!", "温馨提示");
                            flag = 1;
                        }
                    }
                    else
                    {
                        System.Diagnostics.Trace.WriteLine("请确认第" + (i + 1) + "行 " + partno + " 第二批生产需求数量没有输入数字!!!");
                        sw.WriteLine("请确认第" + (i + 1) + "行 " + partno + " 第二批生产需求数量没有输入数字!!!", "温馨提示");
                        flag = 1;
                    }
                }
                if (flag == 1)
                {
                    sw.Close();
                    MessageBox.Show("要导入的预估文件数据有误,请检查!");
                    System.Diagnostics.Process.Start("explorer.exe", txtfilename);
                    return;
                }
                #endregion
                DialogResult dgresult = MessageBox.Show("确定要将预估结果进行导入吗?", "操作确认", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                if (dgresult == DialogResult.No)
                {
                    return;
                }
                #region 首先将上次的预估结果保存为历史记录(按照预估人,专业,区域进行覆盖)

                PartParameter.DeleteEstimate(mSite, ProjectId, DisciplineId);
                #endregion
                ImportDataHanlder ImportData = new ImportDataHanlder(ImportParaData);
                ImportData.BeginInvoke(null, null);
            }
            catch (Exception et) { MessageBox.Show(et.Message); }
            finally { MessageBox.Show("预估数据导入成功!!!", "操作提示"); }
        }