From d10a74e02677c04fe72dc5223c9ceecf542d55c2 Mon Sep 17 00:00:00 2001
From: zzr99 <1940172413@qq.com>
Date: 星期四, 21 四月 2022 16:01:48 +0800
Subject: [PATCH] 标准工时导入

---
 PlanM/数据导入/Gy_StdWorkTimes_RoutingBill.cs |  286 ++++++++++++++++-----------------------------------------
 1 files changed, 81 insertions(+), 205 deletions(-)

diff --git "a/PlanM/\346\225\260\346\215\256\345\257\274\345\205\245/Gy_StdWorkTimes_RoutingBill.cs" "b/PlanM/\346\225\260\346\215\256\345\257\274\345\205\245/Gy_StdWorkTimes_RoutingBill.cs"
index 34ac451..0f8ee76 100644
--- "a/PlanM/\346\225\260\346\215\256\345\257\274\345\205\245/Gy_StdWorkTimes_RoutingBill.cs"
+++ "b/PlanM/\346\225\260\346\215\256\345\257\274\345\205\245/Gy_StdWorkTimes_RoutingBill.cs"
@@ -31,48 +31,23 @@
         public int HStdWorkTimes = 0;    //标准工时
         public int HUpperlimit = 0;  //上限比例
         public int HLowerlimit = 0;	//下限比例
-
-        //public int HMaterNumberCol = 0;             //产品代码
-        //public int HWorkTypeNameCol = 0;           //工种
-        //public int HProcNameCol = 0;           //工序
-        //public int HWorkCenterNameCol = 0;        //工作中心
-        //public int HProcMulNameCol = 0;           //工段
-        //public int HWorkCenterName_SCol = 0;           //产线
-        //public int HWorkQtyCol = 0;          //产能
-        //public int HSubStdEmpQtyCol = 0;          //人数
-        //public int HWorkQty_SCol = 0;          //产线产能
-        //public int HSubStdEmpQty_SCol = 0;          //产线人数
-
-        //public int HMouldNoCol = 0;          //模具编号
-        //public int HChangeMouldCol = 0;          //换模时间
-        //public int HPackStdCol = 0;          //周转箱标准
-        //public int HPackCol = 0;          //周转箱
-        //public int HPutAreaCol = 0;          //暂放区
-        ////
-        //public int HMyWorkDaysCol = 0;          //生产周期
-        //public int HMyFixWorkDaysCol = 0;          //固定生产天数
-
-        //public int HBeginDayQtyCol = 6;     //开工固天
-        //public int HBeginFixQtyCol = 7;     //开工余量 
-        //public int HFixPriceCol = 8;        //定额 小时工资
-        //public int HProcPriceCol = 9;       //工价
-        //public int HProcTypeCol = 0;          //工序类型
         //
         public const int HBeginRow = 2;         //有效数据,开始行数
+
+
         // 
-        //DAL.ClsGy_RoutingBill;
         public DAL.ClsGy_Process_View oProcHlp = new DAL.ClsGy_Process_View();
         public DAL.ClsGy_StdWorkTimes_Ctl BillNew = new DAL.ClsGy_StdWorkTimes_Ctl();
         DAL.ClsIF_Material_View oMaterHlp = new DAL.ClsIF_Material_View();
-        //DAL.ClsGy_WorkType_View oWorkType = new DAL.ClsGy_WorkType_View();
-        long j = -1;
-        int c = 0;
+
+       
 
         public override bool OpenExcelData()
         {
             base.sSheetName = txtHSheetName.Text;
             return base.OpenExcelData();
-        } 
+        }
+
 
         /// <summary>
         ///  初始化界面
@@ -80,7 +55,7 @@
         public override void initData()
         {
             base.initData();
-            base.sSheetName = txtHSheetName.Text ; 
+            base.sSheetName = "标准工时";
             base.ModRightName = "Gy_StdWorkTimes_RoutingBill";
             base.ModRightNameCheck = base.ModRightName + base.ModRightNameCheck;
             base.ModRightNameClose = base.ModRightName + base.ModRightNameClose;
@@ -88,7 +63,7 @@
             base.ModRightNameEdit = base.ModRightName + base.ModRightNameEdit;
             base.ModRightNameMoney = base.ModRightName + base.ModRightNameMoney;
             base.ModRightNameQty = base.ModRightName + base.ModRightNameQty;
-            base.ModCaption = "标准工时导入";
+            base.ModCaption = "标准工时";
             this.Text = base.ModCaption;
             lblCaption.Text = base.ModCaption;
             //
@@ -96,79 +71,23 @@
             DBUtility.Gy_BaseFun.SetComboxPeriod(cmbHPeriod);
             //
         }
