From bd29472dea45f3fd8693473c515db37d998e2b00 Mon Sep 17 00:00:00 2001
From: YL <YL@LAPTOP-SE03PLUR>
Date: 星期二, 17 八月 2021 18:32:38 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 PlanM/数据导入/Gy_DataIn_RoutingBill.cs |  578 +++++++++++++++++++++++++++++++--------------------------
 1 files changed, 310 insertions(+), 268 deletions(-)

diff --git "a/PlanM/\346\225\260\346\215\256\345\257\274\345\205\245/Gy_DataIn_RoutingBill.cs" "b/PlanM/\346\225\260\346\215\256\345\257\274\345\205\245/Gy_DataIn_RoutingBill.cs"
index aebe558..3488207 100644
--- "a/PlanM/\346\225\260\346\215\256\345\257\274\345\205\245/Gy_DataIn_RoutingBill.cs"
+++ "b/PlanM/\346\225\260\346\215\256\345\257\274\345\205\245/Gy_DataIn_RoutingBill.cs"
@@ -10,7 +10,7 @@
 
 namespace PlanM
 {
-    public partial class Gy_DataIn_RoutingBill :BLL.Gy_DataInTmp
+    public partial class Gy_DataIn_RoutingBill : BLL.Gy_DataInTmp
     {
         public Gy_DataIn_RoutingBill()
         {
@@ -21,7 +21,7 @@
         public int HProcNoCol = 0;       //工序序号
         public int HProcNameCol = 0;           //工序
         public int HWorkCenterNameCol = 0;        //工作中心   
-        public int HWorkQtyCol = 0;          //产能
+        public int HWorkQtyCol = 0;          //加工数量
         public int HBeginDayQtyCol = 6;     //开工固天
         public int HBeginFixQtyCol = 7;     //开工余量 
         public int HFixPriceCol = 8;        //定额 小时工资
@@ -37,6 +37,7 @@
         public int HVerNumCol = 0;       //版本
         public int HMouldNoCol = 0;       //模具编号
         public int HProcWorkNumCol = 0;        //程序号
+        public int HPassRateCol = 0;        //良率
         //
         public const int HBeginRow = 2;         //有效数据,开始行数
         // 
@@ -53,7 +54,7 @@
         {
             base.sSheetName = txtHSheetName.Text;
             return base.OpenExcelData();
-        } 
+        }
 
         /// <summary>
         ///  初始化界面
@@ -61,7 +62,7 @@
         public override void initData()
         {
             base.initData();
-            base.sSheetName = txtHSheetName.Text ; 
+            base.sSheetName = txtHSheetName.Text;
             base.ModRightName = "Gy_DataIn_RoutingBill";
             base.ModRightNameCheck = base.ModRightName + base.ModRightNameCheck;
             base.ModRightNameClose = base.ModRightName + base.ModRightNameClose;
@@ -80,307 +81,330 @@
         //导入
         public override void Sub_DataIn()
         {
-            string hnumber = "";
-            string HBillNo = "";
-            //
-            HMaterNumberCol = DBUtility.Gy_BaseFun.Fun_GetCol("产品代码", grdMain);
-            HProcNoCol = DBUtility.Gy_BaseFun.Fun_GetCol("工序序号", grdMain);
-            HProcNameCol = DBUtility.Gy_BaseFun.Fun_GetCol("工序", grdMain);
-            HWorkCenterNameCol = DBUtility.Gy_BaseFun.Fun_GetCol("工作中心", grdMain);
-            HWorkQtyCol = DBUtility.Gy_BaseFun.Fun_GetCol("产能", grdMain);
-            HPicNumCol = DBUtility.Gy_BaseFun.Fun_GetCol("图纸编号", grdMain);
-            HTechnologyParameterCol = DBUtility.Gy_BaseFun.Fun_GetCol("工艺参数", grdMain);
-            HProcCheckNoteCol = DBUtility.Gy_BaseFun.Fun_GetCol("本工序确认记录", grdMain);
-            HPicNumVerCol = DBUtility.Gy_BaseFun.Fun_GetCol("图号版本", grdMain);
-            HPicNumAssembleCol = DBUtility.Gy_BaseFun.Fun_GetCol("总装图号", grdMain);
-            HMaterTextureCol = DBUtility.Gy_BaseFun.Fun_GetCol("材质", grdMain);
-            HProductNumCol = DBUtility.Gy_BaseFun.Fun_GetCol("成品编号", grdMain);
-            HVerNumCol = DBUtility.Gy_BaseFun.Fun_GetCol("版本", grdMain);
-            HMouldNoCol = DBUtility.Gy_BaseFun.Fun_GetCol("模具编号", grdMain);
-            HProcWorkNumCol = DBUtility.Gy_BaseFun.Fun_GetCol("程序号", grdMain);
-            HBeginFixQtyCol = DBUtility.Gy_BaseFun.Fun_GetCol("开工余量", grdMain);
-            HBeginDayQtyCol = DBUtility.Gy_BaseFun.Fun_GetCol("开工固天", grdMain);
-            HFixPriceCol = DBUtility.Gy_BaseFun.Fun_GetCol("小时工资", grdMain);
-            HProcPriceCol = DBUtility.Gy_BaseFun.Fun_GetCol("单个工价", grdMain);
+            try
+            {
+                string hnumber = "";
+                string HBillNo = "";
+                //
+                HMaterNumberCol = DBUtility.Gy_BaseFun.Fun_GetCol("产品代码", grdMain);
+                HProcNoCol = DBUtility.Gy_BaseFun.Fun_GetCol("工序序号", grdMain);
+                HProcNameCol = DBUtility.Gy_BaseFun.Fun_GetCol("工序", grdMain);
+                HWorkCenterNameCol = DBUtility.Gy_BaseFun.Fun_GetCol("工作中心", grdMain);
+                HWorkQtyCol = DBUtility.Gy_BaseFun.Fun_GetCol("加工数量", grdMain);
+                HPicNumCol = DBUtility.Gy_BaseFun.Fun_GetCol("图纸编号", grdMain);
+                HTechnologyParameterCol = DBUtility.Gy_BaseFun.Fun_GetCol("工艺参数", grdMain);
+                HProcCheckNoteCol = DBUtility.Gy_BaseFun.Fun_GetCol("本工序确认记录", grdMain);
+                HPicNumVerCol = DBUtility.Gy_BaseFun.Fun_GetCol("图号版本", grdMain);
+                HPicNumAssembleCol = DBUtility.Gy_BaseFun.Fun_GetCol("总装图号", grdMain);
+                HMaterTextureCol = DBUtility.Gy_BaseFun.Fun_GetCol("材质", grdMain);
+                HProductNumCol = DBUtility.Gy_BaseFun.Fun_GetCol("成品编号", grdMain);
+                HVerNumCol = DBUtility.Gy_BaseFun.Fun_GetCol("版本", grdMain);
+                HMouldNoCol = DBUtility.Gy_BaseFun.Fun_GetCol("模具编号", grdMain);
+                HProcWorkNumCol = DBUtility.Gy_BaseFun.Fun_GetCol("程序号", grdMain);
+                HBeginFixQtyCol = DBUtility.Gy_BaseFun.Fun_GetCol("开工余量", grdMain);
+                HBeginDayQtyCol = DBUtility.Gy_BaseFun.Fun_GetCol("开工固天", grdMain);
+                HFixPriceCol = DBUtility.Gy_BaseFun.Fun_GetCol("小时工资", grdMain);
+                HProcPriceCol = DBUtility.Gy_BaseFun.Fun_GetCol("单个工价", grdMain);
+                HPassRateCol = DBUtility.Gy_BaseFun.Fun_GetCol("良率", grdMain);
 
-            //没有找到列
-            if (HMaterNumberCol == -1)
-            {
-                MessageBox.Show("没有找到【产品代码】的标题", "提示");
-                return;
-            }
-            if (HProcNameCol == -1)
-            {
-                MessageBox.Show("没有找到【工序】的标题", "提示");
-                return;
-            }
-            if (HWorkCenterNameCol == -1)
-            {
-                MessageBox.Show("没有找到【工作中心】的标题", "提示");
-                return;
-            }
-            if (HWorkQtyCol == -1)
-            {
-                MessageBox.Show("没有找到【产能】的标题", "提示");
-                return;
-            }
-            if (HBeginFixQtyCol == -1)
-            {
-                MessageBox.Show("没有找到【开工余量】的标题", "提示");
-                return;
-            }
-            if (HBeginDayQtyCol == -1)
-            {
-                MessageBox.Show("没有找到【开工固天】的标题", "提示");
-                return;
-            }
-            if (HFixPriceCol == -1)
-            {
-                MessageBox.Show("没有找到【小时工资】的标题", "提示");
-                return;
-            }
-            if (HProcPriceCol == -1)
-            {
-                MessageBox.Show("没有找到【单个工价】的标题", "提示");
-                return;
-            }
-            if (HProcNoCol == -1)
-            {
-                MessageBox.Show("没有找到【工序序号】的标题", "提示");
-                return;
-            }
-            if (HTechnologyParameterCol == -1)
-            {
-                MessageBox.Show("没有找到【工艺参数】的标题", "提示");
-                return;
-            }
-            if (HPicNumCol == -1)
-            {
-                MessageBox.Show("没有找到【图纸编号】的标题", "提示");
-                return;
-            }
-            if (HProcCheckNoteCol == -1)
-            {
-                MessageBox.Show("没有找到【本工序确认记录】的标题", "提示");
-                return;
-            }
-            if (HPicNumVerCol == -1)
-            {
-                MessageBox.Show("没有找到【图号版本】的标题", "提示");
-                return;
-            }
-            if (HPicNumAssembleCol == -1)
-            {
-                MessageBox.Show("没有找到【总装图号】的标题", "提示");
-                return;
-            }
-            if (HMaterTextureCol == -1)
-            {
-                MessageBox.Show("没有找到【材质】的标题", "提示");
-                return;
-            }
-            if (HProductNumCol == -1)
-            {
-                MessageBox.Show("没有找到【成品编号】的标题", "提示");
-                return;
-            }
-            if (HVerNumCol == -1)
-            {
-                MessageBox.Show("没有找到【版本】的标题", "提示");
-                return;
-            }
-            if (HMouldNoCol == -1)
-            {
-                MessageBox.Show("没有找到【模具编号】的标题", "提示");
-                return;
-            }
-            if (HProcWorkNumCol == -1)
-            {
-                MessageBox.Show("没有找到【程序号】的标题", "提示");
-                return;
-            }
-            //
-            if (!Checkdata())
-            {
-                return;
-            }
-            if (grdMain.Rows.Count > 0)
-            { 
-                hnumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[0].Cells[HMaterNumberCol].Value);
-                HBillNo = ClsPub.CreateBillCode(BillNew.BillType, ref ClsPub.sExeReturnInfo, true);
-                BillNew.omodel.HStandard = false;
-                BillNew.omodel.HMainTimeUnit = "小时";
-                BillNew.omodel.HYear = 2011;
-                BillNew.omodel.HPeriod = 1;
-                BillNew.omodel.HBillNo = HBillNo;
-                BillNew.omodel.HDate = DateTime.Today.Date;
-                BillNew.omodel.HPicNumVer = "";
-                BillNew.omodel.HPicNumAssemble = "";
-                BillNew.omodel.HMaterTexture = "";
-                BillNew.omodel.HProductNum = "";
-                BillNew.omodel.HVerNum = "";
-                BillNew.DetailColl.Clear();
-            } 
-            for (int i = 0; i <= grdMain.Rows.Count - 1; i++)
-            {
-                BillNew.omodel.HPicNumVer = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HPicNumVerCol].Value);
-                BillNew.omodel.HPicNumAssemble = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HPicNumAssembleCol].Value);
-                BillNew.omodel.HMaterTexture = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HMaterTextureCol].Value);
-                BillNew.omodel.HProductNum = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HProductNumCol].Value);
-                BillNew.omodel.HVerNum = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HVerNumCol].Value);
-                string sHNumber = ""; 
-                if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HMaterNumberCol].Value) != "" )
+                //没有找到列
+                if (HMaterNumberCol == -1)
                 {
-                    //
-                    sHNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HMaterNumberCol].Value);
-                    //审核代码是否合理
-                    if (!DBUtility.ClsPub.AllowNumber(sHNumber))
+                    MessageBox.Show("没有找到【产品代码】的标题", "提示");
+                    return;
+                }
+                if (HProcNameCol == -1)
+                {
+                    MessageBox.Show("没有找到【工序】的标题", "提示");
+                    return;
+                }
+                if (HWorkCenterNameCol == -1)
+                {
+                    MessageBox.Show("没有找到【工作中心】的标题", "提示");
+                    return;
+                }
+                if (HWorkQtyCol == -1)
+                {
+                    MessageBox.Show("没有找到【加工数量】的标题", "提示");
+                    return;
+                }
+                if (HBeginFixQtyCol == -1)
+                {
+                    MessageBox.Show("没有找到【开工余量】的标题", "提示");
+                    return;
+                }
+                if (HBeginDayQtyCol == -1)
+                {
+                    MessageBox.Show("没有找到【开工固天】的标题", "提示");
+                    return;
+                }
+                if (HFixPriceCol == -1)
+                {
+                    MessageBox.Show("没有找到【小时工资】的标题", "提示");
+                    return;
+                }
+                if (HProcPriceCol == -1)
+                {
+                    MessageBox.Show("没有找到【单个工价】的标题", "提示");
+                    return;
+                }
+                if (HProcNoCol == -1)
+                {
+                    MessageBox.Show("没有找到【工序序号】的标题", "提示");
+                    return;
+                }
+                if (HTechnologyParameterCol == -1)
+                {
+                    MessageBox.Show("没有找到【工艺参数】的标题", "提示");
+                    return;
+                }
+                if (HPicNumCol == -1)
+                {
+                    MessageBox.Show("没有找到【图纸编号】的标题", "提示");
+                    return;
+                }
+                if (HProcCheckNoteCol == -1)
+                {
+                    MessageBox.Show("没有找到【本工序确认记录】的标题", "提示");
+                    return;
+                }
+                if (HPicNumVerCol == -1)
+                {
+                    MessageBox.Show("没有找到【图号版本】的标题", "提示");
+                    return;
+                }
+                if (HPicNumAssembleCol == -1)
+                {
+                    MessageBox.Show("没有找到【总装图号】的标题", "提示");
+                    return;
+                }
+                if (HMaterTextureCol == -1)
+                {
+                    MessageBox.Show("没有找到【材质】的标题", "提示");
+                    return;
+                }
+                if (HProductNumCol == -1)
+                {
+                    MessageBox.Show("没有找到【成品编号】的标题", "提示");
+                    return;
+                }
+                if (HVerNumCol == -1)
+                {
+                    MessageBox.Show("没有找到【版本】的标题", "提示");
+                    return;
+                }
+                if (HMouldNoCol == -1)
+                {
+                    MessageBox.Show("没有找到【模具编号】的标题", "提示");
+                    return;
+                }
+                if (HProcWorkNumCol == -1)
+                {
+                    MessageBox.Show("没有找到【程序号】的标题", "提示");
+                    return;
+                }
+                if (HPassRateCol == -1)
+                {
+                    MessageBox.Show("没有找到【良率】的标题", "提示");
+                    return;
+                }
+                //
+                if (!Checkdata())
+                {
+                    return;
+                }
+                if (grdMain.Rows.Count > 0)
+                {
+                    hnumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[0].Cells[HMaterNumberCol].Value);
+                    HBillNo = ClsPub.CreateBillCode(BillNew.BillType, ref ClsPub.sExeReturnInfo, true);
+                    BillNew.omodel.HStandard = false;
+                    BillNew.omodel.HMainTimeUnit = "小时";
+                    BillNew.omodel.HYear = 2011;
+                    BillNew.omodel.HPeriod = 1;
+                    BillNew.omodel.HBillNo = HBillNo;
+                    BillNew.omodel.HDate = DateTime.Today.Date;
+                    BillNew.omodel.HPicNumVer = "";
+                    BillNew.omodel.HPicNumAssemble = "";
+                    BillNew.omodel.HMaterTexture = "";
+                    BillNew.omodel.HProductNum = "";
+                    BillNew.omodel.HVerNum = "";
+                    BillNew.DetailColl.Clear();
+                }
+                for (int i = 0; i <= grdMain.Rows.Count - 1; i++)
+                {
+                    BillNew.omodel.HPicNumVer = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HPicNumVerCol].Value);
+                    BillNew.omodel.HPicNumAssemble = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HPicNumAssembleCol].Value);
+                    BillNew.omodel.HMaterTexture = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HMaterTextureCol].Value);
+                    BillNew.omodel.HProductNum = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HProductNumCol].Value);
+                    BillNew.omodel.HVerNum = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HVerNumCol].Value);
+                    string sHNumber = "";
+                    if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HMaterNumberCol].Value) != "")
                     {
-                        MessageBox.Show("物料代码中不能出现连续‘.’并且首位末位不能为‘.’!", "提示");
-                        return;
-                    }
-
-                    if (hnumber == DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HMaterNumberCol].Value))
-                    {
-                        //得到物料内码
-                        if (oMaterHlp.GetInfoByNumber(sHNumber))
-                        {
-                            if (BillNew.omodel.HMaterID != oMaterHlp.omodel.HItemID)
-                            {
-                                BillNew.omodel.HMaterID = oMaterHlp.omodel.HItemID;
-                                BillNew.omodel.HMaterNumber = oMaterHlp.omodel.HNumber;
-                                BillNew.omodel.HUnitID = oMaterHlp.omodel.HUnitID;
-                                BillNew.omodel.HUnitNumber = oMaterHlp.omodel.HUnitNumber;
-                            }
-
-                        }
-                        else
-                        {
-                            BillNew.omodel.HMaterID = 0;
-                            MessageBox.Show("第" + i.ToString() + "行," + sHNumber + "没有找到对应的物料!");
-                            return;
-                        }
-                        j++;
-                        //写入类
-                        WriteClass(i);
-
-                    }
-                    else
-                    {
-                        DataSet Ds;
-                        ClsCN oCn=new ClsCN();
-                        bool b = false;
-                        // 判断是否存在工艺路线
-                        Ds = oCn.RunProcReturn("Select HMaterID from Gy_RoutingBillMain Where HMaterID=" + BillNew.omodel.HMaterID.ToString(), "Gy_RoutingBillMain");
-                        if (checkadd.Checked == true)
-                        {
-                            //if (Ds.Tables[0].Rows.Count == 0)//追加
-                            //{
-                                //新增前 先删除原来工艺
-                                BillNew.DeleteByMaterID(BillNew.omodel.HMaterID);
-                                b = BillNew.AddBill(ref ClsPub.sExeReturnInfo);
-                                if (b == false) return;
-                                c++;
-                                BillNew.CheckBill(BillNew.omodel.HInterID, ref ClsPub.sExeReturnInfo);
-                            //}
-                            //else
-                            //{
-
-                            //}
-                        }
-                        else
-                        {
-                            BillNew.DeleteByMaterID(BillNew.omodel.HMaterID);
-                            b = BillNew.AddBill(ref ClsPub.sExeReturnInfo);
-                            if (b == false) return;
-                            c++;
-                            BillNew.CheckBill(BillNew.omodel.HInterID, ref ClsPub.sExeReturnInfo);
-                        }
-
-
-                        BillNew.DetailColl.Clear();
-                        hnumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HMaterNumberCol].Value);
+                        //
                         sHNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HMaterNumberCol].Value);
