瀏覽代碼

特殊报表

章政 8 年之前
父節點
當前提交
62247f6ddf

+ 39 - 24
UAS-MES/FunctionCode/Query/Query_SpecialReport.Designer.cs

@@ -50,12 +50,13 @@
             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(181, 272);
+            this.Export.Location = new System.Drawing.Point(241, 340);
+            this.Export.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
             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(75, 28);
+            this.Export.Size = new System.Drawing.Size(100, 35);
             this.Export.TabIndex = 0;
             this.Export.Text = "导出";
             this.Export.UseVisualStyleBackColor = false;
@@ -65,9 +66,10 @@
             // 
             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(53, 80);
+            this.label1.Location = new System.Drawing.Point(71, 100);
+            this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label1.Name = "label1";
-            this.label1.Size = new System.Drawing.Size(52, 21);
+            this.label1.Size = new System.Drawing.Size(65, 27);
             this.label1.TabIndex = 1;
             this.label1.Text = "SERIE";
             // 
@@ -75,9 +77,10 @@
             // 
             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(53, 116);
+            this.label2.Location = new System.Drawing.Point(71, 145);
+            this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label2.Name = "label2";
-            this.label2.Size = new System.Drawing.Size(77, 21);
+            this.label2.Size = new System.Drawing.Size(95, 27);
             this.label2.TabIndex = 2;
             this.label2.Text = "CARTON";
             // 
@@ -85,9 +88,10 @@
             // 
             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(53, 194);
+            this.label3.Location = new System.Drawing.Point(71, 242);
+            this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label3.Name = "label3";
-            this.label3.Size = new System.Drawing.Size(81, 21);
+            this.label3.Size = new System.Drawing.Size(100, 27);
             this.label3.TabIndex = 3;
             this.label3.Text = "DATECRE";
             // 
@@ -95,9 +99,10 @@
             // 
             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(53, 153);
+            this.label4.Location = new System.Drawing.Point(71, 191);
+            this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label4.Name = "label4";
-            this.label4.Size = new System.Drawing.Size(75, 21);
+            this.label4.Size = new System.Drawing.Size(92, 27);
             this.label4.TabIndex = 4;
             this.label4.Text = "PALETTE";
             // 
@@ -106,10 +111,11 @@
             this.SerialNum.AllPower = null;
             this.SerialNum.BackColor = System.Drawing.Color.White;
             this.SerialNum.ID = null;
-            this.SerialNum.Location = new System.Drawing.Point(181, 80);
+            this.SerialNum.Location = new System.Drawing.Point(241, 100);
+            this.SerialNum.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
             this.SerialNum.Name = "SerialNum";
             this.SerialNum.Power = null;
-            this.SerialNum.Size = new System.Drawing.Size(196, 21);
+            this.SerialNum.Size = new System.Drawing.Size(260, 25);
             this.SerialNum.Str = null;
             this.SerialNum.Str1 = null;
             this.SerialNum.Str2 = null;
@@ -120,10 +126,11 @@
             this.CartonBegin.AllPower = null;
             this.CartonBegin.BackColor = System.Drawing.Color.White;
             this.CartonBegin.ID = null;
-            this.CartonBegin.Location = new System.Drawing.Point(181, 120);
+            this.CartonBegin.Location = new System.Drawing.Point(241, 150);
+            this.CartonBegin.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
             this.CartonBegin.Name = "CartonBegin";
             this.CartonBegin.Power = null;
-            this.CartonBegin.Size = new System.Drawing.Size(196, 21);
+            this.CartonBegin.Size = new System.Drawing.Size(260, 25);
             this.CartonBegin.Str = null;
             this.CartonBegin.Str1 = null;
             this.CartonBegin.Str2 = null;
@@ -134,10 +141,11 @@
             this.CartonEnd.AllPower = null;
             this.CartonEnd.BackColor = System.Drawing.Color.White;
             this.CartonEnd.ID = null;
-            this.CartonEnd.Location = new System.Drawing.Point(377, 120);
+            this.CartonEnd.Location = new System.Drawing.Point(503, 150);
+            this.CartonEnd.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
             this.CartonEnd.Name = "CartonEnd";
             this.CartonEnd.Power = null;
-            this.CartonEnd.Size = new System.Drawing.Size(196, 21);
+            this.CartonEnd.Size = new System.Drawing.Size(260, 25);
             this.CartonEnd.Str = null;
             this.CartonEnd.Str1 = null;
             this.CartonEnd.Str2 = null;