-        //导入
+
         public override void Sub_DataIn()
         {
-            string hnumber = "";
-                                    //
-            HStdWorkTimes = DBUtility.Gy_BaseFun.Fun_GetCol("标准工时", grdMain);
-            HProcNum = DBUtility.Gy_BaseFun.Fun_GetCol("工序代码", grdMain);
-            HProcName = DBUtility.Gy_BaseFun.Fun_GetCol("工序", grdMain);
-            HMaterNum = DBUtility.Gy_BaseFun.Fun_GetCol("物料代码", grdMain);
-            HMaterName = DBUtility.Gy_BaseFun.Fun_GetCol("物料", grdMain);
-            HUpperlimit = DBUtility.Gy_BaseFun.Fun_GetCol("上线比例", grdMain);
-            HLowerlimit = DBUtility.Gy_BaseFun.Fun_GetCol("下线比例", grdMain);
-            HUSEORGName = DBUtility.Gy_BaseFun.Fun_GetCol("组织", grdMain);
-            HMaker = DBUtility.Gy_BaseFun.Fun_GetCol("制单人", grdMain);
-            HMakeDate = DBUtility.Gy_BaseFun.Fun_GetCol("制单日期", grdMain);
+            int sHStdWorkTimesCol = DBUtility.Gy_BaseFun.Fun_GetCol("标准工时", grdMain);
+            int sHProcNumCol = DBUtility.Gy_BaseFun.Fun_GetCol("工序代码", grdMain);
+            int sHProcNameCol = DBUtility.Gy_BaseFun.Fun_GetCol("工序", grdMain);
+            int sHMaterNumCol = DBUtility.Gy_BaseFun.Fun_GetCol("物料代码", grdMain);
+            int sHMaterNameCol = DBUtility.Gy_BaseFun.Fun_GetCol("物料", grdMain);
+            int sHUpperlimitCol = DBUtility.Gy_BaseFun.Fun_GetCol("上线比例", grdMain);
+            int sHLowerlimitCol = DBUtility.Gy_BaseFun.Fun_GetCol("下线比例", grdMain);
+            int sHUSEORGNameCol = DBUtility.Gy_BaseFun.Fun_GetCol("组织", grdMain);
+            int sHMakerCol = DBUtility.Gy_BaseFun.Fun_GetCol("制单人", grdMain);
+            int sHMakeDateCol = DBUtility.Gy_BaseFun.Fun_GetCol("制单日期", grdMain);
 
-            //没有找到列
-            if (HStdWorkTimes == -1)
-            {
-                MessageBox.Show("没有找到【标准工时】的标题", "提示");
-                return;
-            }
-            if (HProcName == -1)
-            {
-                MessageBox.Show("没有找到【工序】的标题", "提示");
-                return;
-            }
-            if (HMaterName == -1)
-            {
-                MessageBox.Show("没有找到【物料】的标题", "提示");
-                return;
-            }
-            if (HUpperlimit == -1)
-            {
-                MessageBox.Show("没有找到【上线比例】的标题", "提示");
-                return;
-            }
-            if (HLowerlimit == -1)
-            {
-                MessageBox.Show("没有找到【下线比例】的标题", "提示");
-                return;
-            }
-            if (HUSEORGName == -1)
-            {
-                MessageBox.Show("没有找到【组织】的标题", "提示");
-                return;
-            }
-            if (HMaker == -1)
-            {
-                MessageBox.Show("没有找到【制单人】的标题", "提示");
-                return;
-            }
-            if (HMakeDate == -1)
-            {
-                MessageBox.Show("没有找到【制单日期】的标题", "提示");
-                return;
-            }
-            //
-            if (!Checkdata())
-            {
-                return;
-            }
-            if (grdMain.Rows.Count > 0)
-            { 
-                hnumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[0].Cells[HMaterNum].Value);
-                BillNew.omodel.HMakeDate =  (DateTime.Today.Date).ToString();
-                BillNew.omodel.HUSEORGID =  DBUtility.ClsPub.HOrgID;
-                BillNew.omodel.HStopflag = false;
-                BillNew.DetailColl.Clear();
-            } 
             for (int i = 0; i <= grdMain.Rows.Count - 1; i++)
             {
-                if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HProcNum].Value) != "" && DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HMaterNum].Value) != "")
+                if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[sHMaterNumCol].Value) != "" && DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[sHProcNumCol].Value) != "")
                 {
                     //写入类
                     if (WriteClass(i))
@@ -194,136 +113,93 @@
         //写入类 从控件
         private bool WriteClass(int row)
         {
-            string sHNumber = "";
-            string sHNamePoc = "";
-            string HStopflag = "";
-            string HUSEORGID = "";
-            //string sHNumberWorkType = "";
-            string HStdWorkTimes = "";
-            string HUpperlimit="";  //上限比例
-            string HLowerlimit="";  //下限比例
+            BillNew.DetailColl.Clear();
+            string sMaterNumber = "";
+            string sMaterName = "";
+            string sProcNumber = "";
+            string sProcName = "";
+            double sStdWorkTimes = 0;
+            double sUpperlimit = 0;
+            double sLowerlimit = 0;
+            int sUSEORGName = 0;
+            DateTime sHMakeDate = DateTime.Today.Date;
+            string sHMaker = DBUtility.ClsPub.CurUserName;
 
-            int HMaterNum = DBUtility.Gy_BaseFun.Fun_GetCol("产品代码", grdMain);
-            int sMaterNameCol = DBUtility.Gy_BaseFun.Fun_GetCol("产品名称", grdMain);
-            int sModelCol = DBUtility.Gy_BaseFun.Fun_GetCol("规格型号", grdMain);
-            int HProcNum = DBUtility.Gy_BaseFun.Fun_GetCol("工序代码", grdMain);
-            int sProcNameCol = DBUtility.Gy_BaseFun.Fun_GetCol("工序", grdMain);
-            int sSourceNumberCol = DBUtility.Gy_BaseFun.Fun_GetCol("资源代码", grdMain);
-            int sSourceNameCol = DBUtility.Gy_BaseFun.Fun_GetCol("生产资源", grdMain);
-            int sPriceCol = DBUtility.Gy_BaseFun.Fun_GetCol("单价", grdMain);
-            //long HItemID = 0; 
+            int sHStdWorkTimesCol = DBUtility.Gy_BaseFun.Fun_GetCol("标准工时", grdMain);
+            int sHProcNumCol = DBUtility.Gy_BaseFun.Fun_GetCol("工序代码", grdMain);
+            int sHProcNameCol = DBUtility.Gy_BaseFun.Fun_GetCol("工序", grdMain);
+            int sHMaterNumCol = DBUtility.Gy_BaseFun.Fun_GetCol("物料代码", grdMain);
+            int sHMaterNameCol = DBUtility.Gy_BaseFun.Fun_GetCol("物料", grdMain);
+            int sHUpperlimitCol = DBUtility.Gy_BaseFun.Fun_GetCol("上线比例", grdMain);
+            int sHLowerlimitCol = DBUtility.Gy_BaseFun.Fun_GetCol("下线比例", grdMain);
+            int sHUSEORGNameCol = DBUtility.Gy_BaseFun.Fun_GetCol("组织", grdMain);
+            int sHMakerCol = DBUtility.Gy_BaseFun.Fun_GetCol("制单人", grdMain);
+            int sHMakeDateCol = DBUtility.Gy_BaseFun.Fun_GetCol("制单日期", grdMain);
             //
-            sHNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[HMaterNum].Value);
-            sHNamePoc = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[HProcNum].Value);
-            //
-            //
-            HStopflag = DBUtility.ClsPub.isBool(grdMain.Rows[row].Cells[HStopflag].Value).ToString();
-            HUSEORGID = DBUtility.ClsPub.HOrgID.ToString();
-            HStdWorkTimes = DBUtility.ClsPub.isSingle(grdMain.Rows[row].Cells[HStdWorkTimes].Value).ToString();
-            HUpperlimit = DBUtility.ClsPub.isSingle(grdMain.Rows[row].Cells[HUpperlimit].Value).ToString();
-            HLowerlimit = DBUtility.ClsPub.isSingle(grdMain.Rows[row].Cells[HLowerlimit].Value).ToString();
+            sMaterNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[sHMaterNumCol].Value);
+            //sMaterName = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[sHMaterNameCol].Value);
+            sProcNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[sHProcNumCol].Value);
+            //sProcName = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[sHProcNameCol].Value);
+            sStdWorkTimes = DBUtility.ClsPub.isDoule(grdMain.Rows[row].Cells[sHStdWorkTimesCol].Value);
+            sUpperlimit = DBUtility.ClsPub.isDoule(grdMain.Rows[row].Cells[sHUpperlimitCol].Value);
+            sLowerlimit = DBUtility.ClsPub.isDoule(grdMain.Rows[row].Cells[sHLowerlimitCol].Value);
+            //sUSEORGName = DBUtility.ClsPub.isInt(grdMain.Rows[row].Cells[sHUSEORGNameCol].Value);
+            //sHMakeDate = DBUtility.ClsPub.isDate(grdMain.Rows[row].Cells[sHMakeDateCol].Value);
+            //sHMaker = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[sHMakerCol].Value);
 
             //判断是否允许 保存
