소스 검색

调整核对数据写入

yhluo 1 주 전
부모
커밋
08e25c7b38
1개의 변경된 파일46개의 추가작업 그리고 20개의 파일을 삭제
  1. 46 20
      UAS_Tools_HY/Main.cs

+ 46 - 20
UAS_Tools_HY/Main.cs

@@ -192,38 +192,64 @@ namespace UAS_MES_Tools
                 PlaySound("OK");
                 Datas.FirstDisplayedScrollingRowIndex = Datas.Rows.Count - 1;
 
-                if (ChangeDetail())
-                {
-                    SN.Text = "";
-                    BoxNo.Text = "";
-                    dCount.Text = "0";
-                    Datas.Rows.Clear();
-                    BoxNo.Focus();
-                    BoxNo.SelectAll();
+                try
+                {
+                    int typeNum = ChangeDetail(row);
+                    if (typeNum == 1)
+                    {
+                        SN.Focus();
+                        SN.SelectAll();
+                    }
+                    else if (typeNum == 2)
+                    {
+                        SN.Text = "";
+                        //BoxNo.Text = "";
+                        dCount.Text = "0";
+                        Datas.Rows.Clear();
+                        BoxNo.Focus();
+                        BoxNo.SelectAll();
+                    }
+                }
+                catch (Exception ex)
+                {
+                    MessageBox.Show(ex.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+                    return;
                 }
             }
         }
 
-        private bool ChangeDetail()
+        private int ChangeDetail(DataGridViewRow row)
         {
             int inputSum = Convert.ToInt32(dCount.Text);
             dCount.Text = (inputSum + 1).ToString();
-
-            if(Convert.ToInt32(dCount.Text) == Convert.ToInt32(dSum.Text))
+            int insertCount = ConnectDB.ExecuteInsert($@"INSERT INTO g_packing_sncheck (work_order,part_no,sn,outbox_no,
+                            count,update_time,update_name,check_id,rule_name,rule_value,capacity) 
+                            VALUES ( '', '', '{row.Cells[0].Value}', '{row.Cells[1].Value}',
+                            '{row.Cells[2].Value}',sysdate,'{_UserName}',packcheckid_seq.NEXTVAL,'{dRules.Text.Trim()}','{curRule}','{dSum.Text}' )");
+            if (Convert.ToInt32(dCount.Text) < Convert.ToInt32(dSum.Text))
             {
-                foreach (DataGridViewRow item in Datas.Rows)
-                {
-                    int insertCount = ConnectDB.ExecuteInsert($@"INSERT INTO g_packing_sncheck (work_order,part_no,sn,outbox_no,
-                        count,update_time,update_name,check_id,rule_name,rule_value) 
-                        VALUES ( '', '', '{item.Cells[0].Value}', '{item.Cells[1].Value}',
-                        '{item.Cells[2].Value}',sysdate,'{_UserName}',packcheckid_seq.NEXTVAL,'{dRules.Text.Trim()}','{curRule}' )");
-                }
-                return true;
+                return 1;
             }
             else
             {
-                return false;
+                return 2;
             }
+            
+            //if(Convert.ToInt32(dCount.Text) == Convert.ToInt32(dSum.Text))
+            //{
+            //    foreach (DataGridViewRow item in Datas.Rows)
+            //    {
+            //        int insertCount = ConnectDB.ExecuteInsert($@"INSERT INTO g_packing_sncheck (work_order,part_no,sn,outbox_no,
+            //            count,update_time,update_name,check_id,rule_name,rule_value) 
+            //            VALUES ( '', '', '{item.Cells[0].Value}', '{item.Cells[1].Value}',
+            //            '{item.Cells[2].Value}',sysdate,'{_UserName}',packcheckid_seq.NEXTVAL,'{dRules.Text.Trim()}','{curRule}' )");
+            //    }
+            //    return true;
+            //}
+            //else
+            //{
+            //    return false;
+            //}
         }
 
         private void BoxNo_KeyDown(object sender, KeyEventArgs e)