Browse Source

修改岗位备料取条码的规则

章政 8 years ago
parent
commit
9333dae7b2

+ 77 - 61
UAS-MES/FunctionCode/Make/Make_PositionStock.Designer.cs

@@ -46,6 +46,10 @@
             this.Confirm = new UAS_MES.CustomControl.ButtonUtil.NormalButton();
             this.pr_batchnum = new UAS_MES.CustomControl.TextBoxWithIcon.EnterTextBox();
             this.BatchProductDGV = new UAS_MES.CustomControl.DataGrid_View.DataGridViewWithSerialNum();
+            this.sc_stepcode = new UAS_MES.CustomControl.ValueLabel.ValueLabel();
+            this.pr_detail = new UAS_MES.CustomControl.ValueLabel.ValueLabel();
+            this.ma_prodcode = new UAS_MES.CustomControl.ValueLabel.ValueLabel();
+            this.Screen = new UAS_MES.CustomControl.ButtonUtil.NormalButton();
             this.sp_soncode = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.mss_id = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.mss_prodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
@@ -58,10 +62,7 @@
             this.pr_detail1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pr_spec = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.DeleteRow = new System.Windows.Forms.DataGridViewImageColumn();
-            this.sc_stepcode = new UAS_MES.CustomControl.ValueLabel.ValueLabel();
-            this.pr_detail = new UAS_MES.CustomControl.ValueLabel.ValueLabel();
-            this.ma_prodcode = new UAS_MES.CustomControl.ValueLabel.ValueLabel();
-            this.Screen = new UAS_MES.CustomControl.ButtonUtil.NormalButton();
+            this.ma_bomversion = new System.Windows.Forms.Label();
             this.panel2.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.BatchProductDGV)).BeginInit();
             this.SuspendLayout();
@@ -308,6 +309,65 @@
             this.BatchProductDGV.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.BatchProductDGV_CellEndEdit);
             this.BatchProductDGV.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.BatchProductDGV_CellFormatting);
             // 
+            // sc_stepcode
+            // 
+            this.sc_stepcode.AutoSize = true;
+            this.sc_stepcode.CutLength = null;
+            this.sc_stepcode.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.sc_stepcode.Location = new System.Drawing.Point(917, 52);
+            this.sc_stepcode.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.sc_stepcode.MaximumSize = new System.Drawing.Size(200, 0);
+            this.sc_stepcode.Name = "sc_stepcode";
+            this.sc_stepcode.Size = new System.Drawing.Size(0, 27);
+            this.sc_stepcode.TabIndex = 171;
+            // 
+            // pr_detail
+            // 
+            this.pr_detail.AutoSize = true;
+            this.pr_detail.CutLength = null;
+            this.pr_detail.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.pr_detail.Location = new System.Drawing.Point(553, 102);
+            this.pr_detail.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.pr_detail.MaximumSize = new System.Drawing.Size(200, 0);
+            this.pr_detail.Name = "pr_detail";
+            this.pr_detail.Size = new System.Drawing.Size(0, 27);
+            this.pr_detail.TabIndex = 170;
+            this.pr_detail.Tag = "pr_detail";
+            // 
+            // ma_prodcode
+            // 
+            this.ma_prodcode.AutoSize = true;
+            this.ma_prodcode.CutLength = null;
+            this.ma_prodcode.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.ma_prodcode.Location = new System.Drawing.Point(136, 102);
+            this.ma_prodcode.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.ma_prodcode.MaximumSize = new System.Drawing.Size(200, 0);
+            this.ma_prodcode.Name = "ma_prodcode";
+            this.ma_prodcode.Size = new System.Drawing.Size(0, 27);
+            this.ma_prodcode.TabIndex = 167;
+            this.ma_prodcode.Tag = "ma_prodcode";
+            this.ma_prodcode.TextChanged += new System.EventHandler(this.ma_prodcode_TextChanged);
+            // 
+            // Screen
+            // 
+            this.Screen.AllPower = null;
+            this.Screen.BackColor = System.Drawing.Color.Transparent;
+            this.Screen.DownImage = ((System.Drawing.Image)(resources.GetObject("Screen.DownImage")));
+            this.Screen.Image = ((System.Drawing.Image)(resources.GetObject("Screen.Image")));
+            this.Screen.IsShowBorder = true;
+            this.Screen.Location = new System.Drawing.Point(828, 104);
+            this.Screen.Margin = new System.Windows.Forms.Padding(4);
+            this.Screen.MoveImage = ((System.Drawing.Image)(resources.GetObject("Screen.MoveImage")));
+            this.Screen.Name = "Screen";
+            this.Screen.NormalImage = ((System.Drawing.Image)(resources.GetObject("Screen.NormalImage")));
+            this.Screen.Power = null;
+            this.Screen.Size = new System.Drawing.Size(80, 30);
+            this.Screen.TabIndex = 154;
+            this.Screen.Tag = "IfRead";
+            this.Screen.Text = "刷新";
+            this.Screen.UseVisualStyleBackColor = true;
+            this.Screen.Click += new System.EventHandler(this.Screen_Click);
+            // 
             // sp_soncode
             // 
             this.sp_soncode.DataPropertyName = "sp_soncode";
