protected void setup1_Click(object sender, EventArgs e) { //排除DELETE删除的空行 DataTable dt = ds.Tables[0]; for (int i = dt.Rows.Count - 1; i >= 0; i--) { if (dt.Rows[i].RowState != DataRowState.Deleted) { for (int f = 0; f > 30; f++) { if (dt.Rows[i][f].ToString().Trim() != "") { return; } else { dt.Rows[i].Delete(); } } } } dt.AcceptChanges(); string suberrorstr = string.Empty; int j = 0;//定义错误列表序号 errorstr = string.Empty; string[] code = { "序号", "客户编号", "客户名称" }; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { for (int k = 0; k < code.Length; k++) { if (ds.Tables[0].Rows[i][code[k]].ToString().Trim().Length < 1) { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的 " + code[k] + " 值不能为空值,导入操作失败!<br>"; } } } if (j > 0) { errorstr = "<strong>空值校验错误列表</strong><br>"; errorstr += suberrorstr; this.setup1.Enabled = false; this.tr_result.Visible = true; if (Session["newfile"] != null) { ProductInfoBus.DeleteFile(userinfo.CompanyCD, Session["newfile"].ToString()); ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, errorstr); } } else { this.tr_result.Visible = false; this.setup1.Enabled = false; this.setup2.Enabled = true; } }
/// <summary> /// 长度判断 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void setup3_Click(object sender, EventArgs e) { //3.长度判断 string suberrorstr = string.Empty; errorstr = string.Empty; string[] code = { "分店名称", "物品编号", "现有存量", "批次" }; int[] codelen = { 50, 50, 9, 50 }; for (int i = 0; i < dt.Rows.Count; i++) { for (int k = 0; k < code.Length; k++) { if (dt.Rows[i][code[k]].ToString().Trim().Length > codelen[k]) { suberrorstr += string.Format("第{0}行中的 {1} 数据长度过长,导入操作失败!<br>", i + 2, code[k]); } } } if (suberrorstr.Length > 0) { errorstr = "<strong>数据长度校验错误列表</strong><br>"; errorstr += suberrorstr; this.tr_result.Visible = true; ProductInfoBus.LogInsert(UserInfo.CompanyCD, UserInfo.DeptID, UserInfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, errorstr); } else { this.tr_result.Visible = false; this.setup3.Enabled = false; this.setup4.Enabled = true; } }
/// <summary> /// 判断是否为实数 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void setup4_Click(object sender, EventArgs e) { //4.判断是否为实数 string suberrorstr = string.Empty; errorstr = string.Empty; decimal dec = 0m; string[] code = { "现有存量" }; for (int i = 0; i < dt.Rows.Count; i++) { if (!decimal.TryParse(dt.Rows[i][code[0]].ToString(), out dec)) { suberrorstr += string.Format("第{0}行中的 {1} 格式应该为数值,导入操作失败!<br>", i + 2, code[0]); } } if (suberrorstr.Length > 0) { errorstr = "<strong>数据格式校验错误列表(数据类型和范围)</strong><br>"; errorstr += suberrorstr; this.tr_result.Visible = true; ProductInfoBus.LogInsert(UserInfo.CompanyCD, UserInfo.DeptID, UserInfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, errorstr); } else { this.tr_result.Visible = false; this.setup4.Enabled = false; this.setup6.Enabled = true; } }
protected void btn_input_Click(object sender, EventArgs e) { try { if (userinfo.EmployeeID.ToString().Length < 1 || userinfo.UserID.Length < 1) { ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, this.lbl_result.Text); this.lbl_jg.Text = "该用户没有分配为雇员,导入失败!"; } else { DataTable dt = ds.Tables[0]; if (CustInfoBus.InsertCustInfoRecord(dt, userinfo.CompanyCD, userinfo.EmployeeID.ToString(), userinfo.UserID)) { ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), ds.Tables[0].Rows.Count, 1, "客户档案导入成功!"); this.lbl_jg.Text = "Excel数据导入成功"; } if (Session["newfile"] != null) { ProductInfoBus.DeleteFile(userinfo.CompanyCD, Session["newfile"].ToString()); } } this.tab_end.Visible = true; btn_input.Enabled = false; } catch (Exception ex) { ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, this.lbl_result.Text); btn_input.Enabled = true; this.tab_end.Visible = true; this.lbl_jg.Text = ex.Message; } }
/// <summary> /// 空值验证 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void setup2_Click(object sender, EventArgs e) { string suberrorstr = string.Empty; errorstr = string.Empty; for (int i = 0; i < dt.Rows.Count; i++) { if (String.IsNullOrEmpty(dt.Rows[i]["分店名称"].ToString())) { suberrorstr += string.Format("第{0}行分店名称不能为空,导入操作失败!<br>", i + 2); } if (String.IsNullOrEmpty(dt.Rows[i]["物品编号"].ToString())) { suberrorstr += string.Format("第{0}行物品编号不能为空,导入操作失败!<br>", i + 2); } } if (suberrorstr.Length > 0) { errorstr = "<strong>空值校验错误列表</strong><br>"; errorstr += suberrorstr; this.tr_result.Visible = true; ProductInfoBus.LogInsert(UserInfo.CompanyCD, UserInfo.DeptID, UserInfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, errorstr); } else { this.tr_result.Visible = false; this.setup2.Enabled = false; this.setup3.Enabled = true; } }
protected void btn_input_Click(object sender, EventArgs e) { try { if (userinfo.EmployeeID.ToString().Length < 1) { this.lbl_jg.Text = "该用户没有分配为雇员,导入失败!"; } else { int num = ProductInfoBus.GetExcelToProductInfo(userinfo.CompanyCD, userinfo.EmployeeID.ToString()); this.lbl_jg.Text = "Excel数据导入成功"; if (Session["newfile"] != null) { ProductInfoBus.DeleteFile(userinfo.CompanyCD, Session["newfile"].ToString()); } ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), ds.Tables[0].Rows.Count, 1, "成功导入" + ds.Tables[0].Rows.Count.ToString() + "条数据"); } this.tab_end.Visible = true; btn_input.Enabled = false; } catch (Exception ex) { btn_input.Enabled = true; this.tab_end.Visible = true; this.lbl_jg.Text = ex.Message; ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, this.lbl_jg.Text); } }
protected void setup5_Click(object sender, EventArgs e) { string suberrorstr = string.Empty; int j = 0; //定义错误列表序号 int total = 0; //总错误记录 errorstr = string.Empty; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { bool flag = ProductInfoBus.ChargeProduct("ProdNo", ds.Tables[0].Rows[i]["物品编号"].ToString().Trim(), userinfo.CompanyCD); //1、判断物品编号是否存在 if (flag) { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的物品编号已经存在,导入操作失败!<br>"; } } if (j > 0) { total += j; errorstr = "<strong>数据存在校验(物品编号)</strong><br>"; errorstr += suberrorstr; suberrorstr = string.Empty; } //2、判断物品名称是否存在 //j = 0; //for (int i = 0; i < ds.Tables[0].Rows.Count; i++) //{ // bool flag = ProductInfoBus.ChargeProduct("ProductName", ds.Tables[0].Rows[i]["物品名称"].ToString().Trim(), userinfo.CompanyCD); // if (flag) // { // suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的物品名称已经存在,导入操作失败!<br>"; // } //} //if (j > 0) //{ // total = +j; // errorstr += "<strong>数据存在校验(物品名称)</strong><br>"; // errorstr += suberrorstr; // suberrorstr = string.Empty; //} if (total > 0) { this.tr_result.Visible = true; if (Session["newfile"] != null) { ProductInfoBus.DeleteFile(userinfo.CompanyCD, Session["newfile"].ToString()); } ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, errorstr); } else { this.tr_result.Visible = false; this.setup5.Enabled = false; this.setup6.Enabled = true; } }
protected void btn_input_Click(object sender, EventArgs e) { try { if (UserInfo.EmployeeID.ToString().Length < 1) { this.lbl_jg.Text = "该用户没有分配为雇员,导入失败!"; } else { SubStorageBus.ImportData(dt, UserInfo); this.lbl_jg.Text = "Excel数据导入成功"; } this.tab_end.Visible = true; btn_input.Enabled = false; ProductInfoBus.LogInsert(UserInfo.CompanyCD, UserInfo.DeptID, UserInfo.UserID, Request.QueryString["ModuleID"].ToString(), dt.Rows.Count, 1, "成功导入" + dt.Rows.Count.ToString() + "条数据"); } catch (Exception ex) { btn_input.Enabled = true; this.tab_end.Visible = true; this.lbl_jg.Text = ex.Message; ProductInfoBus.LogInsert(UserInfo.CompanyCD, UserInfo.DeptID, UserInfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, this.lbl_jg.Text); } }
protected void Page_Load(object sender, EventArgs e) { btn_back.Attributes.Add("onclick", "window.close()"); DataSet ds = ProductInfoBus.GetError(Request.QueryString["getid"].ToString()); this.lbl_result.Text = ds.Tables[0].Rows[0]["ExportError"].ToString(); }
protected void btn_excel_Click(object sender, EventArgs e) { if (this.upExcelFile.PostedFile.FileName.Length > 0) { this.initState(); } else { this.lbl_upresult.Text = "请选择要上传的Excel文件!"; return; } string filename = upExcelFile.PostedFile.FileName; string subfile = filename.Substring(filename.LastIndexOf(".") + 1); if (subfile.ToUpper() != "XLS" && subfile.ToUpper() != "XLSX") { this.lbl_upresult.Text = "导入文件格式错误,必须为XLS,XLSX格式!"; ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, this.lbl_upresult.Text); } else { try { //获取企业上传文件路径 string upfilepath = ProductInfoBus.GetCompanyUpFilePath(userinfo.CompanyCD);//得到格式如:"D:\zhou" //获取企业并构造企业上传文件名称 Session["newfile"] = DateTime.Now.ToString("yyyyMMddhhmmss") + filename.Substring(filename.LastIndexOf("\\") + 1); //Session["newfile"] = "HR_ZHOU.xls"; upExcelFile.PostedFile.SaveAs(upfilepath + @"\" + Session["newfile"].ToString()); this.lbl_upresult.Text = "Excel文件上传成功!"; this.setup1.Enabled = true; //将excel中的数据读取到ds中 try { ds = EmployeeInfoBus.ReadEexcel(upfilepath + @"\" + Session["newfile"].ToString(), userinfo.CompanyCD); if (ds.Tables[0].Rows.Count < 1) { initState(); this.lbl_upresult.Text = "您导入的Excel表没有数据!"; return; } } catch (Exception ex) { initState(); this.lbl_upresult.Text = "数据读取失败,原因:" + ex.Message; ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, this.lbl_upresult.Text); } } catch (Exception ex) { this.setup1.Enabled = false; this.lbl_upresult.Text = "数据读取失败,原因:" + ex.Message; ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, this.lbl_upresult.Text); } } }
protected void initState() { lbl_upresult.Text = string.Empty; errorstr = string.Empty; setup1.Enabled = false; setup2.Enabled = false; setup3.Enabled = false; btn_input.Enabled = false; setup4.Enabled = false; lbl_validateend.Visible = false; tab_end.Visible = false; tr_result.Visible = false; tab_end.Visible = false; if (Session["newfile"] != null) { ProductInfoBus.DeleteFile(userinfo.CompanyCD, Session["newfile"].ToString()); } }
protected void setup3_Click(object sender, EventArgs e) { string suberrorstr = string.Empty; int j = 0; //定义错误列表序号 int m = 0; //定义单价格式错误序号 string priceError = string.Empty; //定义单价格式错记录 for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { try { Single.Parse(ds.Tables[0].Rows[i]["现有存量"].ToString().Trim()); } catch { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的 现有存量 格式应该为整数,导入操作失败!<br>"; } try { decimal tmpPrice = Convert.ToDecimal(ds.Tables[0].Rows[i]["单价"].ToString().Trim()); } catch { priceError += (++m).ToString() + ": " + "第" + (i + 2).ToString() + "行中的 单价 格式错误,导入操作失败!<br>"; } } if (j > 0 || m > 0) { errorstr = "<strong>数据格式校验错误列表</strong><br>"; if (j > 0) { errorstr += suberrorstr; } if (m > 0) { errorstr += priceError; } this.tr_result.Visible = true; if (Session["newfile"] != null) { ProductInfoBus.DeleteFile(userinfo.CompanyCD, Session["newfile"].ToString()); } ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, errorstr); } else { this.tr_result.Visible = false; this.setup3.Enabled = false; this.setup4.Enabled = true; //lbl_validateend.Visible = true; //this.btn_input.Enabled = true; } }
protected void setup3_Click(object sender, EventArgs e) { string suberrorstr = string.Empty; errorstr = string.Empty; int j = 0;//定义错误列表序号 int k = 0; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["客户编号"].ToString().Length > 0) { string[] arr = new string[] { "CustNo", "CompanyCD" }; string[] CustNos = new string[] { ds.Tables[0].Rows[i]["客户编号"].ToString().Trim(), userinfo.CompanyCD }; bool NoHas = XBase.Business.Common.PrimekeyVerifyDBHelper.PrimekeyVerifytc("officedba.CustInfo", arr, CustNos); if (NoHas) { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的客户编号与数据库中记录重复,导入操作失败!<br>"; } } if (ds.Tables[0].Rows[i]["客户名称"].ToString().Length > 0) { string[] arr = new string[] { "CustName", "CompanyCD" }; string[] CustNames = new string[] { ds.Tables[0].Rows[i]["客户名称"].ToString().Trim(), userinfo.CompanyCD }; bool NameHas = XBase.Business.Common.PrimekeyVerifyDBHelper.PrimekeyVerifytc("officedba.CustInfo", arr, CustNames); if (NameHas) { suberrorstr += (++k).ToString() + ": " + "第" + (i + 2).ToString() + "行中的客户名称与数据库中记录重复,导入操作失败!<br>"; } } } if (j > 0 || k > 0) { errorstr += "<strong>是否存在校验错误列表(客户编号,名称)</strong><br>"; errorstr += suberrorstr; if (Session["newfile"] != null) { ProductInfoBus.DeleteFile(userinfo.CompanyCD, Session["newfile"].ToString()); } ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, errorstr); this.tr_result.Visible = true; this.setup3.Enabled = false; } else { this.tr_result.Visible = false; this.setup3.Enabled = false; this.setup4.Enabled = true; } }
protected void setup7_Click(object sender, EventArgs e) { string suberrorstr = string.Empty; errorstr = string.Empty; int j = 0;//定义错误列表序号 string[] code = { "注册资本(万元)", "资产规模(万元)", "年销售额(万元)", "员工总数(个)" }; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { for (int k = 0; k < code.Length; k++) { try { if (ds.Tables[0].Rows[i][code[k]].ToString().Length > 0) { if (k == 3) { Convert.ToInt32(ds.Tables[0].Rows[i][code[k]].ToString().Trim()); } else { Convert.ToDecimal(ds.Tables[0].Rows[i][code[k]].ToString().Trim()); //decimal.Round(decimal.Parse(ds.Tables[0].Rows[i][code[k]].ToString().Trim()), 2); } } } catch { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的 " + code[k] + " 格式错误,导入操作失败!<br>"; } } } if (j > 0) { errorstr = "<strong>数字格式校验错误列表</strong><br>"; errorstr += suberrorstr; this.tr_result.Visible = true; this.setup7.Enabled = false; if (Session["newfile"] != null) { ProductInfoBus.DeleteFile(userinfo.CompanyCD, Session["newfile"].ToString()); ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, errorstr); } } else { this.tr_result.Visible = false; this.setup7.Enabled = false; this.setup8.Enabled = true; } }
protected void initvalidate() { this.lbl_validateend.Visible = false; lbl_jg.Text = string.Empty; this.lbl_result.Text = string.Empty; errorstr = string.Empty; if (Session["newfile"] != null) { ProductInfoBus.DeleteFile(userinfo.CompanyCD, Session["newfile"].ToString()); } }
protected void btnImport_Click(object sender, ImageClickEventArgs e) { ProductInfoModel model = new ProductInfoModel(); model.ProdNo = txt_ProdNo.Value; model.ProductName = txt_ProductName.Text; model.TypeID = txt_ID.Value; model.UsedStatus = UsedStatus.Value; model.PYShort = txt_PYShort.Value; model.Specification = txt_Specification.Value; model.BarCode = this.HiddenBarCode.Value; model.CheckStatus = CheckStatus.Value; model.CompanyCD = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyCD; string EFIndex = HdselEFIndex.Value; string EFDesc = HdtxtEFDesc.Value; //string ProductDiyAttr2= int totalCount = 0; DataTable dt = ProductInfoBus.GetProductInfo(model, EFIndex, EFDesc, 1, 1000000, "ID desc", ref totalCount); //导出标题 string headerTitle = "物品编号|物品名称|拼音缩写|名称简称|条码|物品分类|基本单位|所属大类|" + "计量单位组|规格型号|采购计量单位|颜色|销售计量单位|品牌|库存计量单位|档次级别|" + "生产计量单位|尺寸|是否启用批次|ABC分类|成本核算计价方法|标准成本(元)|去税售价(元)|" + "销项税率(%)|含税售价(元)|零售价(元)|销售折扣率(%)|调拨单价(元)|去税进价(元)| 进项税率(%)|" + "含税进价(元)|是否计入库存|是否允许负库存|主放仓库|安全库存量|最低库存量|最高库存量|" + "物品来源分类|产地|图号|启用状态|批准文号|价格策略|技术参数|常见问题|替代品名称|" + "物品描述信息|厂家|材质|建档时间|建档人|审核状态|最后更新日期|" + "最后更新用户"; //string headerTitle = "建档日期|启用状态"; string[] header = headerTitle.Split('|'); //导出标题所对应的列字段名称 string columnFiled = "ProdNo|ProductName|PYShort|ShortNam|BarCode|TypeName|UnitName|BigType|" + "GroupUnitName|Specification|InUnitName|ColorName|SaleUnitName|BrandName|StockUnitName|GradeName|" + "MakeUnitName|Size|IsBatchNo|ABCType|CalcPriceWays|StandardCost|StandardSell|" + "TaxRate|SellTax|SellPrice|Discount|TransferPrice|TaxBuy|InTaxRate|" + "StandardBuy|StockIs|MinusIs|StorageName|SafeStockNum|MinStockNum|MaxStockNum|" + "Source|FromAddr|DrawingNum|UsedStatus|FileNo|PricePolicy|Params|Questions|ReplaceName|" + "Description|Manufacturer|MaterialName|CreateDate|EmployeeName|CheckStatus|ModifiedDate|" + "ModifiedUserID"; //string columnFiled = "CreateDate|strUsedStatus"; string[] field = columnFiled.Split('|'); XBase.Common.OutputToExecl.ExportToTable(this.Page, dt, header, field, "物品档案列表"); }
protected void setup9_Click(object sender, EventArgs e) { string suberrorstr = string.Empty; errorstr = string.Empty; int j = 0;//定义错误列表序号 DataColumn AreaID = new DataColumn(); ds.Tables[0].Columns.Add("AreaID"); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["区域"].ToString().Trim().Length > 0) { DataTable dt = CustInfoBus.CheckArea(ds.Tables[0].Rows[i]["区域"].ToString().Trim(), userinfo.CompanyCD); if (dt.Rows.Count < 1) { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的区域与系统的区域不匹配,导入操作失败!<br>"; } else { ds.Tables[0].Rows[i]["AreaID"] = dt.Rows[0]["ID"].ToString(); } } } if (j > 0) { errorstr = "<strong>与系统的区域匹配式校验错误列表</strong><br>"; errorstr += suberrorstr; this.tr_result.Visible = true; this.setup5.Enabled = false; if (Session["newfile"] != null) { ProductInfoBus.DeleteFile(userinfo.CompanyCD, Session["newfile"].ToString()); ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, errorstr); } } else { this.tr_result.Visible = false; this.setup9.Enabled = false; this.btn_input.Enabled = true; lbl_validateend.Visible = true; } }
protected void setup5_Click(object sender, EventArgs e) { string suberrorstr = string.Empty; errorstr = string.Empty; int j = 0;//定义错误列表序号 DataColumn Manager = new DataColumn(); ds.Tables[0].Columns.Add("Manager"); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["人员编号"].ToString().Trim().Length > 0 && ds.Tables[0].Rows[i]["分管业务员"].ToString().Trim().Length > 0) { DataTable dt = EmployeeInfoDBHelper.IsHaveEmployeesByEmployeeNOAndName(ds.Tables[0].Rows[i]["分管业务员"].ToString().Trim(), ds.Tables[0].Rows[i]["人员编号"].ToString().Trim(), userinfo.CompanyCD); if (dt.Rows.Count < 1) { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的分管业务员与对应的人员编号不匹配,导入操作失败!<br>"; } else { ds.Tables[0].Rows[i]["Manager"] = dt.Rows[0]["ID"].ToString(); } } } if (j > 0) { errorstr = "<strong>人员与人员编号匹配式校验错误列表</strong><br>"; errorstr += suberrorstr; this.tr_result.Visible = true; this.setup5.Enabled = false; if (Session["newfile"] != null) { ProductInfoBus.DeleteFile(userinfo.CompanyCD, Session["newfile"].ToString()); ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, errorstr); } } else { this.tr_result.Visible = false; this.setup5.Enabled = false; this.setup7.Enabled = true; } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { txtOpenDate.Value = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"); txtCloseDate.Value = DateTime.Now.ToString("yyyy-MM-dd"); } lbl_title.Text = ProductInfoBus.GetLogTitle(Request.QueryString["ModuleID"].ToString()) + "列表"; BindUserTree(); //获取查询版块 try { string mod = string.Empty; this.btn_mod.Value = Convert.ToString(Convert.ToInt32(Request.QueryString["ModuleID"].ToString()) - 1); } catch { } }
protected void setup4_Click(object sender, EventArgs e) { string suberrorstr = string.Empty; errorstr = string.Empty; int j = 0;//定义错误列表序号 string[] code = { "成立时间" }; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { for (int k = 0; k < code.Length; k++) { try { if (ds.Tables[0].Rows[i][code[k]].ToString().Length > 0) { DateTime.Parse(ds.Tables[0].Rows[i][code[k]].ToString().Trim()); } } catch { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的 " + code[k] + " 格式错误,导入操作失败!<br>"; } } } if (j > 0) { errorstr = "<strong>日期时间格式校验错误列表</strong><br>"; errorstr += suberrorstr; this.tr_result.Visible = true; this.setup4.Enabled = false; if (Session["newfile"] != null) { ProductInfoBus.DeleteFile(userinfo.CompanyCD, Session["newfile"].ToString()); ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, errorstr); } } else { this.tr_result.Visible = false; this.setup4.Enabled = false; this.setup5.Enabled = true; } }
protected void setup4_Click(object sender, EventArgs e) { string suberrorstr = string.Empty; int j = 0;//定义错误列表序号 //判断记录是否重复 string firststr = string.Empty; string nextstr = string.Empty; #region//总店(判断:批次+仓库+商品+单价) for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { firststr = ds.Tables[0].Rows[i]["批次"].ToString().Trim() + ds.Tables[0].Rows[i]["仓库"].ToString().Trim() + ds.Tables[0].Rows[i]["物品编号"].ToString().Trim() + ds.Tables[0].Rows[i]["单价"].ToString().Trim(); for (int k = i + 1; k < ds.Tables[0].Rows.Count; k++) { nextstr = ds.Tables[0].Rows[k]["批次"].ToString().Trim() + ds.Tables[0].Rows[k]["仓库"].ToString().Trim() + ds.Tables[0].Rows[k]["物品编号"].ToString().Trim() + ds.Tables[0].Rows[i]["单价"].ToString().Trim(); if (firststr == nextstr) { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行与" + "第" + (k + 2).ToString() + "行重复,导入操作失败!<br>"; } } } if (j > 0) { errorstr = "<strong>记录重复校验错误列表</strong><br>"; errorstr += suberrorstr; this.tr_result.Visible = true; if (Session["newfile"] != null) { ProductInfoBus.DeleteFile(userinfo.CompanyCD, Session["newfile"].ToString()); } ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, errorstr); } else { this.tr_result.Visible = false; this.setup4.Enabled = false; lbl_validateend.Visible = true; this.btn_input.Enabled = true; } #endregion }
protected void setup6_Click(object sender, EventArgs e) { string suberrorstr = string.Empty; errorstr = string.Empty; var temp = from d in dt.AsEnumerable() group d by d.Field <object>("分店名称") into g select g; foreach (var item in temp) { if (!SubProductSendPriceBus.ExisitDeptName(UserInfo.CompanyCD, item.Key.ToString().Trim())) { suberrorstr += string.Format(" {0} 分店不存在,导入操作失败!<br>", item.Key); } } temp = from d in dt.AsEnumerable() group d by d.Field <object>("物品编号") into g select g; foreach (var item in temp) { if (!SubProductSendPriceBus.ExisitProdNo(UserInfo.CompanyCD, item.Key.ToString().Trim())) { suberrorstr += string.Format(" {0} 物品编号不存在,导入操作失败!<br>", item.Key); } } if (suberrorstr.Length > 0) { errorstr = "<strong>数据存在校验错误列表</strong><br>"; errorstr += suberrorstr; this.tr_result.Visible = true; ProductInfoBus.LogInsert(UserInfo.CompanyCD, UserInfo.DeptID, UserInfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, errorstr); } else { this.tr_result.Visible = false; this.setup6.Enabled = false; lbl_end.Visible = true; this.btn_input.Enabled = true; } }
protected void btn_input_Click(object sender, EventArgs e) { try { userinfo = (UserInfoUtil)SessionUtil.Session["UserInfo"]; EmployeeInfoBus.GetExcelToEmployeeInfo(userinfo.CompanyCD); this.lbl_jg.Text = "Excel数据导入成功"; ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), ds.Tables[0].Rows.Count, 1, "成功导入" + ds.Tables[0].Rows.Count.ToString() + "条数据"); /* * 更新有特殊符号的员工编号"##@@$$@@##" */ DataSet nullds = EmployeeInfoBus.GetNullEmployeeList(userinfo.CompanyCD); for (int i = 0; i < nullds.Tables[0].Rows.Count; i++) { //获取规则码 string employeeNo = XBase.Business.Common.ItemCodingRuleBus.GetCodeValue(ruleCode.ToString(), "EmployeeInfo", "EmployeeNo"); EmployeeInfoBus.UpdateEmployeeInfo(userinfo.CompanyCD, employeeNo, nullds.Tables[0].Rows[i]["ID"].ToString()); } /* * 更新结束 */ if (Session["newfile"] != null) { ProductInfoBus.DeleteFile(userinfo.CompanyCD, Session["newfile"].ToString()); } this.tab_end.Visible = true; btn_input.Enabled = false; } catch (Exception ex) { btn_input.Enabled = true; this.tab_end.Visible = true; this.lbl_jg.Text = ex.Message; ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, this.lbl_jg.Text); } }
protected void setup6_Click(object sender, EventArgs e) { string suberrorstr = string.Empty; int j = 0;//定义错误列表序号 int k = 0; errorstr = string.Empty; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (checkString(ds.Tables[0].Rows[i]["客户名称"].ToString().Trim())) { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的客户名称含有特殊字符,导入操作失败!<br>"; } if (chenkHave(ds.Tables[0].Rows[i]["客户编号"].ToString().Trim())) { suberrorstr += (++k).ToString() + ": " + "第" + (i + 2).ToString() + "行中的客户编号含有特殊字符,导入操作失败!<br>"; } } if (j > 0 || k > 0) { errorstr = "<strong>含有特殊字符校验错误列表</strong><br>"; errorstr += suberrorstr; this.tr_result.Visible = true; this.setup6.Enabled = false; if (Session["newfile"] != null) { ProductInfoBus.DeleteFile(userinfo.CompanyCD, Session["newfile"].ToString()); ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, errorstr); } } else { this.tr_result.Visible = false; this.setup6.Enabled = false; this.setup3.Enabled = true; } }
/// <summary> /// 长度判断 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void setup3_Click(object sender, EventArgs e) { //3.长度判断 string suberrorstr = string.Empty; errorstr = string.Empty; int j = 0;//定义错误列表序号 string[] code = { "物品编号", "物品名称", "名称简称", "条码", "规格型号", "颜色", "产地", "最低库存", "最高库存", "安全库存", "去税售价", "销项税率", "进项税率", "含税售价", "含税进价", "去税进价" }; int[] codelen = { 50, 100, 50, 50, 100, 12, 100, 12, 12, 12, 12, 12, 12, 12, 12, 12 }; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { for (int k = 0; k < code.Length; k++) { if (ds.Tables[0].Rows[i][code[k]].ToString().Trim().Length > codelen[k]) { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的 " + code[k] + " 数据长度过长,导入操作失败!<br>"; } } } if (j > 0) { errorstr = "<strong>数据长度校验错误列表</strong><br>"; errorstr += suberrorstr; this.tr_result.Visible = true; if (Session["newfile"] != null) { ProductInfoBus.DeleteFile(userinfo.CompanyCD, Session["newfile"].ToString()); } ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, errorstr); } else { this.tr_result.Visible = false; this.setup3.Enabled = false; this.setup4.Enabled = true; } }
/// <summary> /// 空值验证 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void setup2_Click(object sender, EventArgs e) { //3.物品非空判断 string suberrorstr = string.Empty; int j = 0;//定义错误列表序号 errorstr = string.Empty; string[] code = { "物品编号", "物品名称", "主放仓库", "单位" }; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { for (int k = 0; k < code.Length; k++) { if (ds.Tables[0].Rows[i][code[k]].ToString().Trim().Length < 1) { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的 " + code[k] + " 值不能为空值,导入操作失败!<br>"; } } } if (j > 0) { errorstr = "<strong>空值校验错误列表</strong><br>"; errorstr += suberrorstr; this.tr_result.Visible = true; if (Session["newfile"] != null) { ProductInfoBus.DeleteFile(userinfo.CompanyCD, Session["newfile"].ToString()); } ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, errorstr); } else { this.tr_result.Visible = false; this.setup2.Enabled = false; this.setup3.Enabled = true; } }
protected void btn_input_Click(object sender, EventArgs e) { try { userinfo = (UserInfoUtil)SessionUtil.Session["UserInfo"]; StorageInfoBus.GetExcelToStorageInfo(userinfo.CompanyCD, userinfo.UserID, userinfo.IsBatch ? "1" : "0", userinfo.EmployeeID); this.lbl_jg.Text = "Excel数据导入成功"; if (Session["newfile"] != null) { ProductInfoBus.DeleteFile(userinfo.CompanyCD, Session["newfile"].ToString()); } ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), ds.Tables[0].Rows.Count, 1, "成功导入" + ds.Tables[0].Rows.Count.ToString() + "条数据"); this.tab_end.Visible = true; btn_input.Enabled = false; } catch (Exception ex) { btn_input.Enabled = true; this.tab_end.Visible = true; this.lbl_jg.Text = ex.Message; ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, this.lbl_jg.Text); } }
protected void setup4_Click(object sender, EventArgs e) { errorstr = string.Empty; ruleCode = EmployeeInfoBus.GetCodeRuleID(userinfo.CompanyCD); if (ruleCode < 1) { errorstr = "<strong>员工编号编码规则没有设置,设置步骤如下</strong><br><br>办公模式->系统管理->公用设置->基础数据编号设置,点击[新建]按钮,选择“基础数据名称”为“人员”"; if (Session["newfile"] != null) { ProductInfoBus.DeleteFile(userinfo.CompanyCD, Session["newfile"].ToString()); } ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, errorstr); this.tr_result.Visible = true; } else { this.tr_result.Visible = false; tr_repeat.Visible = false; this.setup4.Enabled = false; this.btn_input.Enabled = true; lbl_validateend.Visible = true; } }
protected void setup3_Click(object sender, EventArgs e) { string suberrorstr = string.Empty; errorstr = string.Empty; int j = 0; //定义错误列表序号 int total = 0; //总错误记录 for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["目前所在部门"].ToString().Trim().Length > 0) { bool flag = EmployeeInfoBus.ChargeDeptInfo(ds.Tables[0].Rows[i]["目前所在部门"].ToString().Trim(), ds.Tables[0].Rows[i]["部门编号"].ToString().Trim(), userinfo.CompanyCD); if (!flag) { if (ds.Tables[0].Rows[i]["部门编号"].ToString().Trim().Length > 0) { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中部门编号为<span style='color:blue'>" + ds.Tables[0].Rows[i]["部门编号"].ToString() + "</span>的 部门 不存在,导入操作失败!<br>"; } else { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的 目前所在部门 不存在,导入操作失败!<br>"; } tr_repeat.Visible = false; } //部门多于一个选择 int num = EmployeeInfoBus.ChargeDeptInfoNum(ds.Tables[0].Rows[i]["目前所在部门"].ToString().Trim(), ds.Tables[0].Rows[i]["部门编号"].ToString().Trim(), userinfo.CompanyCD); if (num > 1) { DataTable DeptInfoDt = EmployeeInfoBus.GetDeptInfo(ds.Tables[0].Rows[i]["目前所在部门"].ToString().Trim(), userinfo.CompanyCD); Repeat_data.DataSource = DeptInfoDt; Repeat_data.DataBind(); suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的 目前所在部门 重复,导入操作失败!<br><br><span style='color:red'>解决办法</span>:<span style='color:blue'>在数据重复列表中找到正确的部门编号,填写到Excel文件中,然后重新导入</span>"; this.tr_result.Visible = true; tr_repeat.Visible = true; tr_quqrter.Visible = false; tr_dept.Visible = true; errorstr = suberrorstr; return; } } } if (j > 0) { total += j; errorstr += "<strong>是否存在校验错误列表(部门)</strong><br>"; errorstr += suberrorstr; suberrorstr = string.Empty; this.tr_result.Visible = true; tr_quqrter.Visible = false; tr_dept.Visible = false; return; } j = 0; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { //判断岗位是否存在 if (ds.Tables[0].Rows[i]["目前所在岗位"].ToString().Trim().Length > 0) { bool flag = EmployeeInfoBus.ChargeQuarterInfo(ds.Tables[0].Rows[i]["目前所在岗位"].ToString().Trim(), ds.Tables[0].Rows[i]["岗位编号"].ToString().Trim(), ds.Tables[0].Rows[i]["目前所在部门"].ToString().Trim(), ds.Tables[0].Rows[i]["部门编号"].ToString().Trim(), userinfo.CompanyCD); if (!flag) //岗位不存在 { if (ds.Tables[0].Rows[i]["目前所在部门"].ToString().Trim().Length > 0 && ds.Tables[0].Rows[i]["部门编号"].ToString().Trim().Length > 0) { if (ds.Tables[0].Rows[i]["目前所在岗位"].ToString().Trim().Length > 0 && ds.Tables[0].Rows[i]["岗位编号"].ToString().Trim().Length > 0) { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中部门为<span style='color:blue'>" + ds.Tables[0].Rows[i]["目前所在部门"].ToString() + "</span>,部门编号为<span style='color:blue'>" + ds.Tables[0].Rows[i]["部门编号"].ToString() + "</span>,岗位名称为<span style='color:blue'>" + ds.Tables[0].Rows[i]["目前所在岗位"].ToString() + "</span>,岗位编号为<span style='color:blue'>" + ds.Tables[0].Rows[i]["岗位编号"].ToString() + "</span>的 岗位 不存在,导入操作失败!<br>"; } else if (ds.Tables[0].Rows[i]["目前所在岗位"].ToString().Trim().Length > 0) { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中部门为<span style='color:blue'>" + ds.Tables[0].Rows[i]["目前所在部门"].ToString() + "</span>,部门编号为<span style='color:blue'>" + ds.Tables[0].Rows[i]["部门编号"].ToString() + "</span>,岗位名称为<span style='color:blue'>" + ds.Tables[0].Rows[i]["目前所在岗位"].ToString() + "</span>的 岗位 不存在,导入操作失败!<br>"; } else if (ds.Tables[0].Rows[i]["岗位编号"].ToString().Trim().Length > 0) { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中部门为<span style='color:blue'>" + ds.Tables[0].Rows[i]["目前所在部门"].ToString() + "</span>,部门编号为<span style='color:blue'>" + ds.Tables[0].Rows[i]["部门编号"].ToString() + "</span>,岗位编号为<span style='color:blue'>" + ds.Tables[0].Rows[i]["岗位编号"].ToString() + "</span>的 岗位 不存在,导入操作失败!<br>"; } else { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中部门为<span style='color:blue'>" + ds.Tables[0].Rows[i]["目前所在部门"].ToString() + "</span>,部门编号为<span style='color:blue'>" + ds.Tables[0].Rows[i]["部门编号"].ToString() + "</span>的 岗位 不存在,导入操作失败!<br>"; } } else if (ds.Tables[0].Rows[i]["目前所在部门"].ToString().Trim().Length > 0) { if (ds.Tables[0].Rows[i]["目前所在岗位"].ToString().Trim().Length > 0 && ds.Tables[0].Rows[i]["岗位编号"].ToString().Trim().Length > 0) { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中部门为<span style='color:blue'>" + ds.Tables[0].Rows[i]["目前所在部门"].ToString() + "</span>,岗位名称为<span style='color:blue'>" + ds.Tables[0].Rows[i]["目前所在岗位"].ToString() + "</span>,岗位编号为<span style='color:blue'>" + ds.Tables[0].Rows[i]["岗位编号"].ToString() + "</span>的 岗位 不存在,导入操作失败!<br>"; } else if (ds.Tables[0].Rows[i]["目前所在岗位"].ToString().Trim().Length > 0) { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中部门为<span style='color:blue'>" + ds.Tables[0].Rows[i]["目前所在部门"].ToString() + "</span>,岗位名称为<span style='color:blue'>" + ds.Tables[0].Rows[i]["目前所在岗位"].ToString() + "</span>的 岗位 不存在,导入操作失败!<br>"; } else if (ds.Tables[0].Rows[i]["岗位编号"].ToString().Trim().Length > 0) { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中部门为<span style='color:blue'>" + ds.Tables[0].Rows[i]["目前所在部门"].ToString() + "</span>,岗位编号为<span style='color:blue'>" + ds.Tables[0].Rows[i]["岗位编号"].ToString() + "</span>的 岗位 不存在,导入操作失败!<br>"; } else { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中部门为<span style='color:blue'>" + ds.Tables[0].Rows[i]["目前所在部门"].ToString() + "</span>,部门编号为<span style='color:blue'>" + ds.Tables[0].Rows[i]["部门编号"].ToString() + "</span>的 岗位 不存在,导入操作失败!<br>"; } } else if (ds.Tables[0].Rows[i]["部门编号"].ToString().Trim().Length > 0) { if (ds.Tables[0].Rows[i]["目前所在岗位"].ToString().Trim().Length > 0 && ds.Tables[0].Rows[i]["岗位编号"].ToString().Trim().Length > 0) { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的部门编号为<span style='color:blue'>" + ds.Tables[0].Rows[i]["部门编号"].ToString() + "</span>,岗位名称为<span style='color:blue'>" + ds.Tables[0].Rows[i]["目前所在岗位"].ToString() + "</span>,岗位编号为<span style='color:blue'>" + ds.Tables[0].Rows[i]["岗位编号"].ToString() + "</span>的 岗位 不存在,导入操作失败!<br>"; } else if (ds.Tables[0].Rows[i]["目前所在岗位"].ToString().Trim().Length > 0) { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的部门编号为<span style='color:blue'>" + ds.Tables[0].Rows[i]["部门编号"].ToString() + "</span>,岗位名称为<span style='color:blue'>" + ds.Tables[0].Rows[i]["目前所在岗位"].ToString() + "</span>的 岗位 不存在,导入操作失败!<br>"; } else if (ds.Tables[0].Rows[i]["岗位编号"].ToString().Trim().Length > 0) { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的部门编号为<span style='color:blue'>" + ds.Tables[0].Rows[i]["部门编号"].ToString() + "</span>,岗位编号为<span style='color:blue'>" + ds.Tables[0].Rows[i]["岗位编号"].ToString() + "</span>的 岗位 不存在,导入操作失败!<br>"; } else { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的部门编号为<span style='color:blue'>" + ds.Tables[0].Rows[i]["部门编号"].ToString() + "</span>的 岗位 不存在,导入操作失败!<br>"; } } tr_repeat.Visible = false; } //岗位多于一个选择 DataTable QuarterDT = EmployeeInfoBus.ChargeQuarterInfoNum(ds.Tables[0].Rows[i]["目前所在岗位"].ToString().Trim(), ds.Tables[0].Rows[i]["岗位编号"].ToString().Trim(), ds.Tables[0].Rows[i]["目前所在部门"].ToString().Trim(), ds.Tables[0].Rows[i]["部门编号"].ToString().Trim(), userinfo.CompanyCD); if (QuarterDT.Rows.Count > 1) { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的 目前所在岗位 重复,导入操作失败!<br><br><span style='color:red'>解决办法</span>:<span style='color:blue'>在数据重复列表中找到正确的岗位编号,填写到Excel文件中,然后重新导入</span>"; this.tr_result.Visible = true; tr_quqrter.Visible = true; tr_repeat.Visible = true; tr_dept.Visible = false; rpt_quarter.DataSource = QuarterDT; rpt_quarter.DataBind(); errorstr = suberrorstr; return; } } } if (j > 0) { total += j; errorstr = "<strong>是否存在校验错误列表(岗位)</strong><br>"; errorstr += suberrorstr; suberrorstr = string.Empty; } j = 0; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["婚姻状况"].ToString().Trim().Length > 0) { bool flag = EmployeeInfoBus.ChargeHyInfo(ds.Tables[0].Rows[i]["婚姻状况"].ToString().Trim(), userinfo.CompanyCD); if (!flag) { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的 婚姻状况 不存在,导入操作失败!<br>"; } } } if (j > 0) { total += j; total += j; errorstr += "<strong>是否存在校验错误列表(婚姻状况)</strong><br>"; errorstr += suberrorstr; suberrorstr = string.Empty; } if (total > 0) { if (Session["newfile"] != null) { ProductInfoBus.DeleteFile(userinfo.CompanyCD, Session["newfile"].ToString()); } ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, errorstr); this.tr_result.Visible = true; } else { this.tr_result.Visible = false; this.setup3.Enabled = false; this.setup4.Enabled = true; } }
protected void setup2_Click(object sender, EventArgs e) { string suberrorstr = string.Empty; errorstr = string.Empty; int j = 0; //定义错误列表序号 int total = 0; //总错误记录 string[] code = { "生日", "入职时间", "参加工作时间" }; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { for (int k = 0; k < code.Length; k++) { try { if (ds.Tables[0].Rows[i][code[k]].ToString().Trim().Length > 0) { string timedata = ds.Tables[0].Rows[i][code[k]].ToString().Trim(); int index = -1; char tagstr = 'A'; char[] tag = { '-', '/', '.' }; int ii = 0; do { index = timedata.IndexOf(tag[ii]); if (index > -1) { tagstr = tag[ii]; break; } ii++; } while (ii < 3); if (tagstr == 'A') { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的 " + code[k] + " 日期格式错误,正确的格式如:2009-08-13,2009/08/13或者2009.08.13,导入操作失败!<br>"; } else { timedata = timedata.Replace(tagstr, '-'); try { DateTime mydate = Convert.ToDateTime(ds.Tables[0].Rows[i][code[k]].ToString().Trim()); } catch { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的 " + code[k] + " 日期格式错误,正确的格式如:2009-08-13,2009/08/13或者2009.08.13,导入操作失败!<br>"; } //string[] alldata = timedata.Split(tagstr); //if (alldata[0].Length == 4 && (alldata[1].Length == 1 || alldata[1].Length == 2) && (alldata[2].Length == 1 || alldata[2].TrimEnd(' ').Length == 2)) //{ // DateTime mydate = Convert.ToDateTime(ds.Tables[0].Rows[i][code[k]].ToString().Trim()); //} //else //{ // suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的 " + code[k] + " 日期格式错误,正确的格式如:2009-08-13,2009/08/13或者2009.08.13,导入操作失败!<br>"; //} } } } catch { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的 " + code[k] + " 日期格式错误,正确的格式如:2009-08-13,2009/08/13或者2009.08.13,导入操作失败!<br>"; } } } total += j; if (j > 0) { errorstr = "<strong>格式校验错误列表(时间格式)</strong><br>"; errorstr += suberrorstr; suberrorstr = string.Empty; } j = 0; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["性别"].ToString().Trim() != "男" && ds.Tables[0].Rows[i]["性别"].ToString().Trim() != "女") { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的性别格式错误,应该填写为(男/女),导入操作失败!<br>"; } } total += j; if (j > 0) { errorstr += "<strong>格式校验错误列表(性别格式)</strong><br>"; errorstr += suberrorstr; } j = 0; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["人员分类"].ToString().Trim() != "在职人员" && ds.Tables[0].Rows[i]["人员分类"].ToString().Trim() != "人才储备" && ds.Tables[0].Rows[i]["人员分类"].ToString().Trim() != "离职人员") { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的人员分类错误,应该填写为(在职人员/人才储备/离职人员),导入操作失败!<br>"; } } total += j; if (j > 0) { errorstr += "<strong>格式校验错误列表(人才类型格式)</strong><br>"; errorstr += suberrorstr; } if (total > 0) { this.tr_result.Visible = true; if (Session["newfile"] != null) { ProductInfoBus.DeleteFile(userinfo.CompanyCD, Session["newfile"].ToString()); } ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, errorstr); } else { this.tr_result.Visible = false; tr_repeat.Visible = false; this.setup2.Enabled = false; this.setup3.Enabled = true; } }