-                        
                         //审核代码是否合理
                         if (!DBUtility.ClsPub.AllowNumber(sHNumber))
                         {
                             MessageBox.Show("物料代码中不能出现连续‘.’并且首位末位不能为‘.’!", "提示");
                             return;
                         }
-                        //得到物料内码
-                        if (oMaterHlp.GetInfoByNumber(sHNumber))
+
+                        if (hnumber == DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HMaterNumberCol].Value))
                         {
-                            if (BillNew.omodel.HMaterID != oMaterHlp.omodel.HItemID)
+                            //得到物料内码
+                            if (oMaterHlp.GetInfoByNumber(sHNumber))
                             {
-                                BillNew.omodel.HMaterID = oMaterHlp.omodel.HItemID;
-                                BillNew.omodel.HMaterNumber = oMaterHlp.omodel.HNumber;
-                                BillNew.omodel.HUnitID = oMaterHlp.omodel.HUnitID;
-                                BillNew.omodel.HUnitNumber = oMaterHlp.omodel.HUnitNumber;
+                                if (BillNew.omodel.HMaterID != oMaterHlp.omodel.HItemID)
+                                {
+                                    BillNew.omodel.HMaterID = oMaterHlp.omodel.HItemID;
+                                    BillNew.omodel.HMaterNumber = oMaterHlp.omodel.HNumber;
+                                    BillNew.omodel.HUnitID = oMaterHlp.omodel.HUnitID;
+                                    BillNew.omodel.HUnitNumber = oMaterHlp.omodel.HUnitNumber;
+                                }
+
                             }
+                            else
+                            {
+                                BillNew.omodel.HMaterID = 0;
+                                MessageBox.Show("第" + i.ToString() + "行," + sHNumber + "没有找到对应的物料!");
+                                return;
+                            }
+                            j++;
+                            //写入类
+                            WriteClass(i);
 
                         }
                         else
                         {
-                            BillNew.omodel.HMaterID = 0;
-                            MessageBox.Show("第" + i.ToString() + "行," + sHNumber + "没有找到对应的物料!");
-                            return;
+                            DataSet Ds;
+                            ClsCN oCn = new ClsCN();
+                            bool b = false;
+                            // 判断是否存在工艺路线
+                            Ds = oCn.RunProcReturn("Select HMaterID from Gy_RoutingBillMain Where HMaterID=" + BillNew.omodel.HMaterID.ToString(), "Gy_RoutingBillMain");
+                            if (checkadd.Checked == true)
+                            {
+                                //if (Ds.Tables[0].Rows.Count == 0)//追加
+                                //{
+                                //新增前 先删除原来工艺
+                                BillNew.DeleteByMaterID(BillNew.omodel.HMaterID);
+                                b = BillNew.AddBill(ref ClsPub.sExeReturnInfo);
+                                if (b == false)
+                                {
+                                    MessageBox.Show("第" + i.ToString() + "行,物料" + BillNew.omodel.HMaterNumber + "新增工艺路线失败!代码293行中,原因:" + ClsPub.sExeReturnInfo);
+                                    return;
+                                }
+                                c++;
+                                BillNew.CheckBill(BillNew.omodel.HInterID, ref ClsPub.sExeReturnInfo);
+                                //}
+                                //else
+                                //{
+
+                                //}
+                            }
+                            else
+                            {
+                                BillNew.DeleteByMaterID(BillNew.omodel.HMaterID);
+                                b = BillNew.AddBill(ref ClsPub.sExeReturnInfo);
+                                if (b == false)
+                                {
+                                    MessageBox.Show("第" + i.ToString() + "行,物料" + sHNumber + "新增工艺路线失败!代码310行中");
+                                    return;
+                                }
+                                c++;
+                                BillNew.CheckBill(BillNew.omodel.HInterID, ref ClsPub.sExeReturnInfo);
+                            }
+
+
+                            BillNew.DetailColl.Clear();
+                            hnumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HMaterNumberCol].Value);
+                            sHNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HMaterNumberCol].Value);
+
+                            //审核代码是否合理
+                            if (!DBUtility.ClsPub.AllowNumber(sHNumber))
+                            {
+                                MessageBox.Show("物料代码中不能出现连续‘.’并且首位末位不能为‘.’!", "提示");
+                                return;
+                            }
+                            //得到物料内码
+                            if (oMaterHlp.GetInfoByNumber(sHNumber))
+                            {
+                                if (BillNew.omodel.HMaterID != oMaterHlp.omodel.HItemID)
+                                {
+                                    BillNew.omodel.HMaterID = oMaterHlp.omodel.HItemID;
+                                    BillNew.omodel.HMaterNumber = oMaterHlp.omodel.HNumber;
+                                    BillNew.omodel.HUnitID = oMaterHlp.omodel.HUnitID;
+                                    BillNew.omodel.HUnitNumber = oMaterHlp.omodel.HUnitNumber;
+                                }
+
+                            }
+                            else
+                            {
+                                BillNew.omodel.HMaterID = 0;
+                                MessageBox.Show("第" + i.ToString() + "行," + sHNumber + "没有找到对应的物料!");
+                                return;
+                            }
+                            j = 0;
+                            HBillNo = ClsPub.CreateBillCode(BillNew.BillType, ref ClsPub.sExeReturnInfo, true);
+                            BillNew.omodel.HBillNo = HBillNo;
+                            //写入类
+                            WriteClass(i);
                         }