@@ -320,6 +380,7 @@
             this.mss_id.DataPropertyName = "mss_id";
             this.mss_id.HeaderText = "ID";
             this.mss_id.Name = "mss_id";
+            this.mss_id.Visible = false;
             // 
             // mss_prodcode
             // 
@@ -392,70 +453,24 @@
             this.DeleteRow.Image = global::UAS_MES.Properties.Resources.bindingNavigatorDeleteItem_Image;
             this.DeleteRow.Name = "DeleteRow";
             // 
-            // sc_stepcode
-            // 
-            this.sc_stepcode.AutoSize = true;
-            this.sc_stepcode.CutLength = null;
-            this.sc_stepcode.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.sc_stepcode.Location = new System.Drawing.Point(917, 52);
-            this.sc_stepcode.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
-            this.sc_stepcode.MaximumSize = new System.Drawing.Size(200, 0);
-            this.sc_stepcode.Name = "sc_stepcode";
-            this.sc_stepcode.Size = new System.Drawing.Size(0, 27);
-            this.sc_stepcode.TabIndex = 171;
-            // 
-            // pr_detail
-            // 
-            this.pr_detail.AutoSize = true;
-            this.pr_detail.CutLength = null;
-            this.pr_detail.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.pr_detail.Location = new System.Drawing.Point(553, 102);
-            this.pr_detail.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
-            this.pr_detail.MaximumSize = new System.Drawing.Size(200, 0);
-            this.pr_detail.Name = "pr_detail";
-            this.pr_detail.Size = new System.Drawing.Size(0, 27);
-            this.pr_detail.TabIndex = 170;
-            this.pr_detail.Tag = "pr_detail";
-            // 
-            // ma_prodcode
-            // 
-            this.ma_prodcode.AutoSize = true;
-            this.ma_prodcode.CutLength = null;
-            this.ma_prodcode.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.ma_prodcode.Location = new System.Drawing.Point(136, 102);
-            this.ma_prodcode.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
-            this.ma_prodcode.MaximumSize = new System.Drawing.Size(200, 0);
-            this.ma_prodcode.Name = "ma_prodcode";
-            this.ma_prodcode.Size = new System.Drawing.Size(0, 27);
-            this.ma_prodcode.TabIndex = 167;
-            this.ma_prodcode.Tag = "ma_prodcode";
-            this.ma_prodcode.TextChanged += new System.EventHandler(this.ma_prodcode_TextChanged);
-            // 
-            // Screen
+            // ma_bomversion
             // 
