From 7a5552edd1e2bf2bfd55e60808a1ae103e1e34fa Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期四, 03 十一月 2022 09:34:16 +0800
Subject: [PATCH] 叫料功能维护

---
 BaseSet/公用资料/其他基础资料/Gy_StdWorkTimes.cs |  257 ++++++++++++++++++++++++++++-----------------------
 1 files changed, 141 insertions(+), 116 deletions(-)

diff --git "a/BaseSet/\345\205\254\347\224\250\350\265\204\346\226\231/\345\205\266\344\273\226\345\237\272\347\241\200\350\265\204\346\226\231/Gy_StdWorkTimes.cs" "b/BaseSet/\345\205\254\347\224\250\350\265\204\346\226\231/\345\205\266\344\273\226\345\237\272\347\241\200\350\265\204\346\226\231/Gy_StdWorkTimes.cs"
index e3a5aae..757f566 100644
--- "a/BaseSet/\345\205\254\347\224\250\350\265\204\346\226\231/\345\205\266\344\273\226\345\237\272\347\241\200\350\265\204\346\226\231/Gy_StdWorkTimes.cs"
+++ "b/BaseSet/\345\205\254\347\224\250\350\265\204\346\226\231/\345\205\266\344\273\226\345\237\272\347\241\200\350\265\204\346\226\231/Gy_StdWorkTimes.cs"
@@ -8,7 +8,7 @@
 using System.Text;
 using System.Windows.Forms;
 
