/// <summary> /// 增加一条数据 /// </summary> public bool Add(BaseProductTable model) { return(dal.Add(model)); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(BaseProductTable model) { return(dal.Update(model)); }
/// <summary> /// 得到一个对象实体 /// </summary> public BaseProductTable GetModel(string CODE) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from base_product_view "); strSql.Append(" where CODE=@CODE "); strSql.AppendFormat(" and STATUS_FLAG <> {0}", CConstant.DELETE_STATUS); SqlParameter[] parameters = { new SqlParameter("@CODE", SqlDbType.VarChar, 50) }; parameters[0].Value = CODE; BaseProductTable model = new BaseProductTable(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { model.CODE = ds.Tables[0].Rows[0]["CODE"].ToString(); model.NAME = ds.Tables[0].Rows[0]["NAME"].ToString(); model.SPEC = ds.Tables[0].Rows[0]["SPEC"].ToString(); model.MODEL_NUMBER = ds.Tables[0].Rows[0]["MODEL_NUMBER"].ToString(); model.GROUP_CODE = ds.Tables[0].Rows[0]["GROUP_CODE"].ToString(); model.GROUP_NAME = ds.Tables[0].Rows[0]["GROUP_NAME"].ToString(); model.BASIC_UNIT_CODE = ds.Tables[0].Rows[0]["BASIC_UNIT_CODE"].ToString(); model.BASIC_UNIT_NAME = ds.Tables[0].Rows[0]["UNIT_NAME"].ToString(); model.NAME_JP = ds.Tables[0].Rows[0]["NAME_JP"].ToString(); if (ds.Tables[0].Rows[0]["ACCOUTING_TARGET"].ToString() != "") { model.ACCOUTING_TARGET = int.Parse(ds.Tables[0].Rows[0]["ACCOUTING_TARGET"].ToString()); } model.HS_CODE = ds.Tables[0].Rows[0]["HS_CODE"].ToString(); model.HSCODE_NAME = ds.Tables[0].Rows[0]["HSCODE_NAME"].ToString(); if (ds.Tables[0].Rows[0]["SALES_PRICE"].ToString() != "") { model.SALES_PRICE = decimal.Parse(ds.Tables[0].Rows[0]["SALES_PRICE"].ToString()); } if (ds.Tables[0].Rows[0]["PURCHASE_PRICE"].ToString() != "") { model.PURCHASE_PRICE_INCLUDED_TAX = decimal.Parse(ds.Tables[0].Rows[0]["PURCHASE_PRICE"].ToString()); } model.LOCATION_CODE = ds.Tables[0].Rows[0]["LOCATION_CODE"].ToString(); if (ds.Tables[0].Rows[0]["STOCK_FLAG"].ToString() != "") { model.STOCK_FLAG = int.Parse(ds.Tables[0].Rows[0]["STOCK_FLAG"].ToString()); } if (ds.Tables[0].Rows[0]["PROPERTY_FLAG"].ToString() != "") { model.PROPERTY_FLAG = int.Parse(ds.Tables[0].Rows[0]["PROPERTY_FLAG"].ToString()); } if (ds.Tables[0].Rows[0]["SELL_LOCATION"].ToString() != "") { model.SELL_LOCATION = int.Parse(ds.Tables[0].Rows[0]["SELL_LOCATION"].ToString()); } if (ds.Tables[0].Rows[0]["PACKAGE_MODE"].ToString() != "") { model.PACKAGE_MODE = int.Parse(ds.Tables[0].Rows[0]["PACKAGE_MODE"].ToString()); } if (ds.Tables[0].Rows[0]["FROMSET_FLAG"].ToString() != "") { model.FROMSET_FLAG = int.Parse(ds.Tables[0].Rows[0]["FROMSET_FLAG"].ToString()); } if (ds.Tables[0].Rows[0]["MECHANICAL_DISTINCTION_FLAG"].ToString() != "") { model.MECHANICAL_DISTINCTION_FLAG = int.Parse(ds.Tables[0].Rows[0]["MECHANICAL_DISTINCTION_FLAG"].ToString()); } if (ds.Tables[0].Rows[0]["STATUS_FLAG"].ToString() != "") { model.STATUS_FLAG = int.Parse(ds.Tables[0].Rows[0]["STATUS_FLAG"].ToString()); } model.CREATE_USER = ds.Tables[0].Rows[0]["CREATE_USER"].ToString(); if (ds.Tables[0].Rows[0]["LAST_UPDATE_TIME"].ToString() != "") { model.LAST_UPDATE_TIME = DateTime.Parse(ds.Tables[0].Rows[0]["LAST_UPDATE_TIME"].ToString()); } if (ds.Tables[0].Rows[0]["CREATE_DATE_TIME"].ToString() != "") { model.CREATE_DATE_TIME = DateTime.Parse(ds.Tables[0].Rows[0]["CREATE_DATE_TIME"].ToString()); } model.LAST_UPDATE_USER = ds.Tables[0].Rows[0]["LAST_UPDATE_USER"].ToString(); model.LOCATION_NAME = ds.Tables[0].Rows[0]["LOCATION_NAME"].ToString(); model.GROUP_NAME = ds.Tables[0].Rows[0]["GROUP_NAME"].ToString(); model.HSCODE_NAME = ds.Tables[0].Rows[0]["HSCODE_NAME"].ToString(); model.CUSTOMER_SALES_PRICE = CConvert.ToDecimal(ds.Tables[0].Rows[0]["CUSTOMER_SALES_PRICE"]); model.PURCHASE_PRICE_WITHOUT_TAX = CConvert.ToDecimal(ds.Tables[0].Rows[0]["PURCHASE_PRICE_WITHOUT_TAX"]); model.PRICE_JP = CConvert.ToDecimal(ds.Tables[0].Rows[0]["PRICE_JP"]); return(model); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(BaseProductTable model) { StringBuilder strSql = null; int rows = 0; if (Exists(model.CODE)) { #region 更新 strSql = new StringBuilder(); strSql.Append("update BASE_PRODUCT set "); strSql.Append("NAME=@NAME,"); strSql.Append("SPEC=@SPEC,"); strSql.Append("MODEL_NUMBER=@MODEL_NUMBER,"); strSql.Append("GROUP_CODE=@GROUP_CODE,"); strSql.Append("BASIC_UNIT_CODE=@BASIC_UNIT_CODE,"); strSql.Append("ACCOUTING_TARGET=@ACCOUTING_TARGET,"); strSql.Append("HS_CODE=@HS_CODE,"); strSql.Append("SALES_PRICE=@SALES_PRICE,"); strSql.Append("LOCATION_CODE=@LOCATION_CODE,"); strSql.Append("STOCK_FLAG=@STOCK_FLAG,"); strSql.Append("PROPERTY_FLAG=@PROPERTY_FLAG,"); strSql.Append("FROMSET_FLAG=@FROMSET_FLAG,"); strSql.Append("MECHANICAL_DISTINCTION_FLAG=@MECHANICAL_DISTINCTION_FLAG,"); strSql.Append("SAFETY_STOCK=@SAFETY_STOCK,"); strSql.Append("STATUS_FLAG=@STATUS_FLAG,"); strSql.Append("CREATE_USER=@CREATE_USER,"); strSql.Append("CREATE_DATE_TIME=GETDATE(),"); strSql.Append("LAST_UPDATE_USER=@LAST_UPDATE_USER,"); strSql.Append("LAST_UPDATE_TIME=GETDATE(), "); strSql.Append("SELL_LOCATION=@SELL_LOCATION, "); strSql.Append("PACKAGE_MODE=@PACKAGE_MODE, "); strSql.Append("NAME_JP=@NAME_JP, "); strSql.Append("PURCHASE_PRICE=@PURCHASE_PRICE, "); strSql.Append("CUSTOMER_SALES_PRICE=@CUSTOMER_SALES_PRICE, "); strSql.Append("PURCHASE_PRICE_WITHOUT_TAX=@PURCHASE_PRICE_WITHOUT_TAX, "); strSql.Append("PRICE_JP=@PRICE_JP"); strSql.Append(" where CODE=@CODE "); SqlParameter[] parameters = { new SqlParameter("@CODE", SqlDbType.VarChar, 40), new SqlParameter("@NAME", SqlDbType.NVarChar, 100), new SqlParameter("@SPEC", SqlDbType.NVarChar, 100), new SqlParameter("@MODEL_NUMBER", SqlDbType.NVarChar, 100), new SqlParameter("@GROUP_CODE", SqlDbType.VarChar, 20), new SqlParameter("@BASIC_UNIT_CODE", SqlDbType.VarChar, 20), new SqlParameter("@ACCOUTING_TARGET", SqlDbType.Int, 4), new SqlParameter("@HS_CODE", SqlDbType.VarChar, 20), new SqlParameter("@SALES_PRICE", SqlDbType.Decimal, 9), new SqlParameter("@LOCATION_CODE", SqlDbType.VarChar, 20), new SqlParameter("@STOCK_FLAG", SqlDbType.Int, 4), new SqlParameter("@PROPERTY_FLAG", SqlDbType.Int, 4), new SqlParameter("@FROMSET_FLAG", SqlDbType.Int, 4), new SqlParameter("@MECHANICAL_DISTINCTION_FLAG", SqlDbType.Int, 4), new SqlParameter("@SAFETY_STOCK", SqlDbType.Decimal, 9), new SqlParameter("@STATUS_FLAG", SqlDbType.Int, 4), new SqlParameter("@CREATE_USER", SqlDbType.VarChar, 20), new SqlParameter("@LAST_UPDATE_USER", SqlDbType.VarChar, 20), new SqlParameter("@SELL_LOCATION", SqlDbType.Int, 4), new SqlParameter("@PACKAGE_MODE", SqlDbType.Int, 4), new SqlParameter("@NAME_JP", SqlDbType.NVarChar, 100), new SqlParameter("@PURCHASE_PRICE", SqlDbType.Decimal, 9), new SqlParameter("@CUSTOMER_SALES_PRICE", SqlDbType.Decimal, 9), new SqlParameter("@PURCHASE_PRICE_WITHOUT_TAX", SqlDbType.Decimal, 9), new SqlParameter("@PRICE_JP", SqlDbType.Decimal, 9) }; parameters[0].Value = model.CODE; parameters[1].Value = model.NAME; parameters[2].Value = model.SPEC; parameters[3].Value = model.MODEL_NUMBER; parameters[4].Value = model.GROUP_CODE; parameters[5].Value = model.BASIC_UNIT_CODE; parameters[6].Value = model.ACCOUTING_TARGET; parameters[7].Value = model.HS_CODE; parameters[8].Value = model.SALES_PRICE; parameters[9].Value = model.LOCATION_CODE; parameters[10].Value = model.STOCK_FLAG; parameters[11].Value = model.PROPERTY_FLAG; parameters[12].Value = model.FROMSET_FLAG; parameters[13].Value = model.MECHANICAL_DISTINCTION_FLAG; parameters[14].Value = model.SAFETY_STOCK; parameters[15].Value = model.STATUS_FLAG; parameters[16].Value = model.CREATE_USER; parameters[17].Value = model.LAST_UPDATE_USER; parameters[18].Value = model.SELL_LOCATION; parameters[19].Value = model.PACKAGE_MODE; parameters[20].Value = model.NAME_JP; parameters[21].Value = model.PURCHASE_PRICE_INCLUDED_TAX; parameters[22].Value = model.CUSTOMER_SALES_PRICE; parameters[23].Value = model.PURCHASE_PRICE_WITHOUT_TAX; parameters[24].Value = model.PRICE_JP; rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); #endregion } else { #region 增加 strSql = new StringBuilder(); strSql.Append("insert into BASE_PRODUCT("); strSql.Append("CODE,NAME,SPEC,MODEL_NUMBER,GROUP_CODE,BASIC_UNIT_CODE,ACCOUTING_TARGET,HS_CODE,SALES_PRICE,LOCATION_CODE,STOCK_FLAG,PROPERTY_FLAG,FROMSET_FLAG,MECHANICAL_DISTINCTION_FLAG,SAFETY_STOCK,STATUS_FLAG,CREATE_USER,CREATE_DATE_TIME,LAST_UPDATE_TIME,LAST_UPDATE_USER,SELL_LOCATION,PACKAGE_MODE,NAME_JP,PURCHASE_PRICE,CUSTOMER_SALES_PRICE,PURCHASE_PRICE_WITHOUT_TAX,PRICE_JP)"); strSql.Append(" values ("); strSql.Append("@CODE,@NAME,@SPEC,@MODEL_NUMBER,@GROUP_CODE,@BASIC_UNIT_CODE,@ACCOUTING_TARGET,@HS_CODE,@SALES_PRICE,@LOCATION_CODE,@STOCK_FLAG,@PROPERTY_FLAG,@FROMSET_FLAG,@MECHANICAL_DISTINCTION_FLAG,@SAFETY_STOCK,@STATUS_FLAG,@CREATE_USER,GETDATE(),GETDATE(),@LAST_UPDATE_USER,@SELL_LOCATION,@PACKAGE_MODE,@NAME_JP,@PURCHASE_PRICE,@CUSTOMER_SALES_PRICE,@PURCHASE_PRICE_WITHOUT_TAX,@PRICE_JP)"); SqlParameter[] parameters = { new SqlParameter("@CODE", SqlDbType.VarChar, 40), new SqlParameter("@NAME", SqlDbType.NVarChar, 100), new SqlParameter("@SPEC", SqlDbType.NVarChar, 100), new SqlParameter("@MODEL_NUMBER", SqlDbType.NVarChar, 100), new SqlParameter("@GROUP_CODE", SqlDbType.VarChar, 20), new SqlParameter("@BASIC_UNIT_CODE", SqlDbType.VarChar, 20), new SqlParameter("@ACCOUTING_TARGET", SqlDbType.Int, 4), new SqlParameter("@HS_CODE", SqlDbType.VarChar, 20), new SqlParameter("@SALES_PRICE", SqlDbType.Decimal, 9), new SqlParameter("@LOCATION_CODE", SqlDbType.VarChar, 20), new SqlParameter("@STOCK_FLAG", SqlDbType.Int, 4), new SqlParameter("@PROPERTY_FLAG", SqlDbType.Int, 4), new SqlParameter("@FROMSET_FLAG", SqlDbType.Int, 4), new SqlParameter("@MECHANICAL_DISTINCTION_FLAG", SqlDbType.Int, 4), new SqlParameter("@SAFETY_STOCK", SqlDbType.Decimal, 9), new SqlParameter("@STATUS_FLAG", SqlDbType.Int, 4), new SqlParameter("@CREATE_USER", SqlDbType.VarChar, 20), new SqlParameter("@LAST_UPDATE_USER", SqlDbType.VarChar, 20), new SqlParameter("@SELL_LOCATION", SqlDbType.Int, 4), new SqlParameter("@PACKAGE_MODE", SqlDbType.Int, 4), new SqlParameter("@NAME_JP", SqlDbType.NVarChar, 100), new SqlParameter("@PURCHASE_PRICE", SqlDbType.Decimal, 9), new SqlParameter("@CUSTOMER_SALES_PRICE", SqlDbType.Decimal, 9), new SqlParameter("@PURCHASE_PRICE_WITHOUT_TAX", SqlDbType.Decimal, 9), new SqlParameter("@PRICE_JP", SqlDbType.Decimal, 9) }; parameters[0].Value = model.CODE; parameters[1].Value = model.NAME; parameters[2].Value = model.SPEC; parameters[3].Value = model.MODEL_NUMBER; parameters[4].Value = model.GROUP_CODE; parameters[5].Value = model.BASIC_UNIT_CODE; parameters[6].Value = model.ACCOUTING_TARGET; parameters[7].Value = model.HS_CODE; parameters[8].Value = model.SALES_PRICE; parameters[9].Value = model.LOCATION_CODE; parameters[10].Value = model.STOCK_FLAG; parameters[11].Value = model.PROPERTY_FLAG; parameters[12].Value = model.FROMSET_FLAG; parameters[13].Value = model.MECHANICAL_DISTINCTION_FLAG; parameters[14].Value = model.SAFETY_STOCK; parameters[15].Value = CConstant.NORMAL_STATUS; parameters[16].Value = model.CREATE_USER; parameters[17].Value = model.LAST_UPDATE_USER; parameters[18].Value = model.SELL_LOCATION; parameters[19].Value = model.PACKAGE_MODE; parameters[20].Value = model.NAME_JP; parameters[21].Value = model.PURCHASE_PRICE_INCLUDED_TAX; parameters[22].Value = model.CUSTOMER_SALES_PRICE; parameters[23].Value = model.PURCHASE_PRICE_WITHOUT_TAX; parameters[24].Value = model.PRICE_JP; rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); #endregion } if (rows > 0) { return(true); } else { return(false); } }
public override string[] doUpdateDB() { BaseProductTable ProductTable = null; BProduct bProduct = new BProduct(); StringBuilder strError = new StringBuilder(); int successData = 0; int failureData = 0; string errorFilePath = ""; string backupFilePath = ""; //数据导入处理 foreach (DataRow dr in _csvDataTable.Rows) { StringBuilder str = new StringBuilder(); //编号 if (GetValue(dr, "CODE").ToString().Length > 40) { if (!string.IsNullOrEmpty(GetValue(dr, "CODE").ToString().Substring(0, 40))) { str.Append(CheckString(GetValue(dr, "CODE"), "编号")); } else { str.Append("编号不能为空!"); } } else { if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "CODE")))) { str.Append(CheckString(GetValue(dr, "CODE"), "编号")); } else { str.Append("编号不能为空!"); } } //名称 str.Append(CheckLenght(GetValue(dr, "NAME"), 100, "名称")); //商品规格 str.Append(CheckLenght(GetValue(dr, "SPEC"), 50, "商品规格")); //机器型号 str.Append(CheckLenght(GetValue(dr, "MODEL_NUMBER"), 50, "机器型号")); //商品类别编号 if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "GROUP_CODE")))) { str.Append(CheckProductGroup(CConvert.ToString(GetValue(dr, "GROUP_CODE")), "商品类别编号")); } //基本单位 if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "BASIC_UNIT_CODE")))) { str.Append(CheckUnit(CConvert.ToString(GetValue(dr, "BASIC_UNIT_CODE")), "基本单位")); } //原价计算对象 str.Append(CheckLenght(GetValue(dr, "ACCOUTING_TARGET"), 100, "原价计算对象")); //海关商品编号 if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "HS_CODE")))) { str.Append(CheckHsCode(CConvert.ToString(GetValue(dr, "HS_CODE")), "海关商品编号")); } //默认售价 str.Append(CheckDecimal(GetValue(dr, "SALES_PRICE", 0), 12, 2, "默认售价")); //货位 str.Append(CheckLenght(GetValue(dr, "LOCATION_CODE"), 20, "货位")); //在库Flag if (CConvert.ToInt32(GetValue(dr, "STOCK_FLAG", 1)) != 1 && CConvert.ToInt32(GetValue(dr, "STOCK_FLAG", 1)) != 2 && CConvert.ToString(GetValue(dr, "STOCK_FLAG", 1)) != "") { str.Append("在库Flag只能为1或2!"); } else { str.Append(CheckInt(GetValue(dr, "STOCK_FLAG", 1), 2, "在库Flag")); } //1:组成品 2:材料 if (CConvert.ToInt32(GetValue(dr, "PROPERTY_FLAG", 1)) != 1 && CConvert.ToInt32(GetValue(dr, "PROPERTY_FLAG", 1)) != 2 && CConvert.ToString(GetValue(dr, "PROPERTY_FLAG", 1)) != "") { str.Append("是否组成品只能为1或2!"); } //一式品 if (CConvert.ToInt32(GetValue(dr, "FROMSET_FLAG", 1)) != 1 && CConvert.ToInt32(GetValue(dr, "FROMSET_FLAG", 1)) != 2 && CConvert.ToString(GetValue(dr, "FROMSET_FLAG", 1)) != "") { str.Append("一式品输入只能为1或2!"); } //机械区分 if (CConvert.ToInt32(GetValue(dr, "MECHANICAL_DISTINCTION_FLAG", 1)) != 1 && CConvert.ToInt32(GetValue(dr, "MECHANICAL_DISTINCTION_FLAG", 1)) != 2 && CConvert.ToString(GetValue(dr, "MECHANICAL_DISTINCTION_FLAG", 1)) != "") { str.Append("机械区分输入只能为1或2!"); } //安全在库数 str.Append(CheckDecimal(GetValue(dr, "SAFETY_STOCK", 0), 12, 2, "安全在库数")); //状态 str.Append(CheckInt(GetValue(dr, "STATUS_FLAG", CConstant.NORMAL_STATUS), 1, "状态")); //销售地点 str.Append(CheckInt(GetValue(dr, "SELL_LOCATION", CConstant.NORMAL_STATUS), 1, "销售地点")); //包装方式 str.Append(CheckInt(GetValue(dr, "PACKAGE_MODE", CConstant.NORMAL_STATUS), 1, "包装方式")); //名称 str.Append(CheckLenght(GetValue(dr, "NAME_JP"), 100, "日文名称")); //含税单价 str.Append(CheckDecimal(GetValue(dr, "PURCHASE_PRICE", 0), 12, 2, "含税单价")); //代理店销售价格 str.Append(CheckDecimal(GetValue(dr, "CUSTOMER_SALES_PRICE", 0), 12, 2, "代理店销售价格")); //不含税单价 str.Append(CheckDecimal(GetValue(dr, "PURCHASE_PRICE_WITHOUT_TAX", 0), 12, 2, "不含税单价")); //含税单价 //str.Append(CheckDecimal(GetValue(dr, "PURCHASE_PRICE_INCLUDED_TAX", 0), 12, 2, "含税单价")); //日元单价 str.Append(CheckDecimal(GetValue(dr, "PRICE_JP", 0), 12, 2, "日元单价")); if (str.ToString().Trim().Length > 0) { strError.Append(GetStringBuilder(dr, str.ToString().Trim())); failureData++; continue; } try { int ret = 0; ProductTable = new BaseProductTable(); if (GetValue(dr, "CODE").ToString().Length > 20) { ProductTable.CODE = CConvert.ToString(GetValue(dr, "CODE")).Substring(0, 20); } else { ProductTable.CODE = CConvert.ToString(GetValue(dr, "CODE")); } ProductTable.NAME = CConvert.ToString(GetValue(dr, "NAME")); ProductTable.SPEC = CConvert.ToString(GetValue(dr, "SPEC")); ProductTable.MODEL_NUMBER = CConvert.ToString(GetValue(dr, "MODEL_NUMBER")); ProductTable.GROUP_CODE = CConvert.ToString(GetValue(dr, "GROUP_CODE")); if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "BASIC_UNIT_CODE")))) { ProductTable.BASIC_UNIT_CODE = CConvert.ToString(GetValue(dr, "BASIC_UNIT_CODE")); } else { ProductTable.BASIC_UNIT_CODE = "01"; } ProductTable.ACCOUTING_TARGET = CConvert.ToInt32(GetValue(dr, "ACCOUTING_TARGET")); ProductTable.HS_CODE = CConvert.ToString(GetValue(dr, "HS_CODE")); ProductTable.LOCATION_CODE = CConvert.ToString(GetValue(dr, "LOCATION_CODE")); ProductTable.STOCK_FLAG = CConvert.ToInt32(GetValue(dr, "STOCK_FLAG", 1)); ProductTable.PROPERTY_FLAG = CConvert.ToInt32(GetValue(dr, "PROPERTY_FLAG", 1)); ProductTable.FROMSET_FLAG = CConvert.ToInt32(GetValue(dr, "FROMSET_FLAG", 1)); ProductTable.MECHANICAL_DISTINCTION_FLAG = CConvert.ToInt32(GetValue(dr, "MECHANICAL_DISTINCTION_FLAG", 1)); ProductTable.SAFETY_STOCK = CConvert.ToDecimal(GetValue(dr, "SAFETY_STOCK", 0)); ProductTable.STATUS_FLAG = CConvert.ToInt32(GetValue(dr, "STATUS_FLAG", CConstant.NORMAL_STATUS)); ProductTable.SELL_LOCATION = CConvert.ToInt32(GetValue(dr, "SELL_LOCATION", 1)); ProductTable.PACKAGE_MODE = CConvert.ToInt32(GetValue(dr, "PACKAGE_MODE", 1)); ProductTable.NAME_JP = CConvert.ToString(GetValue(dr, "NAME_JP")); ProductTable.PURCHASE_PRICE_INCLUDED_TAX = CConvert.ToDecimal(GetValue(dr, "PURCHASE_PRICE", 0)); ProductTable.SALES_PRICE = CConvert.ToDecimal(GetValue(dr, "SALES_PRICE", 0)); ProductTable.PURCHASE_PRICE_WITHOUT_TAX = CConvert.ToDecimal(GetValue(dr, "PURCHASE_PRICE_WITHOUT_TAX", 0)); ProductTable.CUSTOMER_SALES_PRICE = CConvert.ToDecimal(GetValue(dr, "CUSTOMER_SALES_PRICE", 0)); ProductTable.PRICE_JP = CConvert.ToDecimal(GetValue(dr, "PRICE_JP", 0)); ProductTable.CREATE_USER = _userInfo.CODE; ProductTable.LAST_UPDATE_USER = _userInfo.CODE; if (!bProduct.Exists(ProductTable.CODE)) { bProduct.Add(ProductTable); } else { bProduct.Update(ProductTable); } successData++; } catch { strError.Append(GetStringBuilder(dr, " 数据导入失败,请与系统管理员联系!").ToString()); failureData++; } } //错误记录处理 if (strError.Length > 0) { errorFilePath = WriteFile(strError.ToString()); } //备份处理 backupFilePath = BackupFile(); return(new string[] { successData.ToString(), failureData.ToString(), errorFilePath, backupFilePath }); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(BaseProductTable model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update BASE_PRODUCT set "); strSql.Append("NAME=@NAME,"); strSql.Append("SPEC=@SPEC,"); strSql.Append("MODEL_NUMBER=@MODEL_NUMBER,"); strSql.Append("GROUP_CODE=@GROUP_CODE,"); strSql.Append("BASIC_UNIT_CODE=@BASIC_UNIT_CODE,"); strSql.Append("ACCOUTING_TARGET=@ACCOUTING_TARGET,"); strSql.Append("HS_CODE=@HS_CODE,"); strSql.Append("SALES_PRICE=@SALES_PRICE,"); strSql.Append("LOCATION_CODE=@LOCATION_CODE,"); strSql.Append("STOCK_FLAG=@STOCK_FLAG,"); strSql.Append("PROPERTY_FLAG=@PROPERTY_FLAG,"); strSql.Append("FROMSET_FLAG=@FROMSET_FLAG,"); strSql.Append("MECHANICAL_DISTINCTION_FLAG=@MECHANICAL_DISTINCTION_FLAG,"); strSql.Append("SAFETY_STOCK=@SAFETY_STOCK,"); strSql.Append("STATUS_FLAG=@STATUS_FLAG,"); strSql.Append("SELL_LOCATION=@SELL_LOCATION, "); strSql.Append("PACKAGE_MODE=@PACKAGE_MODE, "); strSql.Append("NAME_JP=@NAME_JP, "); strSql.Append("PURCHASE_PRICE=@PURCHASE_PRICE, "); strSql.Append("LAST_UPDATE_USER=@LAST_UPDATE_USER,"); strSql.Append("CUSTOMER_SALES_PRICE=@CUSTOMER_SALES_PRICE, "); strSql.Append("PURCHASE_PRICE_WITHOUT_TAX=@PURCHASE_PRICE_WITHOUT_TAX, "); strSql.Append("PRICE_JP=@PRICE_JP"); strSql.Append(" where CODE=@CODE "); SqlParameter[] parameters = { new SqlParameter("@CODE", SqlDbType.VarChar, 40), new SqlParameter("@NAME", SqlDbType.NVarChar, 100), new SqlParameter("@SPEC", SqlDbType.NVarChar, 100), new SqlParameter("@MODEL_NUMBER", SqlDbType.NVarChar, 100), new SqlParameter("@GROUP_CODE", SqlDbType.VarChar, 20), new SqlParameter("@BASIC_UNIT_CODE", SqlDbType.VarChar, 20), new SqlParameter("@ACCOUTING_TARGET", SqlDbType.Int, 4), new SqlParameter("@HS_CODE", SqlDbType.VarChar, 20), new SqlParameter("@SALES_PRICE", SqlDbType.Decimal, 9), new SqlParameter("@LOCATION_CODE", SqlDbType.VarChar, 20), new SqlParameter("@STOCK_FLAG", SqlDbType.Int, 4), new SqlParameter("@PROPERTY_FLAG", SqlDbType.Int, 4), new SqlParameter("@FROMSET_FLAG", SqlDbType.Int, 4), new SqlParameter("@MECHANICAL_DISTINCTION_FLAG", SqlDbType.Int, 4), new SqlParameter("@SAFETY_STOCK", SqlDbType.Decimal, 9), new SqlParameter("@STATUS_FLAG", SqlDbType.Int, 4), new SqlParameter("@LAST_UPDATE_USER", SqlDbType.VarChar, 20), new SqlParameter("@SELL_LOCATION", SqlDbType.Int, 4), new SqlParameter("@PACKAGE_MODE", SqlDbType.Int, 4), new SqlParameter("@NAME_JP", SqlDbType.NVarChar, 100), new SqlParameter("@PURCHASE_PRICE", SqlDbType.Decimal, 9), new SqlParameter("@CUSTOMER_SALES_PRICE", SqlDbType.Decimal, 9), new SqlParameter("@PURCHASE_PRICE_WITHOUT_TAX", SqlDbType.Decimal, 9), new SqlParameter("@PRICE_JP", SqlDbType.Decimal, 9) }; parameters[0].Value = model.CODE; parameters[1].Value = model.NAME; parameters[2].Value = model.SPEC; parameters[3].Value = model.MODEL_NUMBER; parameters[4].Value = model.GROUP_CODE; parameters[5].Value = model.BASIC_UNIT_CODE; parameters[6].Value = model.ACCOUTING_TARGET; parameters[7].Value = model.HS_CODE; parameters[8].Value = model.SALES_PRICE; parameters[9].Value = model.LOCATION_CODE; parameters[10].Value = model.STOCK_FLAG; parameters[11].Value = model.PROPERTY_FLAG; parameters[12].Value = model.FROMSET_FLAG; parameters[13].Value = model.MECHANICAL_DISTINCTION_FLAG; parameters[14].Value = model.SAFETY_STOCK; parameters[15].Value = model.STATUS_FLAG; parameters[16].Value = model.LAST_UPDATE_USER; parameters[17].Value = model.SELL_LOCATION; parameters[18].Value = model.PACKAGE_MODE; parameters[19].Value = model.NAME_JP; parameters[20].Value = model.PURCHASE_PRICE_INCLUDED_TAX; parameters[21].Value = model.CUSTOMER_SALES_PRICE; parameters[22].Value = model.PURCHASE_PRICE_WITHOUT_TAX; parameters[23].Value = model.PRICE_JP; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
public void OperateInit(int currentPage) { BllProductBuildTable PBModel = bProductBuild.GetModel(_slip_number); txtWarehouse.Text = PBModel.WAREHOUSE_CODE; txtWarehouseName.Text = bCommon.GetBaseMaster("WAREHOUSE", PBModel.WAREHOUSE_CODE).Name; txtProduct.Text = PBModel.PRODUCT_CODE; txtProductName.Text = bCommon.GetBaseMaster("PRODUCT", PBModel.PRODUCT_CODE).Name; txtQuantity.Text = CConvert.ToString(PBModel.QUANTITY); txtPossibleQuantity.Text = CConvert.ToString(PBModel.QUANTITY); txtFormDate.Value = PBModel.BUILD_DATE; dgvData.Rows.Clear(); //foreach (BllProductBuildLineTable LModel in PBModel.Items) //{ // int currentRowIndex = dgvData.Rows.Add(1); // DataGridViewRow row = dgvData.Rows[currentRowIndex]; // row.Cells[1].Selected = false; // row.Cells["No"].Value = LModel.LINE_NUMBER; // row.Cells["PARTS_CODE"].Value = LModel.PRODUCT_PARTS_CODE; // BaseProductTable product = new BaseProductTable(); // BProduct bProduct = new BProduct(); // product = bProduct.GetModel(LModel.PRODUCT_PARTS_CODE); // row.Cells["PARTS_NAME"].Value = product.NAME; // row.Cells["SPEC"].Value = product.SPEC; // BAlloation bAlloation = new BAlloation(); // decimal alloationQuantity = bAlloation.GetAlloationQuantity(PBModel.WAREHOUSE_CODE, LModel.PRODUCT_PARTS_CODE); // BaseStockTable stock = new BaseStockTable(); // stock = bPurchaseOrder.GetStockModel(PBModel.WAREHOUSE_CODE, LModel.PRODUCT_PARTS_CODE); // row.Cells["NO_ALLOATION"].Value = stock.QUANTITY - alloationQuantity; // row.Cells["UNIT_CODE"].Value = PBModel.UNIT_CODE; // row.Cells["UNIT_NAME"].Value = bCommon.GetBaseMaster("UNIT", PBModel.UNIT_CODE).Name; // row.Cells["PURCHASE_QUANTITY"].Value = LModel.PARTS_QUANTITY; // row.Cells["STATUE_FLAG"].Value = "OK"; //} for (int i = (currentPage - 1) * PageSize + 1; i <= PBModel.Items.Count && (i - (currentPage - 1) * PageSize) < PageSize; i++) { int currentRowIndex = dgvData.Rows.Add(1); DataGridViewRow row = dgvData.Rows[currentRowIndex]; row.Cells[1].Selected = false; row.Cells["No"].Value = PBModel.Items[i - 1].LINE_NUMBER; row.Cells["PARTS_CODE"].Value = PBModel.Items[i - 1].PRODUCT_PARTS_CODE; row.Cells["MIN_QUANTITY"].Value = PBModel.Items[i - 1].PARTS_QUANTITY / PBModel.QUANTITY; BaseProductTable product = new BaseProductTable(); BProduct bProduct = new BProduct(); product = bProduct.GetModel(PBModel.Items[i - 1].PRODUCT_PARTS_CODE); row.Cells["PARTS_NAME"].Value = product.NAME; row.Cells["SPEC"].Value = product.SPEC; BAlloation bAlloation = new BAlloation(); decimal alloationQuantity = bAlloation.GetAlloationQuantity(PBModel.WAREHOUSE_CODE, PBModel.Items[i - 1].PRODUCT_PARTS_CODE); BaseStockTable stock = new BaseStockTable(); stock = bPurchaseOrder.GetStockModel(PBModel.WAREHOUSE_CODE, PBModel.Items[i - 1].PRODUCT_PARTS_CODE); row.Cells["NO_ALLOATION"].Value = stock.QUANTITY - alloationQuantity; row.Cells["UNIT_CODE"].Value = PBModel.UNIT_CODE; row.Cells["UNIT_NAME"].Value = bCommon.GetBaseMaster("UNIT", PBModel.UNIT_CODE).Name; row.Cells["PURCHASE_QUANTITY"].Value = PBModel.Items[i - 1].PARTS_QUANTITY; row.Cells["STATUE_FLAG"].Value = "OK"; } if (PBModel.Items.Count < PageSize * currentPage) { dgvData.Rows.Add(PageSize - PBModel.Items.Count); } }
private void FrmAlloation_Load(object sender, EventArgs e) { BllOrderHeaderTable headerTable = bOrderHeader.GetModel(_slipNumber); this.txtSlipNumber.Text = headerTable.SLIP_NUMBER; this.txtCustomerCode.Text = headerTable.CUSTOMER_CODE; this.txtCustomerName.Text = headerTable.CUSTOMER_NAME; this.txtEndCustomerCode.Text = headerTable.ENDER_CUSTOMER_CODE; this.txtEndCustomerName.Text = headerTable.ENDER_CUSTOMER_NAME; this.txtDeliveryPointCode.Text = headerTable.DELIVERY_POINT_CODE; this.txtDeliveryPointName.Text = headerTable.DELIVERY_POINT_NAME; this.txtOwnerPoNumber.Text = headerTable.CUSTOMER_PO_NUMBER; this.txtSlipDate.Text = CConvert.DateTimeToString(headerTable.SLIP_DATE, "yyyy-MM-dd"); this.txtDepartualDate.Text = CConvert.DateTimeToString(headerTable.DEPARTUAL_DATE, "yyyy-MM-dd"); DataGridViewComboBoxColumn co = this.dgvData.Columns["DEPARTUAL_WAREHOUSE"] as DataGridViewComboBoxColumn; co.DataSource = CCacheData.WAREHOUSE.Copy(); co.DisplayMember = "NAME"; co.ValueMember = "CODE"; foreach (BllOrderLineTable lineModel in headerTable.Items) { decimal quantity = CConvert.ToDecimal(lineModel.QUANTITY) - CConvert.ToDecimal(lineModel.SHIPMENT_QUANTITY); int currentRowIndex = dgvData.Rows.Add(1); DataGridViewRow dgvr = dgvData.Rows[currentRowIndex]; dgvr.Cells["NO"].Value = lineModel.LINE_NUMBER; dgvr.Cells["PRODUCT_CODE"].Value = lineModel.PRODUCT_CODE; dgvr.Cells["PRODUCT_NAME"].Value = lineModel.PRODUCT_NAME; dgvr.Cells["PRODUCT_SPEC"].Value = lineModel.PRODUCT_SPEC; dgvr.Cells["QUANTITY"].Value = quantity; dgvr.Cells["UNIT_CODE"].Value = lineModel.UNIT_NAME; dgvr.Cells["UNIT_NAME"].Value = lineModel.UNIT_NAME; dgvr.Cells["REF_STOCK"].Value = "参照"; //当前己引当的仓库的取得 BaseWarehouseTable warehouseTable = bAlloation.GetAlloationWarehouse(headerTable.SLIP_NUMBER, lineModel.LINE_NUMBER); string warehouseCode = warehouseTable.CODE; if (warehouseCode != null && warehouseCode != "") { ((DataGridViewComboBoxCell)dgvr.Cells["DEPARTUAL_WAREHOUSE"]).Style.NullValue = warehouseTable.NAME + " "; } else { warehouseCode = headerTable.DEPARTUAL_WAREHOUSE_CODE; ((DataGridViewComboBoxCell)dgvr.Cells["DEPARTUAL_WAREHOUSE"]).Style.NullValue = headerTable.DEPARTUAL_WAREHOUSE_NAME + " "; } dgvr.Cells["DEFAULT_WAREHOUSE_CODE"].Value = warehouseCode; //当前仓库实际库存的取得 BaseStockTable stockTable = bStock.GetModel(warehouseCode, lineModel.PRODUCT_CODE); decimal stock = 0; if (stockTable != null) { stock = CConvert.ToDecimal(stockTable.QUANTITY); } //己使用的引当数量,当前订单除外,己出库数量除外 stock -= bAlloation.GetAlloationQuantity(headerTable.SLIP_NUMBER, warehouseCode, lineModel.PRODUCT_CODE); dgvr.Cells["STOCK"].Value = stock; dgvr.Cells["ALLOATION_QUANTITY"].Value = quantity; BaseProductTable pTable = null; if (lineModel.PRODUCT_CODE.Length >= 4 && lineModel.PRODUCT_CODE.Substring(0, 4) == "9999") { pTable = bProduct.GetModel(lineModel.PRODUCT_CODE.Substring(0, 4)); } else { pTable = bProduct.GetModel(lineModel.PRODUCT_CODE); } if (pTable.STOCK_FLAG == 2) { dgvr.Cells["IS_ALLOATION"].Value = "OK"; } else if (quantity > stock) { dgvr.Cells["IS_ALLOATION"].Value = "NG"; } else { dgvr.Cells["IS_ALLOATION"].Value = "OK"; } } }
public override string[] doUpdateDB() { BaseProductTable SpecificationTable = null; BProduct bSpecification = new BProduct(); StringBuilder strError = new StringBuilder(); int successData = 0; int failureData = 0; string errorFilePath = ""; string backupFilePath = ""; //数据导入处理 foreach (DataRow dr in _csvDataTable.Rows) { StringBuilder str = new StringBuilder(); //规格型号编号 if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "CODE")))) { str.Append(CheckString(GetValue(dr, "CODE"), 20, "规格型号编号")); } else { str.Append("规格型号编号不能为空!"); } //规格型号名称 str.Append(CheckLenght(GetValue(dr, "NAME"), 100, "规格型号名称")); //规格 str.Append(CheckLenght(GetValue(dr, "SPEC"), 50, "规格")); //单位 if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "BASIC_UNIT_CODE")))) { str.Append(CheckUnit(CConvert.ToString(GetValue(dr, "BASIC_UNIT_CODE")), "单位编号")); } //销售单价 str.Append(CheckDecimal(GetValue(dr, "SALES_PRICE", 0), 12, 2, "销售单价")); if (str.ToString().Trim().Length > 0) { strError.Append(GetStringBuilder(dr, str.ToString().Trim())); failureData++; continue; } try { SpecificationTable = new BaseProductTable(); SpecificationTable.CODE = CConvert.ToString(GetValue(dr, "CODE")); SpecificationTable.NAME = CConvert.ToString(GetValue(dr, "NAME")); SpecificationTable.SPEC = CConvert.ToString(GetValue(dr, "SPEC")); SpecificationTable.BASIC_UNIT_CODE = CConvert.ToString(GetValue(dr, "BASIC_UNIT_CODE")); SpecificationTable.SALES_PRICE = CConvert.ToDecimal(GetValue(dr, "SALES_PRICE")); SpecificationTable.PRODUCT_FLAG = CConstant.PRODUCT_FLAG_SPEC; SpecificationTable.STATUS_FLAG = CConstant.INIT; SpecificationTable.CREATE_USER = _userInfo.CODE; SpecificationTable.LAST_UPDATE_USER = _userInfo.CODE; if (!bSpecification.Exists(SpecificationTable.CODE)) { bSpecification.Add(SpecificationTable); } else { bSpecification.Update(SpecificationTable); } successData++; } catch { strError.Append(GetStringBuilder(dr, " 数据导入失败,请与系统管理员联系!").ToString()); failureData++; } } //错误记录处理 if (strError.Length > 0) { errorFilePath = WriteFile(strError.ToString()); } //备份处理 backupFilePath = BackupFile(); return(new string[] { successData.ToString(), failureData.ToString(), errorFilePath, backupFilePath }); }
private void btnSave_Click_1(object sender, EventArgs e) { if (CheckInput()) { if (_currentProductTable == null) { _currentProductTable = new BaseProductTable(); } _currentProductTable.CODE = txtCode.Text; _currentProductTable.NAME = txtName.Text; _currentProductTable.SPEC = txtSpec.Text; _currentProductTable.MODEL_NUMBER = txtModelNumber.Text; _currentProductTable.GROUP_CODE = txtGroupCode.Text; _currentProductTable.BASIC_UNIT_CODE = txtBasic.Text; _currentProductTable.HS_CODE = txtHsCode.Text; _currentProductTable.SALES_PRICE = Convert.ToDecimal(txtPrice.Text); _currentProductTable.LAST_UPDATE_USER = _userInfo.CODE; _currentProductTable.NAME_JP = txtName_Jp.Text; _currentProductTable.PURCHASE_PRICE_INCLUDED_TAX = CConvert.ToDecimal(txtPurchasePrice.Text); _currentProductTable.CUSTOMER_SALES_PRICE = CConvert.ToDecimal(txtCustomerSalesPrice.Text); _currentProductTable.PURCHASE_PRICE_WITHOUT_TAX = CConvert.ToDecimal(txtPurchasePriceWithoutTax.Text); _currentProductTable.PRICE_JP = CConvert.ToDecimal(txtPrice_Jp.Text.Trim()); if (rAccout1.Checked) { _currentProductTable.ACCOUTING_TARGET = 1; } else { _currentProductTable.ACCOUTING_TARGET = 2; } if (rStock1.Checked) { _currentProductTable.STOCK_FLAG = 1; } else { _currentProductTable.STOCK_FLAG = 2; } if (rProperty1.Checked) { _currentProductTable.PROPERTY_FLAG = 1; } else { _currentProductTable.PROPERTY_FLAG = 2; } if (rbNoFromSet.Checked) { _currentProductTable.FROMSET_FLAG = 1; } else { _currentProductTable.FROMSET_FLAG = 2; } if (rbBody.Checked) { _currentProductTable.MECHANICAL_DISTINCTION_FLAG = 1; } else { _currentProductTable.MECHANICAL_DISTINCTION_FLAG = 2; } if (rdoChaina.Checked) { _currentProductTable.SELL_LOCATION = CConstant.PRODUCT_SELL_CHINA; } else { _currentProductTable.SELL_LOCATION = CConstant.PRODUCT_SELL_JAPAN; } if (rdoAlone.Checked) { _currentProductTable.PACKAGE_MODE = CConstant.PRODUCT_PACKAGE_ALONT; } else { _currentProductTable.PACKAGE_MODE = CConstant.PRODUCT_PACKAGE_COMPOSE; } try { if (bProduct.Exists(txtCode.Text.Trim())) { bProduct.Update(_currentProductTable); } else { _currentProductTable.CREATE_USER = _userInfo.CODE; bProduct.Add(_currentProductTable); } } catch (Exception ex) { //log.error MessageBox.Show(""); return; } result = DialogResult.OK; this.Close(); } }
private void dgvData_CellValidated(object sender, DataGridViewCellEventArgs e) { try { DataGridViewRow dr = dgvData.Rows[e.RowIndex]; if (e.ColumnIndex == dgvData.Columns["PRODUCT_CODE"].Index) { string code = dr.Cells["PRODUCT_CODE"].Value.ToString().Trim(); BaseProductTable productTable = bProduct.GetModel(code); if (productTable != null) { dr.Cells["PRODUCT_CODE"].Value = productTable.CODE; dr.Cells["PRODUCT_NAME"].Value = productTable.NAME; BaseStockTable stock = bStock.GetModel(txtDepartualCode.Text.Trim(), productTable.CODE); BAlloation bAlloation = new BAlloation(); decimal alloationQuantity = bAlloation.GetAlloationQuantity(txtDepartualCode.Text.Trim(), productTable.CODE); dr.Cells["QUANTITY"].Value = stock.QUANTITY - alloationQuantity; dr.Cells["UNIT_NAME"].Value = bCommon.GetBaseMaster("UNIT", productTable.BASIC_UNIT_CODE).Name; dr.Cells["UNIT_CODE"].Value = productTable.BASIC_UNIT_CODE; dr.Cells["TRANSFER_QUANTITY"].Value = "1"; } else { MessageBox.Show("商品不存在.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); dr.Cells["PRODUCT_CODE"].Value = null; dr.Cells["PRODUCT_NAME"].Value = null; dr.Cells["QUANTITY"].Value = "0"; dr.Cells["UNIT_NAME"].Value = null; dr.Cells["UNIT_CODE"].Value = null; dr.Cells["TRANSFER_QUANTITY"].Value = "0"; dr.Cells["CODE"].Selected = true; } } else if (e.ColumnIndex == dgvData.Columns["TRANSFER_QUANTITY"].Index) { if (dr.Cells["TRANSFER_QUANTITY"].Value == null) { dr.Cells["TRANSFER_QUANTITY"].Value = 0; MessageBox.Show("调拨数量不能为空!"); } else { Int32 price; if (!Int32.TryParse(CConvert.ToString(dr.Cells["TRANSFER_QUANTITY"].Value), System.Globalization.NumberStyles.Integer, System.Globalization.NumberFormatInfo.CurrentInfo, out price)) { MessageBox.Show("调拨数量只能为整数,请重新输入!"); dr.Cells["TRANSFER_QUANTITY"].Value = "0"; dr.Cells["TRANSFER_QUANTITY"].Selected = true; } } } } catch (Exception ex) { //MessageBox.Show("PRODUCT_CODE"); Logger.Error(ex.Message, ex); } }
private void btnInquirySheet_Click(object sender, EventArgs e) { if (dgvData.SelectedRows.Count > 0) { Hashtable ht = new Hashtable(); DataTable dt = new DataTable(); DataGridViewRow row = dgvData.SelectedRows[0]; BllPurchaseOrderTable purchase = bPurchaseOrder.GetModel(CConvert.ToString(row.Cells["SLIP_NUMBER"].Value)); BaseSupplierTable supplier = bSupplier.GetModel(CConvert.ToString(row.Cells["SUPPLIER_CODE"].Value)); if (purchase == null) { purchase = new BllPurchaseOrderTable(); } if (supplier == null) { supplier = new BaseSupplierTable(); } ht.Add("&SUPPLIER", supplier.NAME); ht.Add("&CONTACT_NAME", supplier.CONTACT_NAME); ht.Add("&MOBIL_NUMBER", supplier.MOBIL_NUMBER); ht.Add("&PHONE_NUMBER", supplier.PHONE_NUMBER); ht.Add("&FAX_NUMBER", supplier.FAX_NUMBER); dt.Columns.Add("No"); dt.Columns.Add("SPEC"); dt.Columns.Add("NAME"); dt.Columns.Add("UNIT_NAME"); dt.Columns.Add("QUANTITY"); dt.Columns.Add("PRICE"); dt.Columns.Add("TOTAL_AMOUNT"); dt.Columns.Add("APPLICATION"); dt.Columns.Add("MEMO"); DataRow rows = null; int i = 0; string name = ""; decimal TOTAL = 0; foreach (BllPurchaseOrderLineTable POLTable in purchase.Items) { rows = dt.NewRow(); rows["No"] = POLTable.LINE_NUMBER; BaseProductTable product = bProduct.GetModel(POLTable.PRODUCT_CODE); if (product != null) { rows["SPEC"] = product.CODE; rows["NAME"] = product.NAME; if (i == 0) { name = product.NAME; } if (bCommon.GetBaseMaster("UNIT", POLTable.UNIT_CODE) != null) { rows["UNIT_NAME"] = bCommon.GetBaseMaster("UNIT", POLTable.UNIT_CODE).Name; } } rows["QUANTITY"] = (int)POLTable.QUANTITY; rows["PRICE"] = POLTable.PRICE; rows["TOTAL_AMOUNT"] = POLTable.AMOUNT_INCLUDED_TAX; rows["MEMO"] = purchase.MEMO; dt.Rows.Add(rows); TOTAL += POLTable.AMOUNT_INCLUDED_TAX; i++; } ht.Add("&TOTAL", TOTAL); SaveFileDialog sf = new SaveFileDialog(); sf.FileName = "HD_INQUIRY_" + supplier.NAME + "_" + purchase.SLIP_DATE.ToString("yyyyMMdd") + ".xls"; sf.Filter = "(文件)|*.xls;*.xlsx"; if (sf.ShowDialog(this) == DialogResult.OK) { if (dt.Rows.Count > 0) { int ret = CExport.DataTableToExcel_IS(@"rpt\HD_INQUIRY.xls", sf.FileName, dt, ht); if (CConstant.EXPORT_FAILURE.Equals(ret)) { MessageBox.Show("导出失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (CConstant.EXPORT_SUCCESS.Equals(ret)) { MessageBox.Show("导出成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (CConstant.EXPORT_RUNNING.Equals(ret)) { MessageBox.Show("文件正在运行,重新生成文件失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (CConstant.EXPORT_TEMPLETE_FILE_NOT_EXIST.Equals(ret)) { MessageBox.Show("模版文件不存在。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show("明细信息不存在。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } }
private void dgvData_CellValidated(object sender, DataGridViewCellEventArgs e) { try { DataGridViewRow dr = dgvData.Rows[e.RowIndex]; if (e.ColumnIndex == dgvData.Columns["PRODUCT_CODE"].Index) { string code = dr.Cells["PRODUCT_CODE"].Value.ToString().Trim(); BaseProductTable productTable = bProduct.GetModel(code); if (productTable != null) { dr.Cells["PRODUCT_CODE"].Value = productTable.CODE; dr.Cells["PRODUCT_NAME"].Value = productTable.NAME; dr.Cells["SPEC"].Value = productTable.SPEC + " " + productTable.MODEL_NUMBER; dr.Cells["UNIT_NAME"].Value = bCommon.GetBaseMaster("UNIT", productTable.BASIC_UNIT_CODE).Name; dr.Cells["UNIT_CODE"].Value = productTable.BASIC_UNIT_CODE; dr.Cells["SANCTION_NUMBER"].Value = "1"; BaseStockTable stock = bStock.GetModel(txtWarehouseCode.Text.Trim(), productTable.CODE); if (stock == null) { dr.Cells["QUANTITY"].Value = "0"; } else { dr.Cells["QUANTITY"].Value = stock.QUANTITY; } } else { MessageBox.Show("商品不存在.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); dr.Cells["PRODUCT_CODE"].Value = null; dr.Cells["PRODUCT_NAME"].Value = null; dr.Cells["SPEC"].Value = null; dr.Cells["QUANTITY"].Value = "0"; dr.Cells["UNIT_NAME"].Value = null; dr.Cells["UNIT_CODE"].Value = null; dr.Cells["SANCTION_NUMBER"].Value = "0"; dr.Cells["CODE"].Selected = true; } } else if (e.ColumnIndex == dgvData.Columns["SANCTION_NUMBER"].Index) { if (dr.Cells["SANCTION_NUMBER"].Value == null) { dr.Cells["SANCTION_NUMBER"].Value = "0"; MessageBox.Show("修改数量不能为空!"); } else { //Int32 price; //if (!Int32.TryParse(CConvert.ToString(dr.Cells["SANCTION_NUMBER"].Value), // System.Globalization.NumberStyles.Integer, // System.Globalization.NumberFormatInfo.CurrentInfo, out price)) //{ // MessageBox.Show("处分数只能为整数,请重新输入!"); // dr.Cells["SANCTION_NUMBER"].Value = "0"; // dr.Cells["SANCTION_NUMBER"].Selected = true; //} decimal sanctionNumber = CConvert.ToDecimal(dr.Cells["SANCTION_NUMBER"].Value); decimal quantity = CConvert.ToDecimal(dr.Cells["QUANTITY"].Value); if ((sanctionNumber + quantity) < 0) { MessageBox.Show("库存数量与修改数量之和不能小于0!"); dr.Cells["SANCTION_NUMBER"].Value = "0"; } } } } catch (Exception ex) { //MessageBox.Show("PRODUCT_CODE"); Logger.Error(ex.Message, ex); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvData_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex != -1) { DataGridViewRow dgvr = dgvData.Rows[e.RowIndex]; if (e.ColumnIndex == dgvData.Columns["DEPARTUAL_WAREHOUSE"].Index) { string warehouseCode = CConvert.ToString(dgvr.Cells["DEPARTUAL_WAREHOUSE"].Value); string productCode = CConvert.ToString(dgvr.Cells["PRODUCT_CODE"].Value); string orderSlipNumber = CConvert.ToString(txtSlipNumber.Text); BaseStockTable stockTable = bStock.GetModel(warehouseCode, productCode); decimal stock = 0; if (stockTable != null) { stock = CConvert.ToDecimal(stockTable.QUANTITY); } stock -= bAlloation.GetAlloationQuantity(orderSlipNumber, warehouseCode, productCode); dgvr.Cells["STOCK"].Value = stock; decimal quantity = CConvert.ToDecimal(dgvr.Cells["QUANTITY"].Value); decimal alloationQuantity = CConvert.ToDecimal(dgvr.Cells["ALLOATION_QUANTITY"].Value); BaseProductTable pTable = null; string code = CConvert.ToString(dgvr.Cells["PRODUCT_CODE"].Value); if (code.Length >= 4 && code.Substring(0, 4) == "9999") { pTable = bProduct.GetModel(code.Substring(0, 4)); } else { pTable = bProduct.GetModel(code); } if (pTable != null) { if (pTable.STOCK_FLAG == 2) { dgvr.Cells["IS_ALLOATION"].Value = "OK"; if (e.RowIndex % 2 == 0) { dgvr.DefaultCellStyle.BackColor = Color.White; } else { dgvr.DefaultCellStyle.BackColor = COLOR_DIFF_ROW; } } else if (alloationQuantity > stock) { dgvr.Cells["IS_ALLOATION"].Value = "NG"; dgvr.DefaultCellStyle.BackColor = COLOR_NG; } else { dgvr.Cells["IS_ALLOATION"].Value = "OK"; if (e.RowIndex % 2 == 0) { dgvr.DefaultCellStyle.BackColor = Color.White; } else { dgvr.DefaultCellStyle.BackColor = COLOR_DIFF_ROW; } } } } } }
private void dgvData_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (e.ColumnIndex == dgvData.Columns["BtnProduct"].Index) { StringBuilder sb = new StringBuilder(); sb.Append(" PRODUCT_FLAG = 2 "); sb.AppendFormat(" AND SUPPLIER_CODE LIKE '{0}%'", txtSupplierCode.Text.Trim()); FrmMasterSearch frm = new FrmMasterSearch("PRODUCT", sb.ToString()); if (frm.ShowDialog(this) == DialogResult.OK) { if (frm.BaseMasterTable != null) { DataGridViewRow dr = dgvData.Rows[e.RowIndex]; string code = frm.BaseMasterTable.Code; BaseProductTable productTable = bProduct.GetModel(code); string taxation = cboTax.Text.Replace("%", ""); if (productTable != null) { if (!productTable.CODE.Equals(dr.Cells["OLD_CODE"].Value)) //商品编号未变换 { dr.Cells["PRODUCT_CODE"].Value = productTable.CODE; dr.Cells["OLD_CODE"].Value = productTable.CODE; dr.Cells["NAME"].Value = productTable.NAME; dr.Cells["SPEC"].Value = productTable.SPEC + " " + productTable.MODEL_NUMBER; dr.Cells["QUANTITY"].Value = 1; if (bCommon.GetBaseMaster("UNIT", productTable.BASIC_UNIT_CODE) != null) { dr.Cells["UNIT_NAME"].Value = bCommon.GetBaseMaster("UNIT", productTable.BASIC_UNIT_CODE).Name; } dr.Cells["UNIT_CODE"].Value = productTable.BASIC_UNIT_CODE; dr.Cells["PRICE"].Value = productTable.PURCHASE_PRICE; dr.Cells["AMOUNT"].Value = productTable.PURCHASE_PRICE; dr.Cells["AMOUNT_INCLUDED_TAX"].Value = productTable.SALES_PRICE * ((100 + Convert.ToDecimal(taxation)) / 100); } } else { MessageBox.Show("商品不存在.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); dr.Cells["PRODUCT_CODE"].Value = ""; dr.Cells["NAME"].Value = ""; dr.Cells["SPEC"].Value = ""; dr.Cells["QUANTITY"].Value = "0"; dr.Cells["UNIT_NAME"].Value = ""; dr.Cells["UNIT_CODE"].Value = ""; dr.Cells["PRICE"].Value = "0"; dr.Cells["AMOUNT"].Value = "0"; dr.Cells["AMOUNT_INCLUDED_TAX"].Value = "0"; //dr.Cells["CODE"].Selected = true; } } } frm.Dispose(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// DataGridView 引当数量的验证 /// </summary> private void dgvData_CellValidated(object sender, DataGridViewCellEventArgs e) { try { DataGridViewRow dgvr = dgvData.Rows[e.RowIndex]; if (e.ColumnIndex == dgvData.Columns["ALLOATION_QUANTITY"].Index) { // //未引当数量 decimal quantity = CConvert.ToDecimal(dgvr.Cells["QUANTITY"].Value); //引当数 decimal alloationQuantity = CConvert.ToDecimal(dgvr.Cells["ALLOATION_QUANTITY"].Value); //利用可能引当数量 decimal stockQuantity = CConvert.ToDecimal(dgvr.Cells["STOCK"].Value); if (alloationQuantity == 0) { try { decimal.Parse(CConvert.ToString(dgvr.Cells["ALLOATION_QUANTITY"].Value)); } catch { MessageBox.Show("请输入正确的引当数量。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); alloationQuantity = quantity; } } else if (alloationQuantity < 0) { MessageBox.Show("引当数量不能为负数。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); alloationQuantity = quantity; } else if (alloationQuantity > quantity) { MessageBox.Show("引当数量不能大于未引当数量。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); alloationQuantity = quantity; } dgvr.Cells["ALLOATION_QUANTITY"].Value = alloationQuantity; BaseProductTable pTable = bProduct.GetModel(CConvert.ToString(dgvr.Cells["PRODUCT_CODE"].Value)); if (pTable.STOCK_FLAG == 2) { dgvr.Cells["IS_ALLOATION"].Value = "OK"; if (e.RowIndex % 2 == 0) { dgvr.DefaultCellStyle.BackColor = Color.White; } else { dgvr.DefaultCellStyle.BackColor = COLOR_DIFF_ROW; } } else if (alloationQuantity > stockQuantity) { dgvr.Cells["IS_ALLOATION"].Value = "NG"; dgvr.DefaultCellStyle.BackColor = COLOR_NG; } else if (alloationQuantity <= stockQuantity) { dgvr.Cells["IS_ALLOATION"].Value = "OK"; if (e.RowIndex % 2 == 0) { dgvr.DefaultCellStyle.BackColor = Color.White; } else { dgvr.DefaultCellStyle.BackColor = COLOR_DIFF_ROW; } } } } catch (Exception ex) { } }
/// <summary> /// 列编辑完成后的验证事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvData_CellValidated(object sender, DataGridViewCellEventArgs e) { try { DataGridViewRow dr = dgvData.Rows[e.RowIndex]; string taxation = cboTax.Text.Replace("%", ""); if (e.ColumnIndex == dgvData.Columns["PRODUCT_CODE"].Index) { string code = CConvert.ToString(dr.Cells["PRODUCT_CODE"].Value); if (code != "") { BaseProductTable productTable = bProduct.GetModel(code); if (productTable != null) { if (!code.Equals(dr.Cells["OLD_CODE"].Value)) { dr.Cells["PRODUCT_CODE"].Value = productTable.CODE; dr.Cells["OLD_CODE"].Value = productTable.CODE; dr.Cells["NAME"].Value = productTable.NAME; dr.Cells["SPEC"].Value = productTable.SPEC + " " + productTable.MODEL_NUMBER; dr.Cells["QUANTITY"].Value = 1; dr.Cells["UNIT_CODE"].Value = productTable.BASIC_UNIT_CODE; dr.Cells["UNIT_NAME"].Value = bCommon.GetBaseMaster("UNIT", productTable.BASIC_UNIT_CODE).Name; dr.Cells["PRICE"].Value = productTable.SALES_PRICE; dr.Cells["AMOUNT"].Value = productTable.SALES_PRICE; dr.Cells["AMOUNT_INCLUDED_TAX"].Value = Convert.ToDecimal(dr.Cells["AMOUNT"].Value) * ((100 + Convert.ToDecimal(taxation)) / 100); } } else { MessageBox.Show("商品不存在.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); dr.Cells["PRODUCT_CODE"].Value = ""; dr.Cells["NAME"].Value = ""; dr.Cells["SPEC"].Value = ""; dr.Cells["QUANTITY"].Value = "0"; dr.Cells["UNIT_CODE"].Value = ""; dr.Cells["UNIT_NAME"].Value = ""; dr.Cells["PRICE"].Value = "0"; dr.Cells["AMOUNT"].Value = "0"; dr.Cells["AMOUNT_INCLUDED_TAX"].Value = "0"; //dr.Cells["CODE"].Selected = true; ; } } } else if (e.ColumnIndex == dgvData.Columns["QUANTITY"].Index) { string quantity = CConvert.ToString(dr.Cells["QUANTITY"].Value); if (quantity == "") { dr.Cells["QUANTITY"].Value = 0; } else { dr.Cells["QUANTITY"].Value = CConvert.ToDecimal(quantity); } dr.Cells["AMOUNT"].Value = Convert.ToDecimal(quantity) * Convert.ToDecimal(dr.Cells["PRICE"].Value.ToString().Trim()); dr.Cells["AMOUNT_INCLUDED_TAX"].Value = Convert.ToDecimal(dr.Cells["AMOUNT"].Value) * ((100 + Convert.ToDecimal(taxation)) / 100); } else if (e.ColumnIndex == dgvData.Columns["PRICE"].Index) { string price = CConvert.ToString(dr.Cells["PRICE"].Value); if (price == "") { dr.Cells["PRICE"].Value = 0; } else { dr.Cells["PRICE"].Value = CConvert.ToDecimal(price); } dr.Cells["AMOUNT"].Value = Convert.ToDecimal(price) * Convert.ToDecimal(dr.Cells["QUANTITY"].Value.ToString().Trim()); dr.Cells["AMOUNT_INCLUDED_TAX"].Value = Convert.ToDecimal(dr.Cells["AMOUNT"].Value) * ((100 + Convert.ToDecimal(taxation)) / 100); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnRelieve_Click(object sender, EventArgs e) { if (RelieveCheck()) { BllProductBuildTable PBModel = new BllProductBuildTable(); BllProductBuildLineTable PBLModel = null; int i = 1; PBModel.SLIP_NUMBER = CConvert.ToString(CConvert.ToInt32(bProductBuild.GetBuildMaxSlipNumber()) + 1).PadLeft(4, '0'); BaseProductTable product = bProduct.GetModel(txtProduct.Text.Trim()); PBModel.PRODUCT_CODE = txtProduct.Text.Trim(); PBModel.WAREHOUSE_CODE = txtWarehouse.Text.Trim(); PBModel.QUANTITY = CConvert.ToDecimal(txtRelieveQuantity.Text.Trim()); PBModel.COMPANY_CODE = _userInfo.COMPANY_CODE; PBModel.BUILD_DATE = txtSlipDate.Value; BaseStockTable stock = new BaseStockTable(); stock = bPurchaseOrder.GetStockModel(txtWarehouse.Text.Trim(), txtProduct.Text.Trim()); PBModel.UNIT_CODE = stock.UNIT_CODE; PBModel.STATUS_FLAG = CConstant.RELIEVE_STATUS; PBModel.CREATE_USER = _userInfo.CODE; PBModel.LAST_UPDATE_USER = _userInfo.CODE; DataSet ds = bProductBuild.getParts(txtProduct.Text.Trim()); foreach (DataRow row in ds.Tables[0].Rows) { PBLModel = new BllProductBuildLineTable(); PBLModel.SLIP_NUMBER = PBModel.SLIP_NUMBER; PBLModel.LINE_NUMBER = i; PBLModel.PRODUCT_PARTS_CODE = CConvert.ToString(row["PRODUCT_PART_CODE"]); PBLModel.PARTS_QUANTITY = CConvert.ToDecimal(row["QUANTITY"]) * PBModel.QUANTITY; BaseStockTable stock1 = new BaseStockTable(); stock1 = bPurchaseOrder.GetStockModel(txtWarehouse.Text.Trim(), PBLModel.PRODUCT_PARTS_CODE); PBLModel.UNIT_CODE = stock1.UNIT_CODE; PBLModel.STATUS_FLAG = CConstant.INIT_STATUS; if (PBLModel.SLIP_NUMBER != null) { PBModel.AddItem(PBLModel); } i++; } int result = 0; try { result = bProductBuild.AddRelieve(PBModel); if (result <= 0) { string errorLog = "解除失败,请重试或与管理员联系."; MessageBox.Show(errorLog, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { txtWarehouse.Text = ""; txtWarehouseName.Text = ""; txtProduct.Text = ""; txtProductName.Text = ""; txtNoAlloation.Text = ""; txtRelieveQuantity.Text = ""; txtSlipDate.Value = DateTime.Now; MessageBox.Show("保存成功", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show("保存失败,系统错误,请与管理员联系.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); Logger.Error("组成失败!", ex); } } }
public override string[] doUpdateDB() { BaseProductTable ProductTable = null; BProduct bProduct = new BProduct(); StringBuilder strError = new StringBuilder(); int successData = 0; int failureData = 0; string errorFilePath = ""; string backupFilePath = ""; //数据导入处理 foreach (DataRow dr in _csvDataTable.Rows) { StringBuilder str = new StringBuilder(); //外购件编号 if (GetValue(dr, "CODE").ToString().Length > 20) { if (!string.IsNullOrEmpty(GetValue(dr, "CODE").ToString().Substring(0, 20))) { str.Append(CheckString(GetValue(dr, "CODE"), "外购件编号")); } else { str.Append("外购件编号不能为空!"); } } else { if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "CODE")))) { str.Append(CheckString(GetValue(dr, "CODE"), "外购件编号")); } else { str.Append("外购件编号不能为空!"); } } //外购件名称 str.Append(CheckLenght(GetValue(dr, "NAME"), 100, "外购件名称")); //外购件规格 str.Append(CheckLenght(GetValue(dr, "SPEC"), 50, "外购件规格")); //外购件类别编号 if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "GROUP_CODE")))) { str.Append(CheckProductGroup(CConvert.ToString(GetValue(dr, "GROUP_CODE")), "外购件类别编号")); } //外购件单位 if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "BASIC_UNIT_CODE")))) { str.Append(CheckUnit(CConvert.ToString(GetValue(dr, "BASIC_UNIT_CODE")), "外购件单位")); } //外购件销售价格 str.Append(CheckDecimal(GetValue(dr, "SALES_PRICE", 0), 12, 2, "外购件销售价格")); //外购件采购价格 str.Append(CheckDecimal(GetValue(dr, "PURCHASE_PRICE", 0), 12, 2, "外购件采购价格")); //外购件安全库存 str.Append(CheckDecimal(GetValue(dr, "SAFETY_STOCK", 0), 12, 2, "外购件安全库存")); if (str.ToString().Trim().Length > 0) { strError.Append(GetStringBuilder(dr, str.ToString().Trim())); failureData++; continue; } try { int ret = 0; ProductTable = new BaseProductTable(); if (GetValue(dr, "CODE").ToString().Length > 20) { ProductTable.CODE = CConvert.ToString(GetValue(dr, "CODE")).Substring(0, 20); } else { ProductTable.CODE = CConvert.ToString(GetValue(dr, "CODE")); } ProductTable.NAME = CConvert.ToString(GetValue(dr, "NAME")); ProductTable.SPEC = CConvert.ToString(GetValue(dr, "SPEC")); ProductTable.GROUP_CODE = CConvert.ToString(GetValue(dr, "GROUP_CODE")); if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "BASIC_UNIT_CODE")))) { ProductTable.BASIC_UNIT_CODE = CConvert.ToString(GetValue(dr, "BASIC_UNIT_CODE")); } else { ProductTable.BASIC_UNIT_CODE = "01"; } ProductTable.SALES_PRICE = Convert.ToDecimal(GetValue(dr, "SALES_PRICE", 0)); ProductTable.PURCHASE_PRICE = Convert.ToDecimal(GetValue(dr, "PURCHASE_PRICE", 0)); ProductTable.SAFETY_STOCK = CConvert.ToDecimal(GetValue(dr, "SAFETY_STOCK", 0)); ProductTable.PRODUCT_FLAG = CConstant.PRODUCT_FLAG_PURCHASE; ProductTable.STATUS_FLAG = CConstant.INIT; ProductTable.CREATE_USER = _userInfo.CODE; ProductTable.LAST_UPDATE_USER = _userInfo.CODE; if (!bProduct.Exists(ProductTable.CODE)) { bProduct.Add(ProductTable); } else { bProduct.Update(ProductTable); } successData++; } catch { strError.Append(GetStringBuilder(dr, " 数据导入失败,请与系统管理员联系!").ToString()); failureData++; } } //错误记录处理 if (strError.Length > 0) { errorFilePath = WriteFile(strError.ToString()); } //备份处理 backupFilePath = BackupFile(); return(new string[] { successData.ToString(), failureData.ToString(), errorFilePath, backupFilePath }); }