-                        j = 0;
-                        HBillNo = ClsPub.CreateBillCode(BillNew.BillType, ref ClsPub.sExeReturnInfo, true);
-                        BillNew.omodel.HBillNo = HBillNo;
-                        //写入类
-                        WriteClass(i);
+                    }
+                    else
+                    {
+                        MessageBox.Show("第" + i.ToString() + "行,没有找到对应的物料!");
+                        return;
                     }
                 }
-                else
+                //最后一个物料处理
+                if (BillNew.DetailColl.Count > 0)
                 {
-                    MessageBox.Show("第" + i.ToString() + "行,没有找到对应的物料!");
-                    return;
-                }
-            }
-            //最后一个物料处理
-            if (BillNew.DetailColl.Count > 0)
-            {
-                DataSet Ds;
-                ClsCN oCn = new ClsCN();
-                bool b = false;
-                //Ds = oCn.RunProcReturn("Select HMaterID from Gy_RoutingBillMain Where HMaterID=" + BillNew.omodel.HMaterID.ToString(), "Gy_RoutingBillMain");
-                //if (Ds.Tables[0].Rows.Count == 0)
-                //{
+                    DataSet Ds;
+                    ClsCN oCn = new ClsCN();
+                    bool b = false;
+                    //Ds = oCn.RunProcReturn("Select HMaterID from Gy_RoutingBillMain Where HMaterID=" + BillNew.omodel.HMaterID.ToString(), "Gy_RoutingBillMain");
+                    //if (Ds.Tables[0].Rows.Count == 0)
+                    //{
                     BillNew.DeleteByMaterID(BillNew.omodel.HMaterID);
                     b = BillNew.AddBill(ref ClsPub.sExeReturnInfo);
                     if (b == false) return;
                     c++;
                     BillNew.CheckBill(BillNew.omodel.HInterID, ref ClsPub.sExeReturnInfo);
-                //}
-                MessageBox.Show("导入完毕:共"+c.ToString()+"个工艺路线");
-                grdMain.DataSource = null;
+                    //}
+                    MessageBox.Show("导入完毕:共" + c.ToString() + "个工艺路线");
+                    grdMain.DataSource = null;
+                }
+                c = 0;
             }