-            this.Screen.AllPower = null;
-            this.Screen.BackColor = System.Drawing.Color.Transparent;
-            this.Screen.DownImage = ((System.Drawing.Image)(resources.GetObject("Screen.DownImage")));
-            this.Screen.Image = ((System.Drawing.Image)(resources.GetObject("Screen.Image")));
-            this.Screen.IsShowBorder = true;
-            this.Screen.Location = new System.Drawing.Point(828, 104);
-            this.Screen.Margin = new System.Windows.Forms.Padding(4);
-            this.Screen.MoveImage = ((System.Drawing.Image)(resources.GetObject("Screen.MoveImage")));
-            this.Screen.Name = "Screen";
-            this.Screen.NormalImage = ((System.Drawing.Image)(resources.GetObject("Screen.NormalImage")));
-            this.Screen.Power = null;
-            this.Screen.Size = new System.Drawing.Size(80, 30);
-            this.Screen.TabIndex = 154;
-            this.Screen.Tag = "IfRead";
-            this.Screen.Text = "刷新";
-            this.Screen.UseVisualStyleBackColor = true;
-            this.Screen.Click += new System.EventHandler(this.Screen_Click);
+            this.ma_bomversion.AutoSize = true;
+            this.ma_bomversion.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.ma_bomversion.Location = new System.Drawing.Point(1049, 54);
+            this.ma_bomversion.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.ma_bomversion.Name = "ma_bomversion";
+            this.ma_bomversion.Size = new System.Drawing.Size(165, 27);
+            this.ma_bomversion.TabIndex = 186;
+            this.ma_bomversion.Text = "ma_bomversion";
+            this.ma_bomversion.Visible = false;
             // 
             // Make_PositionStock
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1229, 675);
+            this.Controls.Add(this.ma_bomversion);
             this.Controls.Add(this.ma_craftcode);
             this.Controls.Add(this.ma_craftcode_label);
             this.Controls.Add(this.Lock);
@@ -526,5 +541,6 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn pr_detail1;
         private System.Windows.Forms.DataGridViewTextBoxColumn pr_spec;
         private System.Windows.Forms.DataGridViewImageColumn DeleteRow;
+        private System.Windows.Forms.Label ma_bomversion;
     }
 }

+ 54 - 18
UAS-MES/FunctionCode/Make/Make_PositionStock.cs

