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; } }
/// <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 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; } }
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 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 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 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 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; } }
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); } }
/// <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 btn_excel_Click(object sender, EventArgs e) { #region 文件 //上传文件 if (upExcelFile.PostedFile.FileName.Length < 1) { this.lbl_result.Text = "请选择要上传的Excel文件!"; return; } else { this.initvalidate(); } string filename = upExcelFile.PostedFile.FileName; string subfile = filename.Substring(filename.LastIndexOf(".") + 1); if (subfile.ToUpper() != "XLS" && subfile.ToUpper() != "XLSX") { this.lbl_result.Text = "导入文件格式错误,必须为XLS,XLSX格式!"; //ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, "", 0, "导入文件格式错误"); ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, this.lbl_result.Text); } else { try { //获取企业上传文件路径 string upfilepath = ProductInfoBus.GetCompanyUpFilePath(userinfo.CompanyCD);//得到格式如:"D:\zhou" //获取企业并构造企业上传文件名称 Session["newfile"] = DateTime.Now.ToString("yyyyMMddhhmmss") + filename.Substring(filename.LastIndexOf("\\") + 1); upExcelFile.PostedFile.SaveAs(upfilepath + @"\" + Session["newfile"].ToString()); #region try { //ds = ProductInfoBus.ReadEexcel(upfilepath + @"\" + Session["newfile"].ToString(), userinfo.CompanyCD);//导入临时表 ds = ConvertXlsToDataSet(upfilepath + @"\" + Session["newfile"].ToString()); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { try { string RetVal = ds.Tables[0].Rows[0]["序号"].ToString() + ds.Tables[0].Rows[0]["客户编号"].ToString() + ds.Tables[0].Rows[0]["客户名称"].ToString() + ds.Tables[0].Rows[0]["客户简介"].ToString() + ds.Tables[0].Rows[0]["人员编号"].ToString() + ds.Tables[0].Rows[0]["分管业务员"].ToString() + ds.Tables[0].Rows[0]["区域"].ToString() + ds.Tables[0].Rows[0]["省"].ToString() + ds.Tables[0].Rows[0]["市"].ToString() + ds.Tables[0].Rows[0]["联系人"].ToString() + ds.Tables[0].Rows[0]["电话"].ToString() + ds.Tables[0].Rows[0]["手机"].ToString() + ds.Tables[0].Rows[0]["传真"].ToString() + ds.Tables[0].Rows[0]["在线咨询"].ToString() + ds.Tables[0].Rows[0]["公司网址"].ToString() + ds.Tables[0].Rows[0]["邮编"].ToString() + ds.Tables[0].Rows[0]["电子邮件"].ToString() + ds.Tables[0].Rows[0]["收货地址"].ToString() + ds.Tables[0].Rows[0]["经营范围"].ToString() + ds.Tables[0].Rows[0]["单位性质"].ToString() + ds.Tables[0].Rows[0]["成立时间"].ToString() + ds.Tables[0].Rows[0]["注册资本(万元)"].ToString() + ds.Tables[0].Rows[0]["资产规模(万元)"].ToString() + ds.Tables[0].Rows[0]["年销售额(万元)"].ToString() + ds.Tables[0].Rows[0]["员工总数(个)"].ToString() + ds.Tables[0].Rows[0]["法人代表"].ToString() + ds.Tables[0].Rows[0]["行业"].ToString() + ds.Tables[0].Rows[0]["注册地址"].ToString() + ds.Tables[0].Rows[0]["关系描述"].ToString() + ds.Tables[0].Rows[0]["发展计划"].ToString() + ds.Tables[0].Rows[0]["合作方法"].ToString(); } catch { this.lbl_result.Text = "数据读取失败,可能原因:Excel模板格式不正确"; //initvalidate(); this.tr_result.Visible = false; this.lbl_validateend.Visible = false; ProductInfoBus.DeleteFile(userinfo.CompanyCD, Session["newfile"].ToString()); return; } this.lbl_result.Text = "Excel文件上传成功!"; this.setup1.Enabled = true; this.setup2.Enabled = false; this.setup3.Enabled = false; this.setup4.Enabled = false; this.setup5.Enabled = false; this.setup6.Enabled = false; this.setup7.Enabled = false; this.setup8.Enabled = false; this.tr_result.Visible = false; ProductInfoBus.DeleteFile(userinfo.CompanyCD, Session["newfile"].ToString()); } else { initvalidate(); ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, this.lbl_result.Text); this.lbl_result.Text = "您导入的Excel表没有数据!"; } } else { initvalidate(); ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, this.lbl_result.Text); this.lbl_result.Text = "您导入的Excel表没有数据!"; } } catch (Exception ex) { //ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, "", 0, "数据读取失败"); ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, this.lbl_result.Text); initvalidate(); this.lbl_result.Text = "数据读取失败,原因:" + ex.Message.ToString(); //this.lbl_result.Text = "数据读取失败!"; } #endregion } catch (Exception ex) { //this.setup1.Enabled = false; ProductInfoBus.LogInsert(userinfo.CompanyCD, userinfo.DeptID, userinfo.UserID, Request.QueryString["ModuleID"].ToString(), 0, 0, this.lbl_result.Text); this.lbl_result.Text = "数据读取失败,原因:" + ex.Message; } } #endregion }
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; } }
protected void setup2_Click(object sender, EventArgs e) { string suberrorstr = string.Empty; errorstr = string.Empty; int j = 0; //定义错误列表序号 int total = 0; //总错误记录 #region excel内部重复判断 序号 for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { for (int k = i + 1; k < ds.Tables[0].Rows.Count; k++) { if (ds.Tables[0].Rows[i]["序号"].ToString().Trim() == ds.Tables[0].Rows[k]["序号"].ToString().Trim()) { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行的序号与第" + (k + 2).ToString() + "行中的序号重复,导入操作失败!<br>"; } } } if (j > 0) { total += j; errorstr += "<strong>重复值校验错误列表(序号重复)</strong><br>"; errorstr += suberrorstr; suberrorstr = string.Empty; } #endregion #region/*excel内部重复判断客户编号、客户名称2个字段值同时相同*/ j = 0; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { for (int k = i + 1; k < ds.Tables[0].Rows.Count; k++) { if (ds.Tables[0].Rows[i]["客户编号"].ToString().Trim() == ds.Tables[0].Rows[k]["客户编号"].ToString().Trim() || ds.Tables[0].Rows[i]["客户名称"].ToString().Trim() == ds.Tables[0].Rows[k]["客户名称"].ToString().Trim()) { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行的客户编号或客户名称与第" + (k + 2).ToString() + "行中的客户编号或客户名称重复,导入操作失败!<br>"; } } } if (j > 0) { total += j; errorstr += "<strong>重复值校验错误列表(客户编号或客户名称有重复值)</strong><br>"; errorstr += suberrorstr; suberrorstr = string.Empty; } #endregion 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; this.setup2.Enabled = false; } else { this.tr_result.Visible = false; this.setup2.Enabled = false; this.setup6.Enabled = true; } }
protected void setup2_Click(object sender, EventArgs e) { //非空判断 string suberrorstr = string.Empty; int j = 0; //定义错误列表序号 int k = 0; //定义批次错误序列号 string batchNoError = string.Empty; int m = 0; //定义单价错误序列号 string priceError = string.Empty; //定义单价错误记录 for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["现有存量"].ToString().Trim().Length < 1) { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的现有存量不能为空值,导入操作失败!<br>"; } //判断是是否启用批次 if (XBase.Business.Office.StorageManager.StorageBus.IsBatchByProductNameAndNo(ds.Tables[0].Rows[i]["物品编号"].ToString(), ds.Tables[0].Rows[i]["物品"].ToString(), UserInfo.CompanyCD)) { if (ds.Tables[0].Rows[i]["批次"].ToString().Trim().Length < 1) { batchNoError += (++k).ToString() + ": " + " 物品(" + ds.Tables[0].Rows[i]["物品"].ToString() + ")开启批次,第" + (i + 2).ToString() + "行中的批次不能为空值,导入操作失败!<br>"; } } if (ds.Tables[0].Rows[i]["单价"].ToString().Trim().Length < 1) { priceError += (++m).ToString() + ": " + "第" + (i + 2).ToString() + "行中的单价不能为空值,导入操作失败!<br>"; } } if (j > 0 || k > 0 || m > 0) { errorstr = "<strong>Excel空值校验错误列表</strong><br>"; if (j > 0) { errorstr += suberrorstr; } if (k > 0) { errorstr += batchNoError; } 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.setup2.Enabled = false; this.setup3.Enabled = true; } }
protected void setup1_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++) { //判断仓库是否存在 bool flag = ProductInfoBus.ChargeStorage(ds.Tables[0].Rows[i]["仓库"].ToString().Trim(), userinfo.CompanyCD); if (!flag) { suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的仓库不存在,导入操作失败!<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++) { bool flag = StorageInfoBus.ChargeProductInfo(ds.Tables[0].Rows[i]["物品"].ToString().Trim(), userinfo.CompanyCD, ds.Tables[0].Rows[i]["物品编号"].ToString()); 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 += j) > 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.setup1.Enabled = false; this.setup2.Enabled = true; } }
protected void setup8_Click(object sender, EventArgs e) { string suberrorstr = string.Empty; errorstr = string.Empty; int j = 0;//定义错误列表序号 DataColumn EmployeeID = new DataColumn(); ds.Tables[0].Columns.Add("CompanyType"); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["单位性质"].ToString().Trim().Length > 0) { //单位性质(1事业,2企业,3社团,4自然人,5其他) switch (ds.Tables[0].Rows[i]["单位性质"].ToString()) { case "事业": ds.Tables[0].Rows[i]["CompanyType"] = "1"; break; case "企业": ds.Tables[0].Rows[i]["CompanyType"] = "2"; break; case "社团": ds.Tables[0].Rows[i]["CompanyType"] = "3"; break; case "自然人": ds.Tables[0].Rows[i]["CompanyType"] = "4"; break; case "其他": ds.Tables[0].Rows[i]["CompanyType"] = "5"; break; default: suberrorstr += (++j).ToString() + ": " + "第" + (i + 2).ToString() + "行中的 单位性质不存在,导入操作失败!<br>"; break; } } } if (j > 0) { errorstr = "<strong>单位性质校验错误列表</strong><br>"; errorstr += suberrorstr; this.tr_result.Visible = true; this.setup8.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.setup8.Enabled = false; this.setup9.Enabled = true; //this.btn_input.Enabled = true; //lbl_validateend.Visible = true; } }