-            c = 0;
+            catch (Exception e)
+            {
+                MessageBox.Show("导入失败!原因:" + e.Message, "提示");
+            }
         }
 
         //写入类 从控件
         private bool WriteClass(int row)
         {
             string sHNumber = "";
-            string sHNamePoc = ""; 
+            string sHNamePoc = "";
             string sHNumberCen = "";
             Single sWorkQty = 0;
             Single sBeginDayQty = 0;
             Single sBeginFixQty = 0;
+            Single sHPassRate = 0;
             //long HItemID = 0; 
             //
-            sHNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[HMaterNumberCol].Value); 
+            sHNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[HMaterNumberCol].Value);
             sHNumberCen = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[HWorkCenterNameCol].Value);
             sHNamePoc = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[HProcNameCol].Value);
 
             sWorkQty = DBUtility.ClsPub.isSingle(grdMain.Rows[row].Cells[HWorkQtyCol].Value);
             sBeginDayQty = DBUtility.ClsPub.isSingle(grdMain.Rows[row].Cells[HBeginDayQtyCol].Value);
             sBeginFixQty = DBUtility.ClsPub.isSingle(grdMain.Rows[row].Cells[HBeginFixQtyCol].Value);
+            sHPassRate = DBUtility.ClsPub.isSingle(grdMain.Rows[row].Cells[HPassRateCol].Value);
             //判断是否允许 保存
