예제 #1
0
        private void ToolStripMenuItem_GetBOMJob_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(tboxPartNum.Text))
            {
                var    JobAsmblDatas = ERP.GetJobAsmbl(tboxPartNum.Text);
                var    JobMtlDatas   = ERP.GetJobMtl(tboxPartNum.Text);
                string mainPart      = "";
                try
                {
                    mainPart = JobAsmblDatas.Where(o => o.JobNum == tboxPartNum.Text && o.BomLevel == 0).FirstOrDefault().PartNum;
                }
                catch { }

                List <Entity.DTO.DTO_MBOM> lists = new List <Entity.DTO.DTO_MBOM>();
                ERP.GetJobBom(lists, JobAsmblDatas, JobMtlDatas, mainPart, 0, 1);
                dataGridViewMain.DataSource = lists.ToList();

                StatusLabelInfo.Text            = "共获取" + lists.Count + "条数据";
                tabControlMain.SelectedIndex    = 0;
                tabControlMain.SelectedTab.Text = "ERP工单BOM";
                CurrentDgv = dataGridViewMain;
            }
        }
        private void BtnOK_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(tBoxPartNum.Text))
            {
                MessageBox.Show("物料编码必填!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (string.IsNullOrEmpty(tBoxJobNum.Text) && radioJob.Checked)
            {
                MessageBox.Show("工单号必填!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            BtnOK.Text    = "对比中...";
            BtnOK.Enabled = false;
            Task.Run(() =>
            {
                //获取ERP设计BOM
                ERP_DES_BOM = new List <DTO_MBOM>();
                ERP.GetERPBOM(tBoxPartNum.Text, ERP_DES_BOM, true, textBoxRev.Text);

                if (radioJob.Checked)
                {
                    //获取工单BOM
                    var JobAsmblDatas = ERP.GetJobAsmbl(tBoxJobNum.Text);
                    var JobMtlDatas   = ERP.GetJobMtl(tBoxJobNum.Text);
                    ERP_JOB_BOM       = new List <DTO_MBOM>();
                    string mainPart   = "";
                    try
                    {
                        mainPart = JobAsmblDatas.Where(o => o.JobNum == tBoxJobNum.Text && o.BomLevel == 0).FirstOrDefault().PartNum;
                    }
                    catch { }
                    ERP.GetJobBom(ERP_JOB_BOM, JobAsmblDatas, JobMtlDatas, mainPart);
                }
                else
                {
                    //获取PLMBOM
                    PLM_BOM = new List <DTO_MBOM>();
                    PLM.GetPLMBOM(tBoxPartNum.Text, PLM_BOM);
                }
                //List<DTO_MBOM> BOM_DIFF = CompareBOM(tBoxPartNum.Text, tBoxJobNum.Text);
                this.BeginInvoke(new Action(() =>
                {
                    BtnOK.Text    = "开始对比";
                    BtnOK.Enabled = true;
                    #region 导出对比结果
                    //var dt = Utility.ListToDataTable(BOM_DIFF, "_", "#");
                    //string rnd = Random.Next(0, 9999).ToString();
                    string filepath = SaveFolderPath + "\\" + tBoxPartNum.Text + "BOM_DIFF.xls";
                    long ticks      = DateTime.Now.Ticks;
                    if (radioJob.Checked)
                    {
                        filepath = SaveFolderPath + "\\DES_JOB_" + tBoxPartNum.Text + "_" + tBoxJobNum.Text + "_Compare" + ticks.ToString() + ".xls";
                        CreateDIFFBook(filepath, ERP_DES_BOM, ERP_JOB_BOM, "设计BOM", "工单BOM");
                    }
                    else
                    {
                        filepath = SaveFolderPath + "\\DES_PLM_" + tBoxPartNum.Text + "_Compare" + ticks.ToString() + ".xls";
                        CreateDIFFBook2(filepath, ERP_DES_BOM, PLM_BOM, "PLMBOM", "设计BOM");
                    }
                    //Utility.ExportExcel(dt, SaveFolderPath + "\\" + tBoxPartNum.Text + "BOM_DIFF" + rnd + ".xls");
                    System.Diagnostics.Process.Start(filepath);
                    #endregion
                }));
            });
        }