コード例 #1
0
        public bool Create(ProjectViewModel projectViewModel)
        {
            try
            {   //checking if same project is assigned  for the same sub company,if exists then return false
                List <Project> projectsExist = _mgmtContext.Project.Where(p => p.SubCompany.Id == projectViewModel.SubCompanyId && p.Name == projectViewModel.ProjectName).ToList();

                if (projectsExist.Count() == 1)
                {
                    return(false);
                }
                //checking if same project is assigned for the different sub company , if it exists then return false
                List <Project> duplicatePjt = _mgmtContext.Project.Where(p => p.SubCompany.Id != projectViewModel.SubCompanyId && p.Name == projectViewModel.ProjectName).ToList();

                if (duplicatePjt.Count() == 1)
                {
                    return(false);
                }

                Project project = new Project();
                project.Name = projectViewModel.ProjectName;

                SubCompany subCompany = GetSubCompany(projectViewModel.SubCompanyId);
                project.SubCompany = subCompany;
                _mgmtContext.Add(project);
                _mgmtContext.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Message " + ex.Message);
                return(false);
            }
        }
コード例 #2
0
        public static void TestSubCompany()
        {
            //List<Guid> subCompanyId = new List<Guid>()
            //{
            //    Guid.Parse("5e724e04-335b-c438-002a-810112854f6e"), Guid.Parse("5e724e04-335b-c438-002a-810268666947")
            //    ,Guid.Parse("5e724e04-335b-c438-002a-81031929e6dc")
            //};
            var rps     = fsql.GetRepository <SubCompany>();
            var userRps = fsql.GetRepository <User>();

            for (uint i = 0; i < 50; i++)
            {
                SubCompany s = new SubCompany()
                {
                    Name = $"{DateTime.Now.ToString("s")}_{i}"
                };
                rps.Insert(s);  //内部会将插入后的自增值填充给 blog.Id
                List <User> arr = new List <User>();
                for (int j = 0; j < 5; j++)
                {
                    User user = new User()
                    {
                        SubCompanyId = s.Id, Name = $"{s.Id}___{j}"
                    };
                    userRps.Insert(user);
                    arr.Add(user);
                }
            }
        }
コード例 #3
0
 public ActionResult Edit(SubCompany item, int?projectid)
 {
     if (ModelState.IsValid)
     {
         CH.Edit <SubCompany>(item);
         return(RedirectToAction("Management", "Project", new { id = projectid, tabindex = 3 }));
     }
     return(View(item));
 }
コード例 #4
0
        public IActionResult Create(int?id)
        {
            SubCompany subCompany = new SubCompany();
            Company    company    = _ISubCompany.GetCompany((int)id);

            subCompany.CompanyName = company.Name;
            subCompany._CompanyId  = company.Id;

            return(View(subCompany));
        }
コード例 #5
0
        public IActionResult DeleteConfirmed(int id, int compId)
        {
            SubCompany subCompany = _ISubCompany.GetSubCompany(id);

            if (_ISubCompany.Delete(subCompany))
            {
                return(RedirectToAction("Index", "SubCompany", new { Id = compId }));
            }
            ViewBag.Message = "Unable To Delete.";
            return(View(subCompany));
        }