- 
-            Model.ClsGy_RoutingBillSub oSub=new Model.ClsGy_RoutingBillSub();
+
+            Model.ClsGy_RoutingBillSub oSub = new Model.ClsGy_RoutingBillSub();
 
             //得到工序内码
             if (oProcHlp.GetInfoByName(sHNamePoc))
@@ -399,20 +423,21 @@
             oSub.HProcNo = DBUtility.ClsPub.isInt(grdMain.Rows[row].Cells[HProcNoCol].Value);
             oSub.HUnitTime = 1;
             oSub.HWorkQty = sWorkQty;
+            oSub.HPassRate = sHPassRate;
             oSub.HRemark = "";
             oSub.HTimeUnit = "小时";
             oSub.HReadyTime = 0;
             oSub.HQueueTime = 0;
             oSub.HMoveTime = 0;
             //
-            
+
             //
             oSub.HCloseMan = "";
             oSub.HCloseType = false;
             oSub.HSourceInterID = 0;
             oSub.HSourceEntryID = 0;
             oSub.HSourceBillType = "";
-            oSub.HSourceBillNo ="";
+            oSub.HSourceBillNo = "";
             oSub.HRelationQty = 0;
             oSub.HRelationMoney = 0;
 
@@ -435,22 +460,39 @@
         //检查物料
         private bool Checkdata()
         {
-            bool b=false;
+            bool b = false;
             string sErrMsg = "";
             string sMsg = "";
             for (int i = 0; i <= grdMain.Rows.Count - 1; i++)
             {
                 string sHNumber = "";
-                string sHNamePoc = ""; 
+                string sHNamePoc = "";
                 string sHNumberCen = "";
-                
+                Single sWorkQty = 0;
+                Single sHPassRate = 0;
+
                 //
                 sHNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HMaterNumberCol].Value);
                 sHNumberCen = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HWorkCenterNameCol].Value);
                 sHNamePoc = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HProcNameCol].Value);