@@ -78,34 +78,51 @@ namespace UAS_MES.Make
                         dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
                         if (dt.Rows.Count > 0)
                         {
+                            //输入的是条码号的时候
                             dt = (DataTable)dh.ExecuteSql("select bar_remain,bar_prodcode from barcode inner join product on pr_code=bar_prodcode where bar_code ='" + pr_batchnum.Text + "'", "select");
                             if (dt.Rows.Count > 0)
                             {
                                 string bar_remain = dt.Rows[0]["bar_remain"].ToString();
                                 string bar_prodcode = dt.Rows[0]["bar_prodcode"].ToString();
                                 sql.Clear();
-                                sql.Append("select * from stepproduct inner join product on pr_code=sp_soncode left join makematerial on mm_prodcode=sp_soncode where ");
-                                sql.Append("sp_craftcode='" + ma_craftcode.Text + "' and sp_stepcode='" + User.CurrentStepCode + "' and sp_soncode='" + bar_prodcode + "' and sp_tracekind=2 ");
+                                sql.Append("select sp_id,sp_oneuseqty,sp_soncode,sp_prefix from stepbom left join stepproduct on sp_sbid=sb_id ");
+                                sql.Append("where sb_craftcode='" + ma_craftcode.Text + "' and  sb_prodcode='" + ma_prodcode.Text + "' and ");
+                                sql.Append("sb_bomversion='" + ma_bomversion.Text + "'  and sp_stepcode='" + User.CurrentStepCode + "' and sp_soncode ='" + bar_prodcode + "' and sp_tracekind=2 ");
                                 dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
                                 if (dt.Rows.Count > 0)
                                 {
-                                    string mm_oneuseqty = dt.Rows[0]["mm_oneuseqty"].ToString();
-                                    string mm_prodcode = dt.Rows[0]["mm_prodcode"].ToString();
-                                    sql.Clear();
-                                    sql.Append("insert into makesourcestock (mss_id,mss_makecode,mss_linecode ,mss_craftcode,");
-                                    sql.Append("mss_stepcode,mss_barcode,mss_fprodcode,mss_indate,mss_inman,mss_qty,");
-                                    sql.Append("mss_remain,mss_baseqty,mss_prodcode,mss_maid) values(makesourcestock_seq.nextval,'" + ma_code.Text + "','" + User.UserLineCode + "',");
-                                    sql.Append("'" + ma_craftcode.Text + "','" + sc_stepcode.Text + "','" + pr_batchnum.Text + "','" + mm_prodcode + "',");
-                                    sql.Append("sysdate,'" + User.UserCode + "','" + bar_remain + "','" + bar_remain + "','" + mm_oneuseqty + "','" + bar_prodcode + "','" + ma_id + "')");
-                                    dh.ExecuteSql(sql.GetString(), "insert");
-                                    dh.UpdateByCondition("barcode", "bar_place='" + ma_code.Text + "'", "bar_code='" + pr_batchnum.Text + "'");
-                                    //数据插入成功后加载Grid的数据
-                                    FillDataGridView();
-                                    OperateResult.AppendText(">>条码号" + pr_batchnum.Text + "备料成功\n", Color.Green, pr_batchnum);
+                                    InsertMakeSourceStock(dt);
                                 }
                                 else OperateResult.AppendText(">>条码号" + pr_batchnum.Text + "对应的物料不是当前工单当前工序需要备的物料\n", Color.Red, pr_batchnum);
                             }
-                            else OperateResult.AppendText(">>条码号:" + pr_batchnum.Text + "不存在,或者状态无效\n", Color.Red, pr_batchnum);
+                            else
+                            {
+                                sql.Clear();
+                                sql.Append("select sp_id,sp_oneuseqty,sp_soncode,sp_prefix from stepbom left join stepproduct on sp_sbid=sb_id ");
+                                sql.Append("where sb_craftcode='" + ma_craftcode.Text + "' and  sb_prodcode='" + ma_prodcode.Text + "' and ");
+                                sql.Append("sb_bomversion='" + ma_bomversion.Text + "'  and sp_stepcode='" + User.CurrentStepCode + "' and sp_tracekind=2 ");
+                                sql.Append("and instr('" + pr_batchnum.Text + "',SP_SONCODE) > 0");
+                                dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
+                                if (dt.Rows.Count > 0)
+                                {
+                                    InsertMakeSourceStock(dt);
+                                }
+                                else
+                                {
+                                    sql.Clear();
+                                    sql.Append("select sp_id,sp_oneuseqty,sp_soncode,sp_prefix from stepbom left join stepproduct on sp_sbid=sb_id ");
+                                    sql.Append("where sb_craftcode='" + ma_craftcode.Text + "' and  sb_prodcode='" + ma_prodcode.Text + "' and ");
+                                    sql.Append("sb_bomversion='" + ma_bomversion.Text + "'  and sp_stepcode='" + User.CurrentStepCode + "' and sp_tracekind=2 ");
+                                    sql.Append("and instr('" + pr_batchnum.Text + "',sp_prefix) > 1 and ((nvl(SP_LENGTH,0)>0 and sp_length ");
+                                    sql.Append("= length('" + pr_batchnum.Text + "')) or nvl(SP_LENGTH,0)=0)");
+                                    dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
+                                    if (dt.Rows.Count > 0)
+                                    {
+                                        InsertMakeSourceStock(dt);
+                                    }
+                                    else  OperateResult.AppendText(">>条码号" + pr_batchnum.Text + "对应的物料不是当前工单当前工序需要备的物料\n", Color.Red, pr_batchnum);
+                                }
+                            }
                         }
                         else OperateResult.AppendText(">>当前岗位资源工序不在工单对应的途程中\n", Color.Red);
                     }