コード例 #6
0
        public ActionResult AddSubCompany(SubCompanyModel sc)
        {
            var emailList = dbEnt.Users.Select(s => s.Email);
            var nameList  = dbEnt.SubCompany.Select(s => s.Name);

            if (!emailList.Contains(sc.Email) && !nameList.Contains(sc.Name))
            {
                var _acc = (from a in dbEnt.Accounts where a.Users.Email == User.Identity.Name select a.Users).FirstOrDefault();

                SubCompany _scObj = new SubCompany {
                    Name = sc.Name, Street = sc.Street, HouseNumber = sc.HouseNumber, mangeCompany_id = (int)_acc.manageCompany_id
                };
                dbEnt.SubCompany.Add(_scObj);
                dbEnt.SaveChanges();

                Users _usrObj = new Users {
                    FirstName = sc.FirstName, SecondName = sc.SecondName, ThirdName = sc.ThirdName, Email = sc.Email, EmailConfirm = false, subCompany_id = _scObj.id
                };
                dbEnt.Users.Add(_usrObj);
                dbEnt.SaveChanges();

                var   roleList = dbEnt.Roles.Select(r => r.Name);
                Roles _rlobj;
                if (!roleList.Contains("SubCompany"))
                {
                    _rlobj = new Roles {
                        Name = "SubCompany"
                    };
                    dbEnt.Roles.Add(_rlobj);
                    dbEnt.SaveChanges();
                }
                else
                {
                    _rlobj = dbEnt.Roles.Where(r => r.Name == "SubCompany").Select(r => r).FirstOrDefault();
                }

                dbEnt.Accounts.Add(new Accounts {
                    user_id = _usrObj.id, password = ISCityFramework.GetPass(rnd)
                });
                dbEnt.SaveChanges();

                dbEnt.UserRoles.Add(new UserRoles {
                    user_id = _usrObj.id, role_id = _rlobj.id
                });
                dbEnt.SaveChanges();

                ISCityFramework.SendMail(_usrObj, dbEnt);
                return(RedirectToAction("SubCompanyList"));
            }

            ModelState.AddModelError("", "Управляющая коомпания с таким Наименованием или Email уже существует.");
            return(View(sc));
        }
コード例 #7
0
 public IActionResult Create(int id, [Bind("Name,Chief_Executive_Officer,Registered_Date,CompanyName,CompanyId")] SubCompany subCompany)
 {
     if (ModelState.IsValid)
     {
         subCompany.Company = _ISubCompany.GetCompany(id);
         if (_ISubCompany.Create(subCompany))
         {
             return(RedirectToAction("Index", "SubCompany", new { Id = id }));
         }
     }
     ViewBag.Message = "Unable To Create.";
     return(View(subCompany));
 }
コード例 #8
0
ファイル: ODataClient.cs プロジェクト: tibold/ODataWebApi
        public static SubCompany CreateSubCompany(int ID, long revenue, global::WebStack.QA.Test.OData.Singleton.Client.CompanyCategory category, global::WebStack.QA.Test.OData.Singleton.Client.Office office)
        {
            SubCompany subCompany = new SubCompany();

            subCompany.ID       = ID;
            subCompany.Revenue  = revenue;
            subCompany.Category = category;
            if ((office == null))
            {
                throw new global::System.ArgumentNullException("office");
            }
            subCompany.Office = office;
            return(subCompany);
        }
コード例 #9
0
 // on creating makes sure sub company object is associated with company
 public bool Create(SubCompany subCompany)
 {
     try
     {
         _mgmtContext.Add(subCompany);
         _mgmtContext.SaveChanges();
         return(true);
     }
     catch (DbUpdateException due)
     {
         Debug.WriteLine(due.Message);
         return(false);
     }
 }
コード例 #10
0
 public bool Delete(SubCompany subCompany)
 {
     try
     {
         _mgmtContext.Remove(subCompany);
         _mgmtContext.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         Debug.WriteLine("Exception  " + ex.Message);
         return(false);
     }
 }
コード例 #11
0
        public IActionResult Edit(int id, int compId)
        {
            if (id == 0)
            {
                return(NotFound());
            }

            SubCompany subCompany = _ISubCompany.GetSubCompany((int)id);

            if (subCompany == null)
            {
                return(NotFound());
            }

            return(View(subCompany));
        }
コード例 #12
0
        public bool Update(SubCompany subCompany)
        {
            try
            {
                _mgmtContext.Update(subCompany);
                _mgmtContext.SaveChangesAsync();

                return(true);
            }
            catch (InvalidOperationException ioe)
            {
                Debug.WriteLine("Message " + ioe.Message);
                return(false);
            }
            catch (DbUpdateConcurrencyException dce)
            {
                Debug.WriteLine("Message " + dce.Message);
                return(false);
            }
        }
コード例 #13
0
        public IActionResult Edit(int id, int compId, [Bind("Id,Name,Chief_Executive_Officer,Registered_Date")] SubCompany subCompany)
        {
            if (id != subCompany.Id)
            {
                return(NotFound());
            }

            if (compId != _ISubCompany.GetCompany(id).Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                if (_ISubCompany.Update(subCompany))
                {
                    return(RedirectToAction("Index", "SubCompany", new { Id = compId }));
                }
            }
            ViewBag.Message = "Unable To Update.";
            return(View(subCompany));
        }
