Пример #1
0
        /// <summary>
        ///     提交
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            //  提配错误行数
            var errorRow = -1;

            try
            {
                using (var ts = new TransactionScope())
                {
                    var data = ViewState["dtData"] as DataTable;
                    if (data == null)
                    {
                        return;
                    }

                    for (int i = 0; i < data.Rows.Count; i++)
                    {
                        errorRow = i + 1;

                        var item = new LHSupplier
                        {
                            FCode  = data.Rows[i]["供应商编码"].ToString(),
                            FName  = data.Rows[i]["供应商名称"].ToString(),
                            FSpell = ChineseSpell.MakeSpellCode(data.Rows[i]["供应商名称"].ToString(), "",
                                                                SpellOptions.FirstLetterOnly).ToUpper(),
                            FLinkman = data.Rows[i]["联系人"].ToString(),
                            FPhome   = data.Rows[i]["电话"].ToString(),
                            FMoile   = data.Rows[i]["手机"].ToString(),
                            FAddress = data.Rows[i]["地址"].ToString(),
                            FFreight = Convert.ToDecimal(data.Rows[i]["运输服务费"]),

                            //客户分类
                            FCateId    = "2078",
                            FSubCateId = "2078",

                            FDate      = DateTime.Now,
                            FIsAllot   = 0,
                            FCompanyId = CurrentUser.AccountComId,
                            FFlag      = 1
                        };

                        SupplierService.AddEntity(item);
                    }

                    //写入数据库
                    SupplierService.SaveChanges();

                    ts.Complete();

                    Alert.Show("引入完成。", MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                Alert.Show(string.Format(@"引入失败,请排查模版内容是否完善,出错定位行:{0} ", errorRow), MessageBoxIcon.Information);
            }
        }