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; } }