-                if (sHNumber != "" )
+                sWorkQty = DBUtility.ClsPub.isSingle(grdMain.Rows[i].Cells[HWorkQtyCol].Value);
+                sHPassRate = DBUtility.ClsPub.isSingle(grdMain.Rows[i].Cells[HPassRateCol].Value);
+                if (sHNumber != "")
                 {
                     // 
+                    int index = i + 1;
+                    //加工数量不能小于等于零
+                    if (sWorkQty <= 0)
+                    {
+                        MessageBox.Show("第" + index + "行加工数量不能小于等于零!", "提示");
+                        return false;
+                    }
+                    //良率不能小于等于零
+                    if (sHPassRate <= 0)
+                    {
+                        MessageBox.Show("第" + index + "行良率不能小于等于零!", "提示");
+                        return false;
+                    }
                     //审核代码是否合理
                     if (!DBUtility.ClsPub.AllowNumber(sHNumber))
                     {
@@ -462,9 +504,9 @@
                     if (!oMaterHlp.GetInfoByNumber(sHNumber))
                     {
                         sMsg = "[" + sHNumber + "]物料不存在";
-                        if (sErrMsg.Contains(sMsg)==false)
+                        if (sErrMsg.Contains(sMsg) == false)
                         {
-                            sErrMsg = sErrMsg + "[" + sHNumber + "]物料不存在\r\n" ;
+                            sErrMsg = sErrMsg + "[" + sHNumber + "]物料不存在\r\n";
                         }
                         b = true;
                     }
@@ -491,7 +533,7 @@
 
                     }
 
-                }               
+                }
             }
             if (b == true)
             {

--
Gitblit v1.9.1