From e429f73d834dcc6ffb2fc64ec9350b383b8f94d1 Mon Sep 17 00:00:00 2001
From: yusijie <ysj@hz-kingdee.com>
Date: 星期三, 14 十二月 2022 15:01:45 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 PlanM/数据导入/Gy_DataIn_RoutingBill.cs |  566 ++++++++++++++++++++++++++++----------------------------
 1 files changed, 284 insertions(+), 282 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 91dca73..9f1b7aa 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()
         {
@@ -54,7 +54,7 @@
         {
             base.sSheetName = txtHSheetName.Text;
             return base.OpenExcelData();
-        } 
+        }
 
         /// <summary>
         ///  初始化界面
@@ -62,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;
@@ -81,309 +81,311 @@
         //导入
         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);
-            HPassRateCol = DBUtility.Gy_BaseFun.Fun_GetCol("良率", grdMain);
-
-            //没有找到列
-            if (HMaterNumberCol == -1)
+            try
             {
-                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();
-            }
-            //初始化进度条
-            pb1.Maximum = grdMain.Rows.Count ;
-            pb1.Value = 0;
-            //
-            for (int i = 0; i <= grdMain.Rows.Count - 1; i++)
-            {
-                pb1.Value = i + 1;
-                Application.DoEvents();
+                string hnumber = "";
+                string HBillNo = "";
                 //
-                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) != "" )
+                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)
                 {
-                    //
-                    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++)
+                {
+                    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
-                        {
-                            Application.DoEvents();
-                            BillNew.DeleteByMaterID(BillNew.omodel.HMaterID);
-                            b = BillNew.AddBill(ref ClsPub.sExeReturnInfo);
-                            if (b == false) return;
-                            c++;
-                            BillNew.CheckBill(BillNew.omodel.HInterID, ref ClsPub.sExeReturnInfo);
-                            Application.DoEvents();
-                        }
-
-
-                        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;
+                                }
+                                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);
                             }
+                            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;
-                        //写入类 
-                        Application.DoEvents();
-                        WriteClass(i); 
-                        Application.DoEvents();
+                    }
+                    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);
-                    Application.DoEvents();
-                //}
-                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;
@@ -391,7 +393,7 @@
             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);
 
@@ -401,7 +403,7 @@
             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))
@@ -427,14 +429,14 @@
             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;
 
@@ -457,13 +459,13 @@
         //检查物料
         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;
@@ -474,7 +476,7 @@
                 sHNamePoc = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HProcNameCol].Value);
                 sWorkQty = DBUtility.ClsPub.isSingle(grdMain.Rows[i].Cells[HWorkQtyCol].Value);
                 sHPassRate = DBUtility.ClsPub.isSingle(grdMain.Rows[i].Cells[HPassRateCol].Value);
-                if (sHNumber != "" )
+                if (sHNumber != "")
                 {
                     // 
                     int index = i + 1;
@@ -501,9 +503,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;
                     }
@@ -530,7 +532,7 @@
 
                     }
 
-                }               
+                }
             }
             if (b == true)
             {

--
Gitblit v1.9.1