-            if (!DBUtility.ClsPub.AllowNumber(sHNumber))
+            //审核代码是否合理
+            if (!DBUtility.ClsPub.AllowNumber(sMaterNumber))
             {
                 MessageBox.Show("产品代码中不能出现连续‘.’并且首位末位不能为‘.’!", "提示");
                 return false;
             }
-            if (!DBUtility.ClsPub.AllowNumber(sHNamePoc))
+            if (!DBUtility.ClsPub.AllowNumber(sProcNumber))
             {
                 MessageBox.Show("工序代码中不能出现连续‘.’并且首位末位不能为‘.’!", "提示");
                 return false;
             }
 
             Model.ClsGy_StdWorkTimes_Model oSub = new Model.ClsGy_StdWorkTimes_Model();
-
-            //得到工序内码
-            if (oProcHlp.GetInfoByName(sHNamePoc))
-            {
-                oSub.HProcID = oProcHlp.omodel.HItemID;
-            }
             //得到物料内码
-            if (oMaterHlp.GetInfoByName(sHNumber))
+            if (oMaterHlp.GetInfoByNumber(sMaterNumber))
             {
                 oSub.HMaterID = oMaterHlp.omodel.HItemID;
             }
-
-
-            //写入信息
-            oSub.HEntryID = j;
-
-            oSub.HMaker = DBUtility.ClsPub.CurUserName;
-            oSub.HMakeDate = (DateTime.Today.Date).ToString();
-            oSub.HStdWorkTimes = double.Parse(HStdWorkTimes);
-            oSub.HRemark = "";
-            oSub.HUpperlimit = double.Parse(HUpperlimit);
-            oSub.HLowerlimit = double.Parse(HLowerlimit);
-            oSub.HStopflag = bool.Parse(HStopflag);
-
-
-            BillNew.DetailColl.Add(oSub);
-            return true;
-        }
-
-        //检查物料
-        private bool Checkdata()
-        {
-            bool b = false;
-            string sErrMsg = "";
-            string sMsg = "";
-            for (int i = 0; i <= grdMain.Rows.Count - 1; i++)
+            else
             {
-                string sHNumber = "";
-                string sHNamePoc = "";
-
-                //
-                sHNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HMaterNum].Value);
-                sHNamePoc = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HProcNum].Value);
-                if (sHNumber != "")
-                {
-                    // 
-                    //审核代码是否合理
-                    if (!DBUtility.ClsPub.AllowNumber(sHNumber))
-                    {
-                        MessageBox.Show("物料代码中不能出现连续‘.’并且首位末位不能为‘.’!", "提示");
-                        return false;
-                    }
-                    //得到物料内码
-                    int j = i + HBeginRow;
-                    if (!oMaterHlp.GetInfoByNumber(sHNumber))
-                    {
-                        sMsg = "[" + sHNumber + "]物料不存在";
-                        if (sErrMsg.Contains(sMsg) == false)
-                        {
-                            sErrMsg = sErrMsg + "[" + sHNumber + "]物料不存在\r\n";
-                        }
-                        b = true;
-                    }
-                    //得到工序内码
-                    if (!oProcHlp.GetInfoByName(sHNamePoc))
-                    {
-                        sMsg = "[" + sHNamePoc + "]工序不存在";
-                        if (sErrMsg.Contains(sMsg) == false)
-                        {
-                            sErrMsg = sErrMsg + "[" + sHNamePoc + "]工序不存在\r\n";
-                        }
-                        b = true;
-                    }
-                }
-            }
-            if (b == true)
-            {
-                Pub_Control.ErrMsgBox oMsgbox = new Pub_Control.ErrMsgBox();
-                oMsgbox.txtHErrMsg.Text = sErrMsg;
-                oMsgbox.ShowDialog();
+                oSub.HMaterID = 0;
+                MessageBox.Show("第" + row.ToString() + "行," + sMaterNumber + "没有找到对应的物料!");
                 return false;
+            }
+            //得到工序内码
+            if (oProcHlp.GetInfoByNumber(sProcNumber))
+            {
+                oSub.HProcID = oProcHlp.omodel.HItemID;
             }
             else
             {
-                return true;
+                oSub.HProcID = 0;
+                MessageBox.Show("第" + row.ToString() + "行," + sProcNumber + "没有找到对应的工序!");
+                return false;
             }
+            
+            //写入信息
+           
+            oSub.HRemark = "";
+            oSub.HStdWorkTimes = sStdWorkTimes;
+            oSub.HUpperlimit = sUpperlimit;
+            oSub.HLowerlimit = sLowerlimit;
+            oSub.HUSEORGID = DBUtility.ClsPub.HOrgID;
+            oSub.HMaker = DBUtility.ClsPub.CurUserName;
+            oSub.HMakeDate = DateTime.Today.ToShortDateString();
+            BillNew.DetailColl.Add(oSub);
+            //oProc.oModel.HBillSubType = DBUtility.ClsPub.isStrNull(txtHBillSubType.Text);
+
+            return true;
         }
 
+
         private void Gy_StdWorkTimes_RoutingBill_Load(object sender, EventArgs e)
         {
 

--
Gitblit v1.9.1