From d4d2fa248c374ebad4acd363a30b429fb093b701 Mon Sep 17 00:00:00 2001
From: zgq <519541279@qq.com>
Date: 星期一, 16 八月 2021 22:30:09 +0800
Subject: [PATCH] 工艺路线导入失败提示

---
 PlanM/数据导入/Gy_DataIn_RoutingBill.cs |  529 ++++++++++++++++++++++++++++++----------------------------
 1 files changed, 272 insertions(+), 257 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 eb40246..784c1ca 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"
@@ -81,290 +81,305 @@
         //导入
         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);
+            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 (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) != "" )
+                //没有找到列
+                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, "提示"); 
+            }
         }
 
         //写入类 从控件

--
Gitblit v1.9.1