-namespace BaseSet.鍏敤璧勬枡.鍏朵粬鍩虹璧勬枡
+namespace BaseSet
 {
     public partial class Gy_StdWorkTimes : Form
     {
@@ -32,6 +32,8 @@
         public const Int16 HLowerlimit = 11;
         public const Int16 HUSEORGID = 12;
         public const Int16 HRemarkCol = 13;
+        public const Int16 HStdPiece = 14;
+        public const Int16 HStdPric = 15;
         public bool BillChange;   //
         public DBUtility.ClsPub.Enum_OKTag OkTag;
         public DBUtility.ClsPub.Enum_BillStatus BillStatus;
@@ -46,8 +48,9 @@
         public DAL.ClsGy_StdWorkTimes_Ctl BillNew = new DAL.ClsGy_StdWorkTimes_Ctl();
         public Model.ClsGy_StdWorkTimes_Model BillOld = new Model.ClsGy_StdWorkTimes_Model();
         ClsGridViewSum oSumGrid = new ClsGridViewSum();
+        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
 
-        
+
         #region 鍥哄畾浠g爜
         //鍚堣
         private void Total()
@@ -187,7 +190,10 @@
             oSumGrid.ogrdMain = grdMain1;
             oSumGrid.oGridsum = grdSum;
             lblCaption.Text = ModName;
+            textBox1.Hide();
+            textBox2.Hide();
             this.Text = ModName;
+           
         }
 
 
@@ -236,7 +242,59 @@
         //淇敼鎸夌航
         private void xg_Click(object sender, EventArgs e)
         {
-            this.Sub_EditBill();
+            try
+            {
+                if (Convert.ToDecimal(txtHStdWorkTimes.Text.ToString())<=0)
+                {
+                    MessageBox.Show("鏍囧噯宸ユ椂蹇呴』澶т簬0", "鎻愮ず");
+                    return;
+                }
+                if (Convert.ToDecimal(txtHUpperlimit.Text) <= 0)
+                {
+                    MessageBox.Show("涓婇檺姣斾緥蹇呴』澶т簬0", "鎻愮ず");
+                    return;
+                }
+                if (Convert.ToDecimal(txtHLowerlimit.Text) <= 0)
+                {
+                    MessageBox.Show("涓嬬嚎姣斾緥蹇呴』澶т簬0", "鎻愮ず");
+                    return;
+                }
+                if (Convert.ToDecimal(txtHStdPiece.Text) <= 0)
+                {
+                    MessageBox.Show("鏍囧噯璁′欢蹇呴』澶т簬0", "鎻愮ず");
+                    return;
+                }
+                if (Convert.ToDecimal(txtHStdPric.Text) <= 0)
+                {
+                    MessageBox.Show("鏍囧噯璁′环蹇呴』澶т簬0", "鎻愮ず");
+                    return;
+                }
+                string sql = string.Format(@"Update Gy_StdWorkTimes set" +
+                            " HMaterID=" + textBox1.Text +
+                            ",HProcID=" + textBox2.Text +
+                            ",HStdWorkTimes=" + txtHStdWorkTimes.Text +
+                            ",HUpperlimit=" + txtHUpperlimit.Text +
+                            ",HLowerlimit=" + txtHLowerlimit.Text +
+                            ",HStdPiece=" + txtHStdPiece.Text +
+                            ",HStdPric=" + txtHStdPric.Text +
+                            ",HMaker='" + DBUtility.ClsPub.CurUserName + "'" +
+                            ",HMakeDate='" + DateTime.Now + "'" +
+                            ",HUSEORGID=" + DBUtility.ClsPub.HOrgID +
+                             " where HItemID=" + BillOld.HItemID);
+                oCn.BeginTran();
+                oCn.RunProc(sql);
+                oCn.Commit();
+                MessageBox.Show("淇敼鎴愬姛,璇烽��鍑哄苟鍒锋柊", "鎻愮ず");
+            }
+            catch (Exception)
+            {
+                oCn.RollBack();
+                MessageBox.Show("淇敼澶辫触", "鎻愮ず");
+                throw;
+            }
+            
+
+            
         }
         //鍒犻櫎鎸夐挳
         private void sc_Click(object sender, EventArgs e)
@@ -293,7 +351,7 @@
         {
             timer1.Enabled = false;
             Sub_ControlLocation();
-            if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_View)//|| BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_Viewonly
+            if (BillOld.HItemID.ToString()!=null&& BillOld.HItemID.ToString() !="0")//|| BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_Viewonly
             {
                 this.Sub_ShowBill();
             }
@@ -324,37 +382,27 @@
         {
             switch (BillStatus)
             {
-                case DBUtility.ClsPub.Enum_BillStatus.BillStatus_View:
-                    //case DBUtility.ClsPub.Enum_BillStatus.BillStatus_Viewonly:
-                    //娴忚鐘舵��
-                    yl.Enabled = true;
-                    xz.Enabled = true;
+                case 0:
                     xg.Enabled = true;
-                    sc.Enabled = true;
                     AddRow.Enabled = false;
                     DelRow.Enabled = false;
                     bc.Enabled = false;
                     tc.Enabled = true;
-                    //鏈鏍�
-                    if (txtHChecker.Text.Trim() == "")
-                    {
-                        xg.Enabled = true;
-                        sc.Enabled = true;
-                    }
-                    else
-                    {
-                        xg.Enabled = false;
-                        sc.Enabled = false;
-                    }
+                    Sub_LrtextStatus(true);
+                    grdStatus = true;
+                    break;
+                case DBUtility.ClsPub.Enum_BillStatus.BillStatus_View:
+                    xg.Enabled = true;
+                    AddRow.Enabled = false;
+                    DelRow.Enabled = false;
+                    bc.Enabled = false;
+                    tc.Enabled = true;
                     Sub_LrtextStatus(false);
                     grdStatus = false;
                     break;
                 case DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew:
                     //鏂板鐘舵��
-                    yl.Enabled = false;
-                    xz.Enabled = false;
                     xg.Enabled = false;
-                    sc.Enabled = false;
                     AddRow.Enabled = true;
                     DelRow.Enabled = true;
                     bc.Enabled = true;
@@ -364,10 +412,7 @@
                     break;
                 case DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify:
                     //淇敼鐘舵��
-                    yl.Enabled = false;
-                    xz.Enabled = false;
                     xg.Enabled = false;
-                    sc.Enabled = false;
                     AddRow.Enabled = true;
                     DelRow.Enabled = true;
                     bc.Enabled = true;
@@ -375,6 +420,7 @@
                     Sub_LrtextStatus(true);
                     grdStatus = true;
                     break;
+
             }
 
         }
@@ -387,60 +433,27 @@
             DAL.ClsIF_Material_View oMater = new DAL.ClsIF_Material_View();
             DAL.ClsIF_Process_View oProc = new DAL.ClsIF_Process_View();
             //鍒ゆ柇鏄惁瀛樺湪鍗曟嵁
-            if (BillNew.ShowBill(BillOld.HItemID, ref ClsPub.sExeReturnInfo) == false)
-            {
-                MessageBox.Show(ClsPub.sExeReturnInfo, "鎻愮ず");
-                return;
-            }
+            DataSet DsSub = oCn.RunProcReturn("Select * from h_v_Gy_StdWorkTimesListNew Where HitemID=" + BillOld.HItemID.ToString(), "Gy_StdWorkTimes");
+            DataRow dr = DsSub.Tables[0].Rows[0];
+            
             //娓呯┖
             Sub_ClearBill();
-            
-            //
-            this.txtHMaker.Text = BillOld.HMaker;
-            this.txtHMakeDate.Text = BillOld.HMakeDate;
-            this.txtHChecker.Text = BillOld.HChecker;
 
-            //鍔犺浇琛ㄤ綋
-            initGrid();
-            int i = 0;
-            foreach (Model.ClsGy_StdWorkTimes_Model oSub in BillNew.DetailColl)
-            {
-                //
-                if (i >= grdMain1.RowCount - 1)
-                    grdMain1.Rows.Add();
-                grdMain1.Rows[i].Cells[HTagCol].Value = "*";
-                grdMain1.Rows[i].Cells[HMaterIDCol].Value = oSub.HMaterID.ToString();
-                if (oMater.GetInfoByID(oSub.HMaterID))
-                {
-                    grdMain1.Rows[i].Cells[HMaterNumberCol].Value = oMater.omodel.HNumber;
-                    grdMain1.Rows[i].Cells[HMaterNameCol].Value = oMater.omodel.HName;
-                    grdMain1.Rows[i].Cells[HMaterModelCol].Value = oMater.omodel.HModel;
-                }
-                else
-                {
-                    grdMain1.Rows[i].Cells[HMaterNumberCol].Value = "";
-                    grdMain1.Rows[i].Cells[HMaterNameCol].Value = "";
-                    grdMain1.Rows[i].Cells[HMaterModelCol].Value = "";
-                }
-                grdMain1.Rows[i].Cells[HProcIDCol].Value = oSub.HProcID.ToString();
-                if (oProc.GetInfoByID(oSub.HProcID))
-                {
-                    grdMain1.Rows[i].Cells[HProcNumberCol].Value = oProc.omodel.HNumber;
-                    grdMain1.Rows[i].Cells[HProcNameCol].Value = oProc.omodel.HName;
-                }
-                else
-                {
-                    grdMain1.Rows[i].Cells[HProcNumberCol].Value = "";
-                    grdMain1.Rows[i].Cells[HProcNameCol].Value = "";
-                }
-                
-                grdMain1.Rows[i].Cells[HStdWorkTimes].Value = oSub.HStdWorkTimes.ToString();
-                grdMain1.Rows[i].Cells[HUpperlimit].Value = oSub.HUpperlimit.ToString();
-                grdMain1.Rows[i].Cells[HLowerlimit].Value = oSub.HLowerlimit.ToString();
-                grdMain1.Rows[i].Cells[HUSEORGID].Value = oSub.HUSEORGID.ToString();
-                grdMain1.Rows[i].Cells[HRemarkCol].Value = oSub.HRemark;
-                i = i + 1;
-            }
+            //
+            this.textBox1.Text = dr["HMaterID"].ToString();
+            this.txtHMaterID.Text = dr["鐗╂枡浠g爜"].ToString();
+            this.txtHMaterName.Text = dr["鐗╂枡鍚嶇О"].ToString();
+            this.txtHMaterModel.Text = dr["瑙勬牸鍨嬪彿"].ToString();
+            this.textBox2.Text = dr["HProcID"].ToString();
+            this.txtHProcID.Text = dr["宸ュ簭浠g爜"].ToString();
+            this.txtHProcName.Text = dr["宸ュ簭鍚嶇О"].ToString();
+            this.txtHStdWorkTimes.Text = dr["鏍囧噯宸ユ椂"].ToString();
+            this.txtHUpperlimit.Text = dr["涓婄嚎姣斾緥"].ToString();
+            this.txtHLowerlimit.Text = dr["涓嬬嚎姣斾緥"].ToString();
+            this.txtHStdPiece.Text = dr["鏍囧噯璁′欢"].ToString();
+            this.txtHStdPric.Text = dr["鏍囧噯璁′环"].ToString();
+
+            
             //GRID鍏佽鍒锋柊
             DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
             //鍚堣
@@ -453,16 +466,6 @@
         //鍗曟嵁瀹屾暣鎬у垽鏂�          鏈畬鎴�
         private bool Sub_AllowSave()
         {
-            //蹇呰緭椤圭洰鏄惁涓虹┖
-            //ClsK3_DepartmentHlp oDept = new ClsK3_DepartmentHlp();
-            //if(!oDept.GetInfoByID(ClsPub.isLong(txtHDeptID.Tag)))
-            //{
-            //    MessageBox.Show("閮ㄩ棬涓嶅瓨鍦紒");
-            //    return false;
-            //}
-
-            //鏄庣粏琛ㄦ槸鍚︿负闆惰
-            bool b = false;
             if (!IsNullRow(0))
             {
                 MessageBox.Show("琛ㄤ綋鏄庣粏琛屼笉瀛樺湪锛佽褰曞叆锛�", "鎻愮ず");
@@ -470,8 +473,18 @@
             }
             else
             {
+
                 return true;
             }
+        }
+        //鏄惁鏄┖琛�
+        private bool IsNullRow(int Row)
+        {
+            if (ClsPub.isInt(grdMain1.Rows[Row].Cells[HMaterIDCol].Value) == 0&& ClsPub.isInt(grdMain1.Rows[Row].Cells[HProcIDCol].Value) == 0&& ClsPub.isDoule( grdMain1.Rows[Row].Cells[HStdWorkTimes].Value )== 0&& ClsPub.isDoule(grdMain1.Rows[Row].Cells[HUpperlimit].Value) == 0&& ClsPub.isDoule(grdMain1.Rows[Row].Cells[HLowerlimit].Value) == 0&& ClsPub.isStrNull(grdMain1.Rows[Row].Cells[HRemarkCol].Value) == ""&& ClsPub.isDoule(grdMain1.Rows[Row].Cells[HStdPiece].Value) == 0&& ClsPub.isDoule(grdMain1.Rows[Row].Cells[HStdPiece].Value) == 0)
+            {
+                return true;
+            }
+            return false;
         }
         //淇濆瓨鍗曟嵁
         private bool Sub_SaveBill()
@@ -480,35 +493,51 @@
             Int32 i;
             bool bResult;
             BillNew = new DAL.ClsGy_StdWorkTimes_Ctl();
-            //缂栬緫鏉冮檺
-            //if (!ClsPub.Security_Log(ModRightNameEdit, 1, true, DBUtility.ClsPub.CurUserName))
-            //{
-            //    return false;
-            //}
+            
             //澶卞幓鐒︾偣
             lblCaption.Focus();
             //
             if (!Sub_AllowSave())//鍗曟嵁瀹屾暣鎬у垽鏂�
-                return false;
+            { return false; }
+
             //
             //鏄庣粏绫昏祴鍊�
             BillNew.DetailColl = new List<Model.ClsGy_StdWorkTimes_Model>();
             for (i = 0; i <= grdMain1.RowCount - 1; i++)
             {
-                if (DBUtility.ClsPub.isLong(grdMain1.Rows[i].Cells[HMaterIDCol].Value) != 0 && DBUtility.ClsPub.isLong(grdMain1.Rows[i].Cells[HProcIDCol].Value) != 0)
+                if (IsNullRow(i))
                 {
-                    Model.ClsGy_StdWorkTimes_Model oSub = new Model.ClsGy_StdWorkTimes_Model();
-                    oSub.HMaterID = ClsPub.isLong(grdMain1.Rows[i].Cells[HMaterIDCol].Value);
-                    oSub.HProcID = ClsPub.isLong(grdMain1.Rows[i].Cells[HProcIDCol].Value);
-                    oSub.HStdWorkTimes = ClsPub.isDoule(grdMain1.Rows[i].Cells[HStdWorkTimes].Value);
-                    oSub.HUpperlimit = ClsPub.isDoule(grdMain1.Rows[i].Cells[HUpperlimit].Value);
-                    oSub.HLowerlimit = ClsPub.isDoule(grdMain1.Rows[i].Cells[HLowerlimit].Value);
-                    oSub.HUSEORGID = ClsPub.HOrgID;
-                    oSub.HStopflag = false;
-                    oSub.HMaker = ClsPub.CurUserName;
-                    oSub.HMakeDate = DateTime.Today.ToString();
-                    oSub.HRemark = ClsPub.isStrNull(grdMain1.Rows[i].Cells[HRemarkCol].Value);
-                    BillNew.DetailColl.Add(oSub);
+                    break;
+                }
+                if (DBUtility.ClsPub.isStrNull(grdMain1.Rows[i].Cells[HMaterIDCol].Value) != "" && DBUtility.ClsPub.isStrNull(grdMain1.Rows[i].Cells[HProcIDCol].Value) != "" && DBUtility.ClsPub.isStrNull(grdMain1.Rows[i].Cells[HStdWorkTimes].Value) != "")
+                {
+                    if (DBUtility.ClsPub.isDoule(grdMain1.Rows[i].Cells[HStdWorkTimes].Value) > 0 && DBUtility.ClsPub.isDoule(grdMain1.Rows[i].Cells[HUpperlimit].Value) > 0 && DBUtility.ClsPub.isDoule(grdMain1.Rows[i].Cells[HLowerlimit].Value) > 0 && DBUtility.ClsPub.isDoule(grdMain1.Rows[i].Cells[HStdPiece].Value) > 0 && DBUtility.ClsPub.isDoule(grdMain1.Rows[i].Cells[HStdPric].Value) > 0)
+                    {
+                        Model.ClsGy_StdWorkTimes_Model oSub = new Model.ClsGy_StdWorkTimes_Model();
+                        oSub.HMaterID = ClsPub.isLong(grdMain1.Rows[i].Cells[HMaterIDCol].Value);
+                        oSub.HProcID = ClsPub.isLong(grdMain1.Rows[i].Cells[HProcIDCol].Value);
+                        oSub.HStdWorkTimes = ClsPub.isDoule(grdMain1.Rows[i].Cells[HStdWorkTimes].Value);
+                        oSub.HUpperlimit = ClsPub.isDoule(grdMain1.Rows[i].Cells[HUpperlimit].Value);
+                        oSub.HLowerlimit = ClsPub.isDoule(grdMain1.Rows[i].Cells[HLowerlimit].Value);
+                        oSub.HStdPiece = ClsPub.isDoule(grdMain1.Rows[i].Cells[HStdPiece].Value);
+                        oSub.HStdPric = ClsPub.isDoule(grdMain1.Rows[i].Cells[HStdPric].Value);
+                        oSub.HUSEORGID = ClsPub.HOrgID;
+                        oSub.HStopflag = false;
+                        oSub.HMaker = ClsPub.CurUserName;
+                        oSub.HMakeDate = DateTime.Today.ToString();
+                        oSub.HRemark = ClsPub.isStrNull(grdMain1.Rows[i].Cells[HRemarkCol].Value);
+                        BillNew.DetailColl.Add(oSub);
+                    }
+                    else
+                    {
+                        MessageBox.Show("绗�" + (i + 1) + "琛�,鏍囧噯宸ユ椂,涓婇檺姣斾緥,涓嬮檺姣斾緥锛屾爣鍑嗚浠跺拰鏍囧噯璁′环閮藉簲澶т簬0", "鎻愮ず");
+                        return false;
+                    }
+                }
+                else
+                {
+                    MessageBox.Show("绗�" + (i + 1) + "琛�,鐗╂枡銆佸伐搴忓拰鏍囧噯宸ユ椂涓嶈兘涓虹┖", "鎻愮ず");
+                    return false;
                 }
             }
             //淇濆瓨瀹屾瘯鍚庡鐞�
@@ -577,6 +606,9 @@
             grdMain1.Columns[HStdWorkTimes].HeaderText = "鏍囧噯宸ユ椂";
             grdMain1.Columns[HUpperlimit].HeaderText = "涓婇檺姣斾緥";
             grdMain1.Columns[HLowerlimit].HeaderText = "涓嬮檺姣斾緥";
+            grdMain1.Columns[HStdPiece].HeaderText = "鏍囧噯璁′欢";
+            grdMain1.Columns[HStdPric].HeaderText = "鏍囧噯璁′环";
+
             grdMain1.Columns[HUSEORGID].HeaderText = "缁勭粐ID";
             grdMain1.Columns[HRemarkCol].HeaderText = "澶囨敞";
             //
@@ -591,6 +623,8 @@
                             "," + HStdWorkTimes.ToString() +
                             "," + HUpperlimit.ToString() +
                             "," + HLowerlimit.ToString() +
+                            "," + HStdPiece.ToString() +
+                            "," + HStdPric.ToString() +
                             "," + HRemarkCol.ToString();
             //鍚堣鍒�
             string sTotalCol = "";
@@ -655,15 +689,6 @@
             //  
             oSumGrid.EditStatus = false;
             return true;
-        }
-        //鏄惁鏄┖琛�
-        private bool IsNullRow(int Row)
-        {
-            if (ClsPub.isInt(grdMain1.Rows[Row].Cells[HMaterIDCol].Value) == 0)
-            {
-                return true;
-            }
-            return false;
         }
         //'鍒ゆ柇缃戞牸琛岀殑褰曞叆鏄惁姝g‘
         private bool CheckGridRow(int Row)

--
Gitblit v1.9.1