@@ -115,6 +132,24 @@ namespace UAS_MES.Make
             }
         }
 
+        private void InsertMakeSourceStock(DataTable dt)
+        {
+            string sp_oneuseqty = dt.Rows[0]["sp_oneuseqty"].ToString();
+            string sp_soncode = dt.Rows[0]["sp_soncode"].ToString();
+            string sp_prefix = dt.Rows[0]["sp_prefix"].ToString();
+            sql.Clear();
+            sql.Append("insert into makesourcestock (mss_id,mss_makecode,mss_linecode ,mss_craftcode,");
+            sql.Append("mss_stepcode,mss_barcode,mss_fprodcode,mss_indate,mss_inman,mss_qty,");
+            sql.Append("mss_remain,mss_baseqty,mss_prodcode,mss_maid) values(makesourcestock_seq.nextval,'" + ma_code.Text + "','" + User.UserLineCode + "',");
+            sql.Append("'" + ma_craftcode.Text + "','" + sc_stepcode.Text + "','" + pr_batchnum.Text + "','" + sp_soncode + "',");
+            sql.Append("sysdate,'" + User.UserCode + "','0','0','" + sp_oneuseqty + "','" + sp_soncode + "','" + ma_id + "')");
+            dh.ExecuteSql(sql.GetString(), "insert");
+            dh.UpdateByCondition("barcode", "bar_place='" + ma_code.Text + "'", "bar_code='" + pr_batchnum.Text + "'");
+            //数据插入成功后加载Grid的数据
+            FillDataGridView();
+            OperateResult.AppendText(">>条码号" + pr_batchnum.Text + "备料成功\n", Color.Green, pr_batchnum);
+        }
+
         //加载Grid数据
         private void FillDataGridView()
         {
@@ -142,7 +177,7 @@ namespace UAS_MES.Make
         {
             if (ma_code.Text != "")
             {
-                dt = (DataTable)dh.ExecuteSql("select ma_id,ma_craftcode,ma_statuscode,ma_code,ma_prodcode,pr_spec,pr_detail from make left join product on ma_prodcode=pr_code where ma_code='" + ma_code.Text + "'", "select");
+                dt = (DataTable)dh.ExecuteSql("select ma_id,ma_craftcode,ma_statuscode,ma_code,ma_prodcode,pr_spec,pr_detail,ma_bomversion from make left join product on ma_prodcode=pr_code where ma_code='" + ma_code.Text + "'", "select");
                 if (dt.Rows.Count > 0)
                 {
                     ma_id = dt.Rows[0]["ma_id"].ToString();
@@ -235,7 +270,8 @@ namespace UAS_MES.Make
 
         private void BatchProductDGV_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
         {
-            if (BatchProductDGV.Columns[e.ColumnIndex].Name == "DeleteRow") {
+            if (BatchProductDGV.Columns[e.ColumnIndex].Name == "DeleteRow")
+            {
                 if (BatchProductDGV.Rows[e.RowIndex].Cells["mss_id"].Value.ToString() == "0")
                     e.Value = Properties.Resources.WhiteImage;
                 else

+ 36 - 0
UAS-MES/FunctionCode/Make/Make_PositionStock.resx

@@ -547,4 +547,40 @@
         ROJSU3qXjMKwG/vjzEz/skOI3Zqgv7AAAAAASUVORK5CYII=
 </value>
   </data>
+  <metadata name="sp_soncode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="mss_id.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="mss_prodcode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="mss_barcode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="sp_oneuseqty.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="mss_qty.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="mm_qty.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="mss_remain.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="mss_useqty.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="pr_detail1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="pr_spec.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="DeleteRow.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
 </root>