Эх сурвалжийг харах

工单只能从界面指定

callm 1 жил өмнө
parent
commit
c7f554a5e9

+ 1 - 1
UAS_MES_LGDZ/FunctionCode/Make/Make_ColorBoxLabelPrint.cs

@@ -190,7 +190,7 @@ namespace UAS_MES_NEW.Make
                         }
                     }
                     LogicHandler.GetMakeInfo(sncode.Text, out oMakeCode, out status, out ErrorMessage);
-                    if (LogicHandler.CheckStepSNAndMacode(oMakeCode == "" ? ma_code.Text : oMakeCode, User.UserSourceCode, sncode.Text, User.UserCode, out oMakeCode, out oMsID, out ErrorMessage))
+                    if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, User.UserSourceCode, sncode.Text, User.UserCode, out oMakeCode, out oMsID, out ErrorMessage))
                     {
                         string nextstepcode = dh.getFieldDataByCondition("makeserial", "ms_nextstepcode", "ms_id='" + oMsID + "'").ToString();
                         if (nextstepcode != User.CurrentStepCode)

+ 1 - 1
UAS_MES_LGDZ/FunctionCode/Make/Make_ColorBoxLabelPrint_WN.cs

@@ -190,7 +190,7 @@ namespace UAS_MES_NEW.Make
                         }
                     }
                     LogicHandler.GetMakeInfo(sncode.Text, out oMakeCode, out status, out ErrorMessage);
-                    if (LogicHandler.CheckStepSNAndMacode(oMakeCode == "" ? ma_code.Text : oMakeCode, User.UserSourceCode, sncode.Text, User.UserCode, out oMakeCode, out oMsID, out ErrorMessage))
+                    if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, User.UserSourceCode, sncode.Text, User.UserCode, out oMakeCode, out oMsID, out ErrorMessage))
                     {
                         string nextstepcode = dh.getFieldDataByCondition("makeserial", "ms_nextstepcode", "ms_id='" + oMsID + "'").ToString();
                         if (nextstepcode != User.CurrentStepCode)

+ 1 - 1
UAS_MES_LGDZ/FunctionCode/Make/Make_CustomLabelPrint.cs

@@ -167,7 +167,7 @@ namespace UAS_MES_NEW.Make
                                             string fp_path = label.Rows[0]["FP_PATH"].ToString().Replace("/app/uas/webapps/", "");
                                             fp_name = label.Rows[0]["fp_name"].ToString();
                                             WebClient wc = new WebClient();
-                                            wc.DownloadFile("http://172.16.30.253:8099/" + fp_path, @"C:\打印标签\" + fp_name);
+                                            wc.DownloadFile("http://39.165.240.186:8099/" + fp_path, @"C:\打印标签\" + fp_name);
                                         }
                                     }
                                 }

+ 1 - 1
UAS_MES_LGDZ/FunctionCode/Make/Make_FuselageLabelPrint.cs

@@ -154,7 +154,7 @@ namespace UAS_MES_NEW.Make
                     LogicHandler.GetMakeInfo(sncode.Text, out oMakeCode, out status, out oErrorMessage);
                     if (oMakeCode == "" || oMakeCode == null)
                         oMakeCode = ma_code.Text;
-                    if (LogicHandler.CheckStepSNAndMacode(oMakeCode, User.UserSourceCode, sncode.Text, User.UserCode, out oMakeCode, out oMsId, out oErrorMessage))
+                    if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, User.UserSourceCode, sncode.Text, User.UserCode, out oMakeCode, out oMsId, out oErrorMessage))
                     {
                         string nextstepcode = dh.getFieldDataByCondition("makeserial", "ms_nextstepcode", "ms_id='" + oMsId + "'").ToString();
                         if (nextstepcode != User.CurrentStepCode)

+ 1 - 1
UAS_MES_LGDZ/FunctionCode/Make/Make_FuselageLabelPrintGetIMEI.cs

@@ -154,7 +154,7 @@ namespace UAS_MES_NEW.Make
                     LogicHandler.GetMakeInfo(sncode.Text, out oMakeCode, out status, out oErrorMessage);
                     if (oMakeCode == "" || oMakeCode == null)
                         oMakeCode = ma_code.Text;
-                    if (LogicHandler.CheckStepSNAndMacode(oMakeCode, User.UserSourceCode, sncode.Text, User.UserCode, out oMakeCode, out oMsId, out oErrorMessage))
+                    if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, User.UserSourceCode, sncode.Text, User.UserCode, out oMakeCode, out oMsId, out oErrorMessage))
                     {
                         string nextstepcode = dh.getFieldDataByCondition("makeserial", "ms_nextstepcode", "ms_id='" + oMsId + "'").ToString();
                         if (nextstepcode != User.CurrentStepCode)

+ 1 - 1
UAS_MES_LGDZ/FunctionCode/Make/Make_FuselageLabelPrintGetIMEIWatch.cs

@@ -154,7 +154,7 @@ namespace UAS_MES_NEW.Make
                     LogicHandler.GetMakeInfo(sncode.Text, out oMakeCode, out status, out oErrorMessage);
                     if (oMakeCode == "" || oMakeCode == null)
                         oMakeCode = ma_code.Text;
-                    if (LogicHandler.CheckStepSNAndMacode(oMakeCode, User.UserSourceCode, sncode.Text, User.UserCode, out oMakeCode, out oMsId, out oErrorMessage))
+                    if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, User.UserSourceCode, sncode.Text, User.UserCode, out oMakeCode, out oMsId, out oErrorMessage))
                     {
                         string nextstepcode = dh.getFieldDataByCondition("makeserial", "ms_nextstepcode", "ms_id='" + oMsId + "'").ToString();
                         if (nextstepcode != User.CurrentStepCode)

+ 81 - 150
UAS_MES_LGDZ/FunctionCode/Query/Query_SpecialReport.Designer.cs

@@ -29,196 +29,127 @@
         private void InitializeComponent()
         {
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Query_SpecialReport));
-            this.Export = new UAS_MES_NEW.CustomControl.ButtonUtil.NormalButton();
             this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
-            this.Prefix = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
+            this.XYFilePath = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
             this.label5 = new System.Windows.Forms.Label();
-            this.Date = new System.Windows.Forms.DateTimePicker();
-            this.Num = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
+            this.ExportFileDialog = new System.Windows.Forms.FolderBrowserDialog();
+            this.XY = new UAS_MES_NEW.CustomControl.ButtonUtil.NormalButton();
+            this.ImportExcel1 = new System.Windows.Forms.OpenFileDialog();
+            this.pr_code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.SearchTextBox();
             this.label1 = new System.Windows.Forms.Label();
-            this.label2 = new System.Windows.Forms.Label();
-            this.label3 = new System.Windows.Forms.Label();
-            this.Rn = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
-            this.label4 = new System.Windows.Forms.Label();
-            this.Printer = new UAS_MES_NEW.CustomControl.ComBoxWithFocus.PrinterCombox();
             this.SuspendLayout();
             // 
-            // Export
-            // 
-            this.Export.AllPower = null;
-            this.Export.BackColor = System.Drawing.Color.Transparent;
-            this.Export.DownImage = ((System.Drawing.Image)(resources.GetObject("Export.DownImage")));
-            this.Export.Image = null;
-            this.Export.IsShowBorder = true;
-            this.Export.Location = new System.Drawing.Point(362, 506);
-            this.Export.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
-            this.Export.MoveImage = ((System.Drawing.Image)(resources.GetObject("Export.MoveImage")));
-            this.Export.Name = "Export";
-            this.Export.NormalImage = ((System.Drawing.Image)(resources.GetObject("Export.NormalImage")));
-            this.Export.Power = null;
-            this.Export.Size = new System.Drawing.Size(150, 56);
-            this.Export.TabIndex = 0;
-            this.Export.Text = "打印";
-            this.Export.UseVisualStyleBackColor = false;
-            this.Export.Click += new System.EventHandler(this.Export_Click);
-            // 
-            // Prefix
-            // 
-            this.Prefix.AllPower = null;
-            this.Prefix.BackColor = System.Drawing.Color.White;
-            this.Prefix.ID = null;
-            this.Prefix.Location = new System.Drawing.Point(362, 85);
-            this.Prefix.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
-            this.Prefix.Name = "Prefix";
-            this.Prefix.Power = null;
-            this.Prefix.Size = new System.Drawing.Size(278, 35);
-            this.Prefix.Str = null;
-            this.Prefix.Str1 = null;
-            this.Prefix.Str2 = null;
-            this.Prefix.TabIndex = 12;
-            this.Prefix.TextChanged += new System.EventHandler(this.inoutno_TextChanged);
+            // XYFilePath
+            // 
+            this.XYFilePath.AllPower = null;
+            this.XYFilePath.BackColor = System.Drawing.Color.White;
+            this.XYFilePath.ID = null;
+            this.XYFilePath.Location = new System.Drawing.Point(434, 149);
+            this.XYFilePath.Margin = new System.Windows.Forms.Padding(6);
+            this.XYFilePath.Name = "XYFilePath";
+            this.XYFilePath.Power = null;
+            this.XYFilePath.Size = new System.Drawing.Size(445, 35);
+            this.XYFilePath.Str = null;
+            this.XYFilePath.Str1 = null;
+            this.XYFilePath.Str2 = null;
+            this.XYFilePath.TabIndex = 12;
+            this.XYFilePath.TextChanged += new System.EventHandler(this.inoutno_TextChanged);
             // 
             // label5
             // 
             this.label5.AutoSize = true;
             this.label5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label5.Location = new System.Drawing.Point(217, 79);
+            this.label5.Location = new System.Drawing.Point(212, 143);
             this.label5.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.label5.Name = "label5";
-            this.label5.Size = new System.Drawing.Size(82, 41);
+            this.label5.Size = new System.Drawing.Size(210, 41);
             this.label5.TabIndex = 11;
-            this.label5.Text = "前缀";
-            // 
-            // Date
-            // 
-            this.Date.Location = new System.Drawing.Point(362, 190);
-            this.Date.Name = "Date";
-            this.Date.Size = new System.Drawing.Size(278, 35);
-            this.Date.TabIndex = 13;
-            // 
-            // Num
-            // 
-            this.Num.AllPower = null;
-            this.Num.BackColor = System.Drawing.Color.White;
-            this.Num.ID = null;
-            this.Num.Location = new System.Drawing.Point(362, 310);
-            this.Num.Margin = new System.Windows.Forms.Padding(6);
-            this.Num.Name = "Num";
-            this.Num.Power = null;
-            this.Num.Size = new System.Drawing.Size(278, 35);
-            this.Num.Str = null;
-            this.Num.Str1 = null;
-            this.Num.Str2 = null;
-            this.Num.TabIndex = 14;
+            this.label5.Text = "原始坐标文件";
+            // 
+            // XY
+            // 
+            this.XY.AllPower = null;
+            this.XY.BackColor = System.Drawing.Color.Transparent;
+            this.XY.DownImage = ((System.Drawing.Image)(resources.GetObject("XY.DownImage")));
+            this.XY.Image = null;
+            this.XY.IsShowBorder = true;
+            this.XY.Location = new System.Drawing.Point(434, 223);
+            this.XY.Margin = new System.Windows.Forms.Padding(6);
+            this.XY.MoveImage = ((System.Drawing.Image)(resources.GetObject("XY.MoveImage")));
+            this.XY.Name = "XY";
+            this.XY.NormalImage = ((System.Drawing.Image)(resources.GetObject("XY.NormalImage")));
+            this.XY.Power = null;
+            this.XY.Size = new System.Drawing.Size(177, 56);
+            this.XY.TabIndex = 187;
+            this.XY.Text = "导入原始坐标";
+            this.XY.UseVisualStyleBackColor = false;
+            this.XY.Click += new System.EventHandler(this.XY_Click);
+            // 
+            // ImportExcel1
+            // 
+            this.ImportExcel1.FileName = "ImportExcel";
+            // 
+            // pr_code
+            // 
+            this.pr_code.AllPower = "ifall";
+            this.pr_code.Caller = null;
+            this.pr_code.Condition = null;
+            this.pr_code.DBTitle = "回流工序";
+            this.pr_code.Font = new System.Drawing.Font("微软雅黑", 9F);
+            this.pr_code.FormName = null;
+            this.pr_code.Location = new System.Drawing.Point(434, 74);
+            this.pr_code.Margin = new System.Windows.Forms.Padding(5);
+            this.pr_code.Name = "pr_code";
+            this.pr_code.Power = "ifspecial";
+            this.pr_code.ReturnData = null;
+            this.pr_code.SelectField = null;
+            this.pr_code.SetValueField = null;
+            this.pr_code.Size = new System.Drawing.Size(445, 44);
+            this.pr_code.TabIndex = 239;
+            this.pr_code.TableName = null;
+            this.pr_code.Tag = "";
+            this.pr_code.TextBoxEnable = false;
             // 
             // label1
             // 
             this.label1.AutoSize = true;
             this.label1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label1.Location = new System.Drawing.Point(217, 304);
+            this.label1.Location = new System.Drawing.Point(212, 74);
             this.label1.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.label1.Name = "label1";
-            this.label1.Size = new System.Drawing.Size(82, 41);
-            this.label1.TabIndex = 15;
-            this.label1.Text = "数量";
-            // 
-            // label2
-            // 
-            this.label2.AutoSize = true;
-            this.label2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label2.Location = new System.Drawing.Point(217, 190);
-            this.label2.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.label2.Name = "label2";
-            this.label2.Size = new System.Drawing.Size(82, 41);
-            this.label2.TabIndex = 16;
-            this.label2.Text = "日期";
-            // 
-            // label3
-            // 
-            this.label3.AutoSize = true;
-            this.label3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label3.Location = new System.Drawing.Point(217, 411);
-            this.label3.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.label3.Name = "label3";
-            this.label3.Size = new System.Drawing.Size(82, 41);
-            this.label3.TabIndex = 18;
-            this.label3.Text = "流水";
-            // 
-            // Rn
-            // 
-            this.Rn.AllPower = null;
-            this.Rn.BackColor = System.Drawing.Color.White;
-            this.Rn.ID = null;
-            this.Rn.Location = new System.Drawing.Point(362, 417);
-            this.Rn.Margin = new System.Windows.Forms.Padding(6);
-            this.Rn.Name = "Rn";
-            this.Rn.Power = null;
-            this.Rn.Size = new System.Drawing.Size(278, 35);
-            this.Rn.Str = null;
-            this.Rn.Str1 = null;
-            this.Rn.Str2 = null;
-            this.Rn.TabIndex = 17;
-            this.Rn.Text = "1";
-            // 
-            // label4
-            // 
-            this.label4.AutoSize = true;
-            this.label4.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label4.Location = new System.Drawing.Point(801, 85);
-            this.label4.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.label4.Name = "label4";
-            this.label4.Size = new System.Drawing.Size(114, 41);
-            this.label4.TabIndex = 186;
-            this.label4.Text = "打印机";
-            // 
-            // Printer
-            // 
-            this.Printer.Location = new System.Drawing.Point(960, 85);
-            this.Printer.Margin = new System.Windows.Forms.Padding(8);
-            this.Printer.Name = "Printer";
-            this.Printer.Size = new System.Drawing.Size(291, 50);
-            this.Printer.TabIndex = 185;
+            this.label1.Size = new System.Drawing.Size(146, 41);
+            this.label1.TabIndex = 240;
+            this.label1.Text = "产品编号";
             // 
             // Query_SpecialReport
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1494, 1075);
-            this.Controls.Add(this.label4);
-            this.Controls.Add(this.Printer);
-            this.Controls.Add(this.label3);
-            this.Controls.Add(this.Rn);
-            this.Controls.Add(this.label2);
             this.Controls.Add(this.label1);
-            this.Controls.Add(this.Num);
-            this.Controls.Add(this.Date);
-            this.Controls.Add(this.Prefix);
+            this.Controls.Add(this.pr_code);
+            this.Controls.Add(this.XY);
+            this.Controls.Add(this.XYFilePath);
             this.Controls.Add(this.label5);
-            this.Controls.Add(this.Export);
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
-            this.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
+            this.Margin = new System.Windows.Forms.Padding(6);
             this.Name = "Query_SpecialReport";
             this.Tag = "Query!SpecialReport";
             this.Text = "Query_SpecialReport";
             this.Load += new System.EventHandler(this.Query_SpecialReport_Load);
-            this.ResumeLayout(true);
+            this.ResumeLayout(false);
             this.PerformLayout();
 
         }
 
         #endregion
-
-        private CustomControl.ButtonUtil.NormalButton Export;
         private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1;
-        private CustomControl.TextBoxWithIcon.EnterTextBox Prefix;
+        private CustomControl.TextBoxWithIcon.EnterTextBox XYFilePath;
         private System.Windows.Forms.Label label5;
-        private System.Windows.Forms.DateTimePicker Date;
-        private CustomControl.TextBoxWithIcon.EnterTextBox Num;
+        private System.Windows.Forms.FolderBrowserDialog ExportFileDialog;
+        private CustomControl.ButtonUtil.NormalButton XY;
+        private System.Windows.Forms.OpenFileDialog ImportExcel1;
+        private CustomControl.TextBoxWithIcon.SearchTextBox pr_code;
         private System.Windows.Forms.Label label1;
-        private System.Windows.Forms.Label label2;
-        private System.Windows.Forms.Label label3;
-        private CustomControl.TextBoxWithIcon.EnterTextBox Rn;
-        private System.Windows.Forms.Label label4;
-        private CustomControl.ComBoxWithFocus.PrinterCombox Printer;
     }
 }

+ 143 - 76
UAS_MES_LGDZ/FunctionCode/Query/Query_SpecialReport.cs

@@ -1,5 +1,11 @@
-using LabelManager2;
+using DevExpress.Printing.Core.PdfExport.Metafile;
+using LabelManager2;
+using NPOI.HSSF.UserModel;
+using NPOI.SS.Formula.Functions;
+using NPOI.SS.UserModel;
 using System;
+using System.Data;
+using System.IO;
 using System.Linq;
 using System.Threading;
 using System.Windows.Forms;
@@ -15,10 +21,6 @@ namespace UAS_MES_NEW.Query
 
         DataHelper dh = SystemInf.dh;
 
-        ApplicationClass lbl;
-
-        Document doc;
-
         Thread InitPrint;
 
         public Query_SpecialReport()
@@ -26,97 +28,162 @@ namespace UAS_MES_NEW.Query
             InitializeComponent();
         }
 
-        private void Export_Click(object sender, EventArgs e)
+        private void Query_SpecialReport_Load(object sender, EventArgs e)
         {
-            ExcelExport("");
+            pr_code.TableName = "product";
+            pr_code.SelectField = "pr_code # 产品编号,pr_detail # 产品名称,pr_spec # 产品规格";
+            pr_code.FormName = Name;
+            pr_code.DBTitle = "物料查询";
+            pr_code.SetValueField = new string[] { "pr_code" };
         }
 
-        //选择导出Excel时是选择导出数据的还是模板
-        private void ExcelExport(string DataOrTemplet)
+        private static string lpad(int length, string number)
         {
-            for (int i = int.Parse(Rn.Text); i < int.Parse(Num.Text); i = i + 8)
+            while (number.Length < length)
             {
-                int temp = i;
-                for (int j = 0; j < doc.Variables.FormVariables.Count; j++)
-                {
-                    switch (doc.Variables.FormVariables.Item(j + 1).Name)
-                    {
-                        case "RN1":
-                            doc.Variables.FormVariables.Item(j + 1).Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp).ToString()));
-                            Console.WriteLine(doc.Variables.FormVariables.Item(j + 1).Value);
-                            break;
-                        case "RN2":
-                            doc.Variables.FormVariables.Item(j + 1).Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp + 1).ToString()));
-                            Console.WriteLine(doc.Variables.FormVariables.Item(j + 1).Value);
-                            break;
-                        case "RN3":
-                            doc.Variables.FormVariables.Item(j + 1).Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp + 2).ToString()));
-                            Console.WriteLine(doc.Variables.FormVariables.Item(j + 1).Value);
-                            break;
-                        case "RN4":
-                            doc.Variables.FormVariables.Item(j + 1).Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp + 3).ToString()));
-                            Console.WriteLine(doc.Variables.FormVariables.Item(j + 1).Value);
-                            break;
-                        case "RN5":
-                            doc.Variables.FormVariables.Item(j + 1).Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp + 4).ToString()));
-                            Console.WriteLine(doc.Variables.FormVariables.Item(j + 1).Value);
-                            break;
-                        case "RN6":
-                            doc.Variables.FormVariables.Item(j + 1).Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp + 5).ToString()));
-                            Console.WriteLine(doc.Variables.FormVariables.Item(j + 1).Value);
-                            break;
-                        case "RN7":
-                            doc.Variables.FormVariables.Item(j + 1).Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp + 6).ToString()));
-                            Console.WriteLine(doc.Variables.FormVariables.Item(j + 1).Value);
-                            break;
-                        case "RN8":
-                            doc.Variables.FormVariables.Item(j + 1).Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp + 7).ToString()));
-                            Console.WriteLine(doc.Variables.FormVariables.Item(j + 1).Value);
-                            break;
-                        default:
-                            break;
-                    }
-                }
-                doc.Printer.SwitchTo(Printer.Text);
-                doc.PrintDocument(1);
+                number = "0" + number;
             }
+            number = number.Substring(number.Length - length, length);
+            return number;
         }
 
-        private void Query_SpecialReport_Load(object sender, EventArgs e)
+        private void inoutno_TextChanged(object sender, EventArgs e)
         {
-            InitPrint = new Thread(InPrint);
-            SetLoadingWindow stw = new SetLoadingWindow(InitPrint, "初始化打印程序");
-            BaseUtil.SetFormCenter(stw);
-            stw.ShowDialog();
-            doc = lbl.Documents.Open(System.Windows.Forms.Application.StartupPath + @"\SN.lab");
+
         }
 
-        private void InPrint()
+        private void XY_Click(object sender, EventArgs e)
         {
-            try
-            {
-                lbl = new ApplicationClass();
-                BaseUtil.WriteLbl();
-            }
-            catch (Exception)
+            ImportExcel1.Filter = "(*.xls)|*.xls";
+            DialogResult result;
+            result = ImportExcel1.ShowDialog();
+
+            DataTable BOM = (DataTable)dh.ExecuteSql("select * from BOMDetail LEFT JOIN bom on bd_bomid=bo_id left join " +
+                "Product ON bd_soncode=pr_code where bo_mothercode='" + pr_code + "'", "select");
+            if (result == DialogResult.OK)
             {
-                MessageBox.Show("未正确安装BarTender软件");
+                XYFilePath.Text = ImportExcel1.FileName;
+                DataTable dt = ExcelToDataTable(ImportExcel1.FileName, true);
+                for (int i = 0; i < dt.Rows.Count; i++)
+                {
+                    for (int j = 0; j < BOM.Rows.Count; j++)
+                    {
+                        string Refer = dt.Rows[i]["Refer"].ToString();
+                    }
+                }
             }
         }
 
-        private static string lpad(int length, string number)
+        public static DataTable ExcelToDataTable(string filePath, bool isColumnName)
         {
-            while (number.Length < length)
+            DataTable dataTable = null;
+            FileStream fs = null;
+            DataColumn column = null;
+            DataRow dataRow = null;
+            IWorkbook workbook = null;
+            ISheet sheet = null;
+            IRow row = null;
+            ICell cell = null;
+            int startRow = 0;
+            try
             {
-                number = "0" + number;
-            }
-            number = number.Substring(number.Length - length, length);
-            return number;
-        }
+                using (fs = File.OpenRead(filePath))
+                {
+                    // 2007版本
+                    workbook = new HSSFWorkbook(fs);
+                    if (workbook != null)
+                    {
+                        sheet = workbook.GetSheetAt(0);//读取第一个sheet,当然也可以循环读取每个sheet
+                        dataTable = new DataTable();
+                        if (sheet != null)
+                        {
+                            int rowCount = sheet.LastRowNum;//总行数
+                            if (rowCount > 0)
+                            {
+                                IRow firstRow = sheet.GetRow(0);//第一行
+                                int cellCount = firstRow.LastCellNum;//列数
 
-        private void inoutno_TextChanged(object sender, EventArgs e)
-        {
+                                //构建datatable的列
+                                if (isColumnName)
+                                {
+                                    startRow = 1;//如果第一行是列名,则从第二行开始读取
+                                    for (int i = firstRow.FirstCellNum; i < cellCount; ++i)
+                                    {
+                                        cell = firstRow.GetCell(i);
+                                        if (cell != null)
+                                        {
+                                            if (cell.StringCellValue != null)
+                                            {
+                                                column = new DataColumn(cell.StringCellValue);
+                                                dataTable.Columns.Add(column);
+                                            }
+                                        }
+                                    }
+                                }
+                                else
+                                {
+                                    for (int i = firstRow.FirstCellNum; i < cellCount; ++i)
+                                    {
+                                        column = new DataColumn("column" + (i + 1));
+                                        dataTable.Columns.Add(column);
+                                    }
+                                }
+                                //填充行
+                                for (int i = startRow; i <= rowCount; ++i)
+                                {
+                                    row = sheet.GetRow(i);
+                                    if (row == null) continue;
 
+                                    dataRow = dataTable.NewRow();
+                                    for (int j = row.FirstCellNum; j < cellCount; ++j)
+                                    {
+                                        cell = row.GetCell(j);
+                                        if (cell == null)
+                                        {
+                                            dataRow[j] = "";
+                                        }
+                                        else
+                                        {
+                                            //CellType(Unknown = -1,Numeric = 0,String = 1,Formula = 2,Blank = 3,Boolean = 4,Error = 5,)
+                                            switch (cell.CellType)
+                                            {
+                                                case CellType.BLANK:
+                                                    dataRow[j] = "";
+                                                    break;
+                                                case CellType.NUMERIC:
+                                                    short format = cell.CellStyle.DataFormat;
+                                                    //对时间格式(2015.12.5、2015/12/5、2015-12-5等)的处理
+                                                    if (format == 14 || format == 31 || format == 57 || format == 58)
+                                                        dataRow[j] = cell.DateCellValue;
+                                                    else
+                                                        dataRow[j] = cell.NumericCellValue;
+                                                    break;
+                                                case CellType.STRING:
+                                                    dataRow[j] = cell.StringCellValue;
+                                                    break;
+                                                case CellType.FORMULA:
+                                                    dataRow[j] = cell.StringCellValue;
+                                                    break;
+                                            }
+                                        }
+                                    }
+                                    dataTable.Rows.Add(dataRow);
+                                }
+                            }
+                        }
+                    }
+                }
+                return dataTable;
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine(ex.Message);
+                if (fs != null)
+                {
+                    fs.Close();
+                }
+                return null;
+            }
         }
     }
 }

+ 11 - 5
UAS_MES_LGDZ/FunctionCode/Query/Query_SpecialReport.resx

@@ -117,8 +117,14 @@
   <resheader name="writer">
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
+  <metadata name="folderBrowserDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>17, 17</value>
+  </metadata>
+  <metadata name="ExportFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>282, 17</value>
+  </metadata>
   <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
-  <data name="Export.DownImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+  <data name="XY.DownImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>
         iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
         dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAFcSURBVFhH5di7UsJAFMbxtDT6QMI76IAFT0npIE0K
@@ -130,7 +136,7 @@
         oPrhusndcPinpIXd2N8gIusbTaFspKtR2SQAAAAASUVORK5CYII=
 </value>
   </data>
-  <data name="Export.MoveImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+  <data name="XY.MoveImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>
         iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
         dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAFzSURBVFhH5djNSgJRGMZxL2P2gTfQFbZvHSEZFBEW
@@ -143,7 +149,7 @@
         gg==
 </value>
   </data>
-  <data name="Export.NormalImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+  <data name="XY.NormalImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>
         iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
         dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAGVSURBVFhH5di7agJRFIXhDSKoYBQEC8FCECwEQRBE
@@ -156,7 +162,7 @@
         ROJSU3qXjMKwG/vjzEz/skOI3Zqgv7AAAAAASUVORK5CYII=
 </value>
   </data>
-  <metadata name="folderBrowserDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>17, 17</value>
+  <metadata name="ImportExcel1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>1018, 17</value>
   </metadata>
 </root>