@@ -148,10 +156,11 @@
             this.PaletteEnd.AllPower = null;
             this.PaletteEnd.BackColor = System.Drawing.Color.White;
             this.PaletteEnd.ID = null;
-            this.PaletteEnd.Location = new System.Drawing.Point(377, 157);
+            this.PaletteEnd.Location = new System.Drawing.Point(503, 196);
+            this.PaletteEnd.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
             this.PaletteEnd.Name = "PaletteEnd";
             this.PaletteEnd.Power = null;
-            this.PaletteEnd.Size = new System.Drawing.Size(196, 21);
+            this.PaletteEnd.Size = new System.Drawing.Size(260, 25);
             this.PaletteEnd.Str = null;
             this.PaletteEnd.Str1 = null;
             this.PaletteEnd.Str2 = null;
@@ -162,10 +171,11 @@
             this.PaletteBegin.AllPower = null;
             this.PaletteBegin.BackColor = System.Drawing.Color.White;
             this.PaletteBegin.ID = null;
-            this.PaletteBegin.Location = new System.Drawing.Point(181, 157);
+            this.PaletteBegin.Location = new System.Drawing.Point(241, 196);
+            this.PaletteBegin.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
             this.PaletteBegin.Name = "PaletteBegin";
             this.PaletteBegin.Power = null;
-            this.PaletteBegin.Size = new System.Drawing.Size(196, 21);
+            this.PaletteBegin.Size = new System.Drawing.Size(260, 25);
             this.PaletteBegin.Str = null;
             this.PaletteBegin.Str1 = null;
             this.PaletteBegin.Str2 = null;
@@ -173,16 +183,19 @@
             // 
             // InDate
             // 
-            this.InDate.Location = new System.Drawing.Point(181, 194);
+            this.InDate.Checked = false;
+            this.InDate.Location = new System.Drawing.Point(241, 242);
+            this.InDate.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
             this.InDate.Name = "InDate";
-            this.InDate.Size = new System.Drawing.Size(196, 21);
+            this.InDate.ShowCheckBox = true;
+            this.InDate.Size = new System.Drawing.Size(260, 25);
             this.InDate.TabIndex = 10;
             // 
             // Query_SpecialReport
             // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(747, 538);
+            this.ClientSize = new System.Drawing.Size(996, 672);
             this.Controls.Add(this.InDate);
             this.Controls.Add(this.PaletteEnd);
             this.Controls.Add(this.PaletteBegin);
@@ -195,9 +208,11 @@
             this.Controls.Add(this.label1);
             this.Controls.Add(this.Export);
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+            this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
             this.Name = "Query_SpecialReport";
             this.Tag = "Query!SpecialReport";
             this.Text = "Query_SpecialReport";
+            this.Load += new System.EventHandler(this.Query_SpecialReport_Load);
             this.ResumeLayout(false);
             this.PerformLayout();
 

+ 92 - 48
UAS-MES/FunctionCode/Query/Query_SpecialReport.cs

@@ -8,6 +8,7 @@ using System.Text;
 using System.Windows.Forms;
 using UAS_MES.DataOperate;
 using UAS_MES.Entity;
+using UAS_MES.PublicMethod;
 
 namespace UAS_MES.Query
 {
@@ -26,7 +27,6 @@ namespace UAS_MES.Query
             ExcelExport("");
         }
 