コード例 #14
0
        /// <summary>
        /// 导入数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void biImporData_Click(object sender, EventArgs e)
        {
            //合并Open\check和Import代码
            OpenFileDialog openFileDialog = new OpenFileDialog()
            {
                Filter = "Microsoft Excel 文件|*.xlsx;*.xls|所有文件|*.*"
            };

            if (openFileDialog.ShowDialog() == DialogResult.OK && !string.IsNullOrEmpty(openFileDialog.FileName))
            {
                string[] SheetNames = ExcelHelper.GetExcelSheetNames(openFileDialog.FileName);
                if (SheetNames != null && SheetNames.Length > 1)//Excel有不只一个sheet,弹出选择窗口
                {
                    FrmSheetsSelecter frmSheetsSelecter = new FrmSheetsSelecter();
                    frmSheetsSelecter.SheetList = SheetNames;
                    if (frmSheetsSelecter.ShowDialog() != DialogResult.Retry)
                    {
                        if (frmSheetsSelecter.SelectedSheetName != "")
                        {
                            dt = ExcelHelper.LoadDataFromExcel(openFileDialog.FileName, frmSheetsSelecter.SelectedSheetName);
                        }
                        else
                        {
                            dt = (DataTable)null;
                            dataGridView1.DataSource = dt;
                            MessageBox.Show("请先选择一个工作簿",
                                            "系统错误",
                                            MessageBoxButtons.OK,
                                            MessageBoxIcon.Stop);
                            return;
                        }
                    }
                }
                else if (SheetNames != null && SheetNames.Length == 1)//只有一个sheet
                {
                    string SelectedSheetName = SheetNames[0];
                    dt = ExcelHelper.LoadDataFromExcel(openFileDialog.FileName, SelectedSheetName);
                }
                else
                {
                    dt = (DataTable)null;
                    dataGridView1.DataSource = dt;
                    MessageBox.Show("打开Excel文件出错!",
                                    "系统错误",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                dt = (DataTable)null;
                dataGridView1.DataSource = dt;
                MessageBox.Show("请先打开Excel文件或者文件出错!",
                                "系统错误",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }

            if (dt != null && dt.Rows.Count > 0)
            {
                ///去掉统计行
                dt.Rows.RemoveAt(index: dt.Rows.Count - 1);
                //绑定、显示数据
                dataGridView1.DataSource = dt;
                //1、检查Excel文件中列完整性
                string ErrMsg = ExcelHelper.ChkColumnsName(new string[] { "单据编号", "日期", "商品长代码", "批号", "单位", "实收数量", "单价", "收料仓库", "基本单位实收数量", "验收", "保管", "制单" }, dt);
                if (ErrMsg == "")
                {
                    //2、检查数据同步情况
                    int ErrCount = checkData(dt);
                    if (ErrCount == 0)
                    {
                        //3、如果检查数据成功就开始导入数据
                        if (SubCompany.ToLower() == "wuhan")
                        {
                            Excel2DB(dt);
                        }
                        else
                        {
                            Excel2DB1(dt);
                        }
                    }
                    else
                    {
                        MessageBoxEx.Show(String.Format("总共测试数据 {0} 行,其中测试失败记录有 {1} 项!", dt.Rows.Count, ErrCount),
                                          "系统提示",
                                          MessageBoxButtons.OK,
                                          MessageBoxIcon.Stop);
                        return;
                    }
                }
                else
                {
                    //dt = (DataTable)null;
                    //dataGridView1.DataSource = dt;
                    MessageBox.Show("请检查Excel文件,不存在的字段有:" + ErrMsg.Substring(0, ErrMsg.Length - 1),
                                    "系统提示",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Stop);
                    return;
                }
            }
            else
            {
                dt = (DataTable)null;
                dataGridView1.DataSource = dt;
                MessageBox.Show(" 打开Excel文件失败或无数据",
                                "系统提示",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Stop);
                return;
            }
        }
コード例 #15
0
        private void biImport_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog()
            {
                Filter = "Microsoft Excel 文件|*.xlsx;*.xls|所有文件|*.*"
            };

            if (openFileDialog.ShowDialog() == DialogResult.OK && !string.IsNullOrEmpty(openFileDialog.FileName))
            {
                string[] SheetNames = ExcelHelper.GetExcelSheetNames(openFileDialog.FileName);
                if (SheetNames != null && SheetNames.Length > 1)//Excel有不只一个sheet,弹出选择窗口
                {
                    FrmSheetsSelecter frmSheetsSelecter = new FrmSheetsSelecter();
                    frmSheetsSelecter.SheetList = SheetNames;
                    if (frmSheetsSelecter.ShowDialog() != DialogResult.Retry)
                    {
                        if (frmSheetsSelecter.SelectedSheetName != "")
                        {
                            dt = ExcelHelper.LoadDataFromExcel(openFileDialog.FileName, frmSheetsSelecter.SelectedSheetName);
                        }
                        else
                        {
                            dt = (DataTable)null;
                            dataGridView1.DataSource = dt;
                            MessageBox.Show("请先选择一个工作簿",
                                            "系统错误",
                                            MessageBoxButtons.OK,
                                            MessageBoxIcon.Stop);
                            return;
                        }
                    }
                }
                else if (SheetNames != null && SheetNames.Length == 1)//只有一个sheet
                {
                    string SelectedSheetName = SheetNames[0];
                    dt = ExcelHelper.LoadDataFromExcel(openFileDialog.FileName, SelectedSheetName);
                }
                else
                {
                    dt = (DataTable)null;
                    dataGridView1.DataSource = dt;
                    MessageBox.Show("打开Excel文件出错!",
                                    "系统错误",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                dt = (DataTable)null;
                dataGridView1.DataSource = dt;
                MessageBox.Show("请先打开Excel文件或者文件出错!",
                                "系统错误",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }

            if (dt != null && dt.Rows.Count > 0)
            {
                ///去掉统计行
                dt.Rows.RemoveAt(index: dt.Rows.Count - 1);
                //绑定、显示数据
                dataGridView1.DataSource = dt;
                //1、检查Excel文件中列完整性
                string[] whColumns = new string[] {
                    "单据编号", "日期", "发货仓库", "销售单价", "购货单位代码", "订单号", "基本单位实发数量",
                    "进货单号", "验收单号", "订单日期", "交货日期", "审核日期A", "产品长代码",
                    "实发数量", "销售单价", "销售金额", "批号", "单位", "F件数", "F含量",
                    "F细数", "F赠品", "F税率", "F未税金额", "F价税合计", "F保质日期", "F生产日期",
                    "F单位", "F规格", "F商品", "F包装", "F箱数", "F零头", "F税额", "F售价"
                };
                string[] jzColumns = new string[] {
                    "单据编号", "日期", "发货仓库", "销售单价", "购货单位代码", "订单号", "基本单位实发数量",
                    "产品长代码", "实发数量", "销售单价", "销售金额", "批号", "单位"
                };
                string[] chkColumn = SubCompany.ToLower() == "wuhan" ? whColumns : jzColumns;
                string   ErrMsg    = ExcelHelper.ChkColumnsName(chkColumn, dt);
                if (ErrMsg == "")
                {
                    //2、检查数据完整性
                    int ErrCount = checkData(dt);
                    if (ErrCount == 0)
                    {
                        //3、导入数据
                        if (SubCompany.ToLower() == "wuhan")
                        {
                            Excel2DB(dt);
                        }
                        else
                        {
                            Excel2DB1(dt);
                        }
                    }
                    else
                    {
                        MessageBoxEx.Show(String.Format("总共测试数据 {0} 行,其中测试失败记录有 {1} 项!", dt.Rows.Count, ErrCount),
                                          "系统提示",
                                          MessageBoxButtons.OK,
                                          MessageBoxIcon.Stop);
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("请检查Excel文件,不存在的字段有:" + ErrMsg.Substring(0, ErrMsg.Length - 1),
                                    "系统提示",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Stop);
                    return;
                }
            }
            else
            {
                dt = (DataTable)null;
                dataGridView1.DataSource = dt;
                MessageBox.Show(" 打开Excel文件失败或无数据",
                                "系统提示",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Stop);
                return;
            }
        }
コード例 #16
0
ファイル: ODataClient.cs プロジェクト: ZhaoYngTest01/WebApi
 public static SubCompany CreateSubCompany(int ID, long revenue, global::WebStack.QA.Test.OData.Singleton.Client.CompanyCategory category, global::WebStack.QA.Test.OData.Singleton.Client.Office office)
 {
     SubCompany subCompany = new SubCompany();
     subCompany.ID = ID;
     subCompany.Revenue = revenue;
     subCompany.Category = category;
     if ((office == null))
     {
         throw new global::System.ArgumentNullException("office");
     }
     subCompany.Office = office;
     return subCompany;
 }
コード例 #17
0
        /// <summary>
        /// 宜昌襄樊分公司导入
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        private bool Excel2DB1(DataTable dt)
        {
            string fBillNo = "";       // 主键列
            //int fInterID = 0;//内联ID,外键列
            int fEntryID          = 0; //明细表记录行号
            int successCount      = 0; //成功完成导入的个数
            int iSuccessBillCount = 0;
            //string fBillNo = "";//金蝶收货单号
            bool retVal = false;
            ICStockBillService      bICStockBill      = new ICStockBillService();
            ICStockBillEntryService bICStockBillEntry = new ICStockBillEntryService();


            for (int i = 0; i < dt.Rows.Count; i++)
            {
                ICStockBill mICStockBill = new ICStockBill();

                //商品代码
                int fItemID = bICStockBillEntry.GetfItemId(sConnectionString, dt.Rows[i]["商品长代码"].ToString());
                if (fItemID > 0)
                {
                    if (fBillNo != dt.Rows[i]["单据编号"].ToString())
                    {
                        //单据号
                        mICStockBill.FBillNo = dt.Rows[i]["单据编号"].ToString();
                        fBillNo = mICStockBill.FBillNo;
                        //内联编号
                        ///fInterID  = bICStockBill.GetMaxFInterID(sConnectionString);
                        bICStockBill.UpdateFInterID(sConnectionString);
                        mICStockBill.FInterID = bICStockBill.GetMaxFInterID(sConnectionString);

                        //fROB
                        mICStockBill.FROB = decimal.Parse(dt.Rows[i]["实收数量"].ToString()) > 0 ? 1 : -1;
                        //日期
                        mICStockBill.FDate = DateTime.Parse(dt.Rows[i]["日期"].ToString());
                        //单据类型
                        mICStockBill.FTranType = 1;

                        if (SubCompany.ToLower() == "yichang")
                        {
                            mICStockBill.FSupplyID   = 4478;//武汉友谊
                            mICStockBill.FFManagerID = 4175;
                            mICStockBill.FSManagerID = 4174;
                            mICStockBill.FBillerID   = 16394;
                        }
                        else if (SubCompany.ToLower() == "xiangfan") //
                        {
                            mICStockBill.FSupplyID   = 198;          //武汉友谊
                            mICStockBill.FFManagerID = 4128;
                            mICStockBill.FSManagerID = 4128;
                            mICStockBill.FBillerID   = 16394;
                        }
                        else //jingzhou
                        {
                            mICStockBill.FSupplyID   = 198;//武汉友谊
                            mICStockBill.FFManagerID = 4395;
                            mICStockBill.FSManagerID = 4395;
                            mICStockBill.FBillerID   = 16394;
                        }


                        ///if (InsertStockBill(sConnectionString, fInterID, fBillNo, fdate, frob) == true && bStockBill.UpdateFInterID(sConnectionString) == true && bStockBill.UpdateFBillNo(sConnectionString,iBillNo + 1, "WIN+" + iBillNo.ToString().PadLeft(6, '0'), 1) == true)
                        try
                        {
                            retVal = bICStockBill.Add(sConnectionString, mICStockBill);
                            //bICStockBill.UpdateFInterID(sConnectionString);
                        }
                        catch (Exception ex)
                        {
                            MessageBoxEx.Show(this, "导入主表数据失败:" + ex.Message, "系统信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        finally
                        {
                            if (retVal == true)
                            {
                                fEntryID = 1;
                                iSuccessBillCount++;
                            }
                        }
                    }

                    ICStockBillEntry mICStockBillEntry = new ICStockBillEntry();
                    //SetPropertyDefaultValue4Detail(mICStockBillEntry);
                    ///内联ID
                    mICStockBillEntry.FInterID = bICStockBill.GetMaxFInterID(sConnectionString);
                    //数量
                    mICStockBillEntry.FQty = decimal.Parse(dt.Rows[i]["基本单位实收数量"].ToString());
                    //金额
                    mICStockBillEntry.FAmount = decimal.Parse(dt.Rows[i]["金额"].ToString());
                    //价格
                    mICStockBillEntry.FPrice = mICStockBillEntry.FAmount / mICStockBillEntry.FQty;
                    //仓库ID
                    mICStockBillEntry.FDCStockID = bICStockBill.GetStockId(sConnectionString, dt.Rows[i]["收料仓库"].ToString());
                    //批号
                    mICStockBillEntry.FBatchNo = dt.Rows[i]["批号"].ToString();
                    //单位编号
                    mICStockBillEntry.FUnitID = bICStockBillEntry.GetUnitID(sConnectionString, dt.Rows[i]["单位"].ToString());//单位ID
                    //商品编号
                    mICStockBillEntry.FItemID = fItemID;
                    //输入单价
                    mICStockBillEntry.FAuxPrice = decimal.Parse(dt.Rows[i]["单价"].ToString());
                    //输入数量
                    mICStockBillEntry.FAuxQty = decimal.Parse(dt.Rows[i]["实收数量"].ToString());
                    //条目序号
                    mICStockBillEntry.FEntryID = fEntryID;
                    //销售单价
                    mICStockBillEntry.FConsignPrice = 0;
                    //销售金额
                    mICStockBillEntry.FConsignAmount = 0;

                    ///mICStockBillEntry.FEntrySelfB0159 = 0;
                    ///mICStockBillEntry.FEntrySelfB0161 = "";
                    ///mICStockBillEntry.FEntrySelfB0162 = 0;
                    ///mICStockBillEntry.FEntrySelfB0163 = 0;
                    ///mICStockBillEntry.FEntrySelfB0166 = "";
                    ///mICStockBillEntry.FEntrySelfB0167 = "";
                    ///mICStockBillEntry.FEntrySelfB0168 = "";
                    ///mICStockBillEntry.FEntrySelfB0169 = "";
                    ///mICStockBillEntry.FEntrySelfB0170 = 0;
                    ///mICStockBillEntry.FEntrySelfB0172 = 0;
                    ///mICStockBillEntry.FEntrySelfB0171 = "";
                    ///mICStockBillEntry.FEntrySelfB0163 = 0;
                    ///mICStockBillEntry.FEntrySelfB0173 = 0;
                    ///mICStockBillEntry.FEntrySelfB0174 = 0;
                    ///mICStockBillEntry.FEntrySelfB0158 = "";
                    ///mICStockBillEntry.FEntrySelfB0163 = 0;
                    ///mICStockBillEntry.FEntrySelfB0159 = 0;

                    //写Detail表
                    try
                    {
                        retVal = bICStockBillEntry.Add(sConnectionString, mICStockBillEntry);
                    }
                    catch (Exception ex)
                    {
                        MessageBoxEx.Show(this, "导入明细表数据失败:" + ex.Message, "系统信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    finally
                    {
                        if (retVal == true)
                        {
                            fEntryID++;
                            successCount++;
                        }
                    }
                }
                else
                {
                    MessageBox.Show(dt.Rows[i]["商品长代码"].ToString() + "商品编号不存在!");
                    dataGridView1.Rows[i].Selected = true;
                }
            }

            MessageBox.Show("总共有 " + dt.Rows.Count.ToString() + " 条记录," + "导入失败 " + (dt.Rows.Count - successCount).ToString() + " 条!");

            return(retVal);
        }