-
         //选择导出Excel时是选择导出数据的还是模板
         private void ExcelExport(string DataOrTemplet)
         {
@@ -45,89 +45,133 @@ namespace UAS_MES.Query
                 dt = (DataTable)dh.ExecuteSql("select st_id,st_tablesql,st_condition from SEARCHTEMPLATE where st_title='ZIDE出货报表'", "select");
                 if (dt.Rows.Count > 0)
                 {
+                    string InOutNo = "";
                     st_tablesql = dt.Rows[0]["st_tablesql"].ToString();
                     st_id = dt.Rows[0]["st_id"].ToString();
                     st_condition = dt.Rows[0]["st_condition"].ToString();
-                    dt = (DataTable)dh.ExecuteSql("select stg_field,stg_text,stg_table,stg_formula,stg_type from  SEARCHTEMPLATEgrid where stg_stid='" + st_id + "'", "select");
                     string SQLField = "";
-                    for (int i = 0; i < dt.Rows.Count; i++)
-                    {
-                        if (dt.Rows[i]["stg_table"].ToString() != "")
-                        {
-                            if (dt.Rows[i]["stg_type"].ToString() == "DATE")
-                            {
-                                SQLField += "to_char(" + dt.Rows[i]["stg_field"].ToString() + ",'YYYYMMDD') as " + dt.Rows[i]["stg_text"].ToString() + ",";
-                            }
-                            else
-                            {
-                                SQLField += dt.Rows[i]["stg_field"].ToString() + " as " + dt.Rows[i]["stg_text"].ToString() + ",";
-                            }
-                        }
-                        else
-                        {
-                            if (dt.Rows[i]["stg_formula"].ToString().Replace("'", "").Trim() == "")
-                                SQLField += "''" + " as " + dt.Rows[i]["stg_text"].ToString() + ",";
-                            else
-                                SQLField += dt.Rows[i]["stg_formula"].ToString() + " as " + dt.Rows[i]["stg_text"].ToString() + ",";
-                        }
-                    }
-                    SQLField = SQLField.Substring(0, SQLField.Length - 1);
-                    string sql = "select " + SQLField + " from " + st_tablesql;
-                    if (st_condition != "")
-                    {
-                        sql += " where " + st_condition;
-                    }
+                    string AddCondition = "";
                     if (SerialNum.Text != "")
                     {
-                        sql += " and ms_sncode='" + SerialNum.Text + "'";
+                        AddCondition += " and ms_sncode='" + SerialNum.Text + "'";
                     }
                     if (CartonBegin.Text != "" || CartonEnd.Text != "")
                     {
                         if (CartonBegin.Text != "" && CartonEnd.Text == "")
                         {
-                            sql += " and ms_outboxcode> '" + CartonBegin.Text + "' ";
+                            AddCondition += " and ms_outboxcode> '" + CartonBegin.Text + "' ";
                         }
                         if (CartonBegin.Text == "" && CartonEnd.Text != "")
                         {
-                            sql += " and ms_outboxcode< '" + CartonBegin.Text + "' ";
+                            AddCondition += " and ms_outboxcode< '" + CartonBegin.Text + "' ";
                         }
                         if (CartonBegin.Text != "" && CartonEnd.Text != "")
                         {
-                            sql += " and ms_outboxcode between '" + CartonBegin.Text + "' and '" + CartonEnd.Text + "' ";
+                            AddCondition += " and ms_outboxcode between '" + CartonBegin.Text + "' and '" + CartonEnd.Text + "' ";
                         }
                     }
                     if (PaletteBegin.Text != "" || PaletteBegin.Text != "")
                     {
                         if (PaletteBegin.Text != "" && PaletteEnd.Text == "")
                         {
-                            sql += " and v_outboxcode> '" + PaletteBegin.Text + "' ";
+                            AddCondition += " and v_outboxcode> '" + PaletteBegin.Text + "' ";
                         }
                         if (PaletteBegin.Text == "" && PaletteEnd.Text != "")
                         {
-                            sql += " and v_outboxcode< '" + PaletteEnd.Text + "' ";
+                            AddCondition += " and v_outboxcode< '" + PaletteEnd.Text + "' ";
                         }
                         if (PaletteBegin.Text != "" && PaletteEnd.Text != "")
                         {
-                            sql += " and v_outboxcode between '" + PaletteBegin.Text + "' and '" + PaletteEnd.Text + "' ";
+                            AddCondition += " and v_outboxcode between '" + PaletteBegin.Text + "' and '" + PaletteEnd.Text + "' ";
+                        }
+                    }
+                    if (InDate.Checked)
+                    {
+                        AddCondition += " and trunc(ms_indate) = trunc(to_date('" + InDate.Value.ToString("yyyy-MM-dd") + "','yyyy-MM-dd')) ";
+                    }
+                    string GetInOutNoSQL = "select ms_outno from " + st_tablesql;
+                    if (st_condition != "")
+                    {
+                        GetInOutNoSQL += " where " + st_condition;
+                    }
+                    //获取出货单号
+                    dt = (DataTable)dh.ExecuteSql(GetInOutNoSQL + AddCondition + " and rownum=1", "select");
+                    if (dt.Rows.Count > 0)
+                    {
+                        InOutNo = dt.Rows[0]["ms_outno"].ToString();
+                    }
+                    DataTable SeqTanle = (DataTable)dh.ExecuteSql("select cl_code,cl_result from commandlog where cl_operate='导出特殊报表' order by cl_id desc", "select");
+                    string SEQ_NUMBER = "";
+                    string SEQ = "";
+                    string SEQ_PreFix = "NL" + DateTime.Now.Year.ToString().Substring(2, 2) + (DateTime.Now.DayOfYear < 100 ? "0" + DateTime.Now.DayOfYear.ToString() : DateTime.Now.DayOfYear.ToString()) + "COC";
+                    if (SeqTanle.Rows.Count > 0)
+                    {
+                        //如果今天已经包含本出货单则导出的使用之前的流水
+                        DataRow[] dr = SeqTanle.Select("cl_result='" + InOutNo + "'");
+                        if (dr.Length > 0)
+                        {
+                            SEQ_NUMBER = dr[0]["cl_code"].ToString();
+                            SEQ = SEQ_PreFix + SEQ_NUMBER;
+                        }
+                        else
+                        {
+                            SEQ_NUMBER = SeqTanle.Rows[0]["cl_code"].ToString();
+                            int temp = int.Parse(SEQ_NUMBER) + 1;
+                            SEQ_NUMBER = temp.ToString().PadLeft(5, '0');
+                            SEQ = SEQ_PreFix + SEQ_NUMBER;
+                            LogicHandler.DoCommandLog(Tag.ToString(), User.CurrentStepCode, "", "", User.UserSourceCode, "导出特殊报表", InOutNo, SEQ, SEQ_NUMBER);
                         }
                     }
-                    if (InDate.Text != "")
+                    else
                     {
-                        sql += " and trunc(ms_indate) = trunc(to_date('" + InDate.Value.ToString("yyyy-MM-dd") + "','yyyy-MM-dd')) ";
+                        SEQ = SEQ_PreFix + "00001";
+                        LogicHandler.DoCommandLog(Tag.ToString(), User.CurrentStepCode, "", "", User.UserSourceCode, "导出特殊报表", InOutNo, SEQ, "00001");
                     }
-                    dt = (DataTable)dh.ExecuteSql(sql, "select");
+                    dt = (DataTable)dh.ExecuteSql("select stg_field,stg_text,stg_table,stg_formula,stg_type from  SEARCHTEMPLATEgrid where stg_stid='" + st_id + "'", "select");
+                    for (int i = 0; i < dt.Rows.Count; i++)
+                    {
+                        if (dt.Rows[i]["stg_table"].ToString() != "")
+                        {
+                            if (dt.Rows[i]["stg_type"].ToString() == "DATE")
+                            {
+                                SQLField += "to_char(" + dt.Rows[i]["stg_field"].ToString() + ",'YYYYMMDD') as " + dt.Rows[i]["stg_text"].ToString() + ",";
+                            }
+                            else
+                            {
+                                SQLField += dt.Rows[i]["stg_field"].ToString() + " as " + dt.Rows[i]["stg_text"].ToString() + ",";
+                            }
+                        }
+                        else
+                        {
+                            if (dt.Rows[i]["stg_text"].ToString() == "SEQ")
+                            {
+                                SQLField += "'" + SEQ + "'" + " as " + dt.Rows[i]["stg_text"].ToString() + ",";
+                            }
+                            else if (dt.Rows[i]["stg_formula"].ToString().Replace("'", "").Trim() == "")
+                                SQLField += "''" + " as " + dt.Rows[i]["stg_text"].ToString() + ",";
+                            else
+                                SQLField += dt.Rows[i]["stg_formula"].ToString() + " as " + dt.Rows[i]["stg_text"].ToString() + ",";
+                        }
+                    }
+                    SQLField = SQLField.Substring(0, SQLField.Length - 1);
+                    string sql = "select " + SQLField + " from " + st_tablesql;
+                    //单独获取出货单号对流水进行标识
+                    if (st_condition != "")
+                    {
+                        sql += " where " + st_condition;
+                    }
+                    //界面生成的条件
+                    dt = (DataTable)dh.ExecuteSql(sql + AddCondition, "select");
                     //导出Excel的时候返回一个文件名,用户选择是否打开
-                    /*string filePath = */
-                    eh.WriteTxt(dt, FolderPath, "NL" + DateTime.Now.Year.ToString().Substring(2,2) + (DateTime.Now.DayOfYear < 100 ? "0" + DateTime.Now.DayOfYear.ToString() : DateTime.Now.DayOfYear.ToString()) + "COC");
-                    ////用户选择导出之后是否立即打开
-                    //MessageBoxButtons messButton = MessageBoxButtons.YesNo;
-                    //string openFile = MessageBox.Show(this.ParentForm, "是否打开文件", "提示", messButton).ToString();
-                    //if (openFile == "Yes")
-                    //{
-                    //    System.Diagnostics.Process.Start(filePath);
-                    //}
+                    eh.WriteTxt(dt, FolderPath, SEQ);
+                    MessageBox.Show("导出成功");
                 }
             }
         }
+
+        private void Query_SpecialReport_Load(object sender, EventArgs e)
+        {
+            InDate.Checked = false;
+        }
     }
 }