/// <summary> /// 增加一条数据 /// </summary> public bool Add(BasicDataEntity model) { StringBuilder strSql = new StringBuilder( ); strSql.Append("insert into T_BasicData("); strSql.Append("ModelCodeID,ModelCode,HSCodeInCat,EnglishProductName,LocalProductName,QuantityUnit,SentialFactor,LocalComposition,SupervisionCondition,DoubleOrSet,Description,ExaminingReport,Size)"); strSql.Append(" values ("); strSql.Append("@ModelCodeID,@ModelCode,@HSCodeInCat,@EnglishProductName,@LocalProductName,@QuantityUnit,@SentialFactor,@LocalComposition,@SupervisionCondition,@DoubleOrSet,@Description,@ExaminingReport,@Size)"); SqlParameter[] parameters = { new SqlParameter("@ModelCodeID", SqlDbType.Int, 4), new SqlParameter("@ModelCode", SqlDbType.VarChar, 50), new SqlParameter("@HSCodeInCat", SqlDbType.VarChar, 50), new SqlParameter("@EnglishProductName", SqlDbType.VarChar, 255), new SqlParameter("@LocalProductName", SqlDbType.VarChar, 255), new SqlParameter("@QuantityUnit", SqlDbType.VarChar, 50), new SqlParameter("@SentialFactor", SqlDbType.VarChar, 2048), new SqlParameter("@LocalComposition", SqlDbType.VarChar, 255), new SqlParameter("@SupervisionCondition", SqlDbType.VarChar, 255), new SqlParameter("@DoubleOrSet", SqlDbType.VarChar, 255), new SqlParameter("@Description", SqlDbType.VarChar, 2048), new SqlParameter("@ExaminingReport", SqlDbType.VarChar, 255), new SqlParameter("@Size", SqlDbType.VarChar, 255) }; parameters[0].Value = GetMaxId() + 1; parameters[1].Value = model.ModelCode; parameters[2].Value = model.HSCodeInCat; //parameters[3].Value = model.ModelCodeDescription; parameters[3].Value = model.EnglishProductName; parameters[4].Value = model.LocalProductName; parameters[5].Value = model.QuantityUnit; parameters[6].Value = model.SentialFactor; parameters[7].Value = model.LocalComposition; parameters[8].Value = model.SupervisionCondition; parameters[9].Value = model.DoubleOrSet; parameters[10].Value = model.Description; parameters[11].Value = model.ExaminingReport; parameters[12].Value = model.Size; int rows = SqlHelper.ExecuteSql(SqlHelper.LocalSqlServer, strSql.ToString( ), parameters); if (rows > 0) { return(true); } else { return(false); } }
//public bool ExcuteDataInput( DataTable excelDT,string fileName, ref string errMsg ) //{ // foreach ( DataRow row in excelDT.Rows ) // { // OriginalCLPEntity model=new OriginalCLPEntity( ); // model.ItemCode=row["ITEM CODE"].ToString( ); // model.ShippingNumber=row["SHIPPING NUMBER"].ToString( ); // model.OrderNumber=row["ORDER NUMBER"].ToString( ); // model.OriginalPONumber=row["ORIGINAL PO NUMBER"].ToString( ); // model.PalletNumber=row["PALLET_NUMBER"].ToString( ); // model.ParcelNumber=row["PARCEL NUMBER"].ToString( ); // model.ModelCode=row["MODEL CODE"].ToString( ); // model.Origin=row["ORIGIN"].ToString( ); // model.Quantity=row["QUANTITY"].ToString( ); // model.QuantityUnit=row["QUANTITY UNIT"].ToString( ); // model.DispatchingKey=row["DISPATCHING KEY"].ToString( ); // model.EnglishComposition=row["English Composition"].ToString( ); // model.LocalComposition=row["Local Composition [english composition]"].ToString( ); // model.Size=row["SIZE"].ToString( ); // model.EnglishDescription=row["English Description"].ToString( ); // model.LocalDescription=row["Local Description [english description]"].ToString( ); // model.Brand=row["BRAND"].ToString( ); // model.TypeOfGoods=row["TYPE OF GOODS"].ToString( ); // model.Price=row["PRICE"].ToString( ); // model.Currency=row["CURRENCY"].ToString( ); // model.HSCode=row["HS CODE"].ToString( ); // model.TotalValue=row["TOTAL VALUE"].ToString( ); // model.Unit=row["Unit"].ToString( ); // model.NETWeight=row["NET WEIGHT"].ToString( ); // model.GrossWeight=row["GROSS WEIGHT"].ToString( ); // model.CommercialInvoiceNO=row["COMMERCIAL INVOICE NO"].ToString( ); // model.StoreNO=row["STORE NO"].ToString( ); // model.StoreName=row["STORE NAME"].ToString( ); // model.FileName=fileName.Substring(fileName.LastIndexOf('\\')+1); // model.CreateTime=DateTime.Now; // model.Creator="admin"; // bll.Add( model ); // } // if ( errMsg!="" ) // return false; // else // return true; //} public bool ExcuteBasicDataInput(DataTable excelDT, string fileName, ref string errMsg) { //basicDataBLL.BulkBasicDataInsert( excelDT , 1000 ); foreach (DataRow row in excelDT.Rows) { BasicDataEntity model = new BasicDataEntity( ); model.ModelCode = row["Model code"].ToString( ); model.QuanitityUnit = row["法定计量单位"].ToString( ); model.HSCode = row["HS CODE (IN CAT)"].ToString( ); model.LocalProdectName = row["中文品名"].ToString( ); model.EnglishProductName = row["英文品名"].ToString( ); model.SentialFactor = row["申报要素"].ToString( ); model.ModelCode = row["MODEL CODE"].ToString( ); model.SupervisionCondition = row["监管条件"].ToString( ); model.DoubleOrSet = row["Double or Set"].ToString( ); model.ExaminingReport = row["检测报告号"].ToString( ); model.ModelCodeDescription = ""; model.LocalComposition = ""; if (!basicDataBLL.ModelCodeExists(row["Model code"].ToString( ))) { basicDataBLL.Add(model); } else { basicDataBLL.Update(model); } } if (errMsg != "") { return(false); } else { return(true); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(BasicDataEntity model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(BasicDataEntity model) { return(dal.Add(model)); }
/// <summary> /// 获得数据列表 /// </summary> public List <BasicDataEntity> DataTableToList(DataTable dt) { List <BasicDataEntity> modelList = new List <BasicDataEntity>( ); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { BasicDataEntity model; for (int n = 0; n < rowsCount; n++) { model = new BasicDataEntity( ); if (dt.Rows[n]["ModelCodeID"] != null && dt.Rows[n]["ModelCodeID"].ToString( ) != "") { model.ModelCodeID = int.Parse(dt.Rows[n]["ModelCodeID"].ToString( )); } if (dt.Rows[n]["ModelCode"] != null && dt.Rows[n]["ModelCode"].ToString( ) != "") { model.ModelCode = dt.Rows[n]["ModelCode"].ToString( ); } if (dt.Rows[n]["HSCodeInCat"] != null && dt.Rows[n]["HSCodeInCat"].ToString( ) != "") { model.HSCodeInCat = dt.Rows[n]["HSCodeInCat"].ToString( ); } //if ( dt.Rows[n]["ModelCodeDescription"]!=null && dt.Rows[n]["ModelCodeDescription"].ToString( )!="" ) //{ // model.ModelCodeDescription=dt.Rows[n]["ModelCodeDescription"].ToString( ); //} if (dt.Rows[n]["EnglishProductName"] != null && dt.Rows[n]["EnglishProductName"].ToString( ) != "") { model.EnglishProductName = dt.Rows[n]["EnglishProductName"].ToString( ); } if (dt.Rows[n]["LocalProductName"] != null && dt.Rows[n]["LocalProductName"].ToString( ) != "") { model.LocalProductName = dt.Rows[n]["LocalProductName"].ToString( ); } if (dt.Rows[n]["QuantityUnit"] != null && dt.Rows[n]["QuantityUnit"].ToString( ) != "") { model.QuantityUnit = dt.Rows[n]["QuantityUnit"].ToString( ); } if (dt.Rows[n]["SentialFactor"] != null && dt.Rows[n]["SentialFactor"].ToString( ) != "") { model.SentialFactor = dt.Rows[n]["SentialFactor"].ToString( ); } if (dt.Rows[n]["LocalComposition"] != null && dt.Rows[n]["LocalComposition"].ToString( ) != "") { model.LocalComposition = dt.Rows[n]["LocalComposition"].ToString( ); } if (dt.Rows[n]["SupervisionCondition"] != null && dt.Rows[n]["SupervisionCondition"].ToString( ) != "") { model.SupervisionCondition = dt.Rows[n]["SupervisionCondition"].ToString( ); } if (dt.Rows[n]["DoubleOrSet"] != null && dt.Rows[n]["DoubleOrSet"].ToString( ) != "") { model.DoubleOrSet = dt.Rows[n]["DoubleOrSet"].ToString( ); } if (dt.Rows[n]["Description"] != null && dt.Rows[n]["Description"].ToString( ) != "") { model.Description = dt.Rows[n]["Description"].ToString( ); } if (dt.Rows[n]["ExaminingReport"] != null && dt.Rows[n]["ExaminingReport"].ToString( ) != "") { model.ExaminingReport = dt.Rows[n]["ExaminingReport"].ToString( ); } if (dt.Rows[n]["Size"] != null && dt.Rows[n]["Size"].ToString( ) != "") { model.Size = dt.Rows[n]["Size"].ToString( ); } modelList.Add(model); } } return(modelList); }
/// <summary> /// 得到一个对象实体 /// </summary> public BasicDataEntity GetModel(int ModelCodeID) { StringBuilder strSql = new StringBuilder( ); strSql.Append("select top 1 ModelCodeID,ModelCode,HSCodeInCat,EnglishProductName,LocalProductName,QuantityUnit,SentialFactor,LocalComposition,SupervisionCondition,DoubleOrSet,Description,ExaminingReport,Size from T_BasicData "); strSql.Append(" where ModelCodeID=@ModelCodeID "); SqlParameter[] parameters = { new SqlParameter("@ModelCodeID", SqlDbType.Int, 4) }; parameters[0].Value = ModelCodeID; BasicDataEntity model = new BasicDataEntity( ); DataSet ds = SqlHelper.Query(SqlHelper.LocalSqlServer, strSql.ToString( ), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ModelCodeID"] != null && ds.Tables[0].Rows[0]["ModelCodeID"].ToString( ) != "") { model.ModelCodeID = int.Parse(ds.Tables[0].Rows[0]["ModelCodeID"].ToString( )); } if (ds.Tables[0].Rows[0]["ModelCode"] != null && ds.Tables[0].Rows[0]["ModelCode"].ToString( ) != "") { model.ModelCode = ds.Tables[0].Rows[0]["ModelCode"].ToString( ); } if (ds.Tables[0].Rows[0]["HSCodeInCat"] != null && ds.Tables[0].Rows[0]["HSCodeInCat"].ToString( ) != "") { model.HSCodeInCat = ds.Tables[0].Rows[0]["HSCodeInCat"].ToString( ); } if (ds.Tables[0].Rows[0]["EnglishProductName"] != null && ds.Tables[0].Rows[0]["EnglishProductName"].ToString( ) != "") { model.EnglishProductName = ds.Tables[0].Rows[0]["EnglishProductName"].ToString( ); } if (ds.Tables[0].Rows[0]["LocalProductName"] != null && ds.Tables[0].Rows[0]["LocalProductName"].ToString( ) != "") { model.LocalProductName = ds.Tables[0].Rows[0]["LocalProductName"].ToString( ); } if (ds.Tables[0].Rows[0]["QuantityUnit"] != null && ds.Tables[0].Rows[0]["QuantityUnit"].ToString( ) != "") { model.QuantityUnit = ds.Tables[0].Rows[0]["QuantityUnit"].ToString( ); } if (ds.Tables[0].Rows[0]["SentialFactor"] != null && ds.Tables[0].Rows[0]["SentialFactor"].ToString( ) != "") { model.SentialFactor = ds.Tables[0].Rows[0]["SentialFactor"].ToString( ); } if (ds.Tables[0].Rows[0]["LocalComposition"] != null && ds.Tables[0].Rows[0]["LocalComposition"].ToString( ) != "") { model.LocalComposition = ds.Tables[0].Rows[0]["LocalComposition"].ToString( ); } if (ds.Tables[0].Rows[0]["SupervisionCondition"] != null && ds.Tables[0].Rows[0]["SupervisionCondition"].ToString( ) != "") { model.SupervisionCondition = ds.Tables[0].Rows[0]["SupervisionCondition"].ToString( ); } if (ds.Tables[0].Rows[0]["DoubleOrSet"] != null && ds.Tables[0].Rows[0]["DoubleOrSet"].ToString( ) != "") { model.DoubleOrSet = ds.Tables[0].Rows[0]["DoubleOrSet"].ToString( ); } if (ds.Tables[0].Rows[0]["Description"] != null && ds.Tables[0].Rows[0]["Description"].ToString( ) != "") { model.Description = ds.Tables[0].Rows[0]["Description"].ToString( ); } if (ds.Tables[0].Rows[0]["ExaminingReport"] != null && ds.Tables[0].Rows[0]["ExaminingReport"].ToString( ) != "") { model.ExaminingReport = ds.Tables[0].Rows[0]["ExaminingReport"].ToString( ); } if (ds.Tables[0].Rows[0]["Size"] != null && ds.Tables[0].Rows[0]["Size"].ToString( ) != "") { model.Size = ds.Tables[0].Rows[0]["Size"].ToString( ); } return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(BasicDataEntity model) { StringBuilder strSql = new StringBuilder( ); strSql.Append("update T_BasicData set "); strSql.Append("ModelCode=@ModelCode,"); strSql.Append("HSCodeInCat=@HSCodeInCat,"); //strSql.Append( "ModelCodeDescription=@ModelCodeDescription," ); strSql.Append("EnglishProductName=@EnglishProductName,"); strSql.Append("LocalProductName=@LocalProductName,"); strSql.Append("QuantityUnit=@QuantityUnit,"); strSql.Append("SentialFactor=@SentialFactor,"); strSql.Append("LocalComposition=@LocalComposition,"); strSql.Append("SupervisionCondition=@SupervisionCondition,"); strSql.Append("DoubleOrSet=@DoubleOrSet,"); strSql.Append("Description=@Description,"); strSql.Append("ExaminingReport=@ExaminingReport,"); strSql.Append("Size=@Size"); strSql.Append(" where ModelCodeID=@ModelCodeID "); SqlParameter[] parameters = { new SqlParameter("@ModelCode", SqlDbType.VarChar, 50), new SqlParameter("@HSCodeInCat", SqlDbType.VarChar, 50), //new SqlParameter("@ModelCodeDescription", SqlDbType.VarChar,250), new SqlParameter("@EnglishProductName", SqlDbType.VarChar, 255), new SqlParameter("@LocalProductName", SqlDbType.VarChar, 255), new SqlParameter("@QuantityUnit", SqlDbType.VarChar, 50), new SqlParameter("@SentialFactor", SqlDbType.VarChar, 2048), new SqlParameter("@LocalComposition", SqlDbType.VarChar, 255), new SqlParameter("@SupervisionCondition", SqlDbType.VarChar, 255), new SqlParameter("@DoubleOrSet", SqlDbType.VarChar, 255), new SqlParameter("@Description", SqlDbType.VarChar, 2048), new SqlParameter("@ExaminingReport", SqlDbType.VarChar, 255), new SqlParameter("@Size", SqlDbType.VarChar, 255), new SqlParameter("@ModelCodeID", SqlDbType.Int, 4) }; parameters[0].Value = model.ModelCode; parameters[1].Value = model.HSCodeInCat; //parameters[2].Value = model.ModelCodeDescription; parameters[2].Value = model.EnglishProductName; parameters[3].Value = model.LocalProductName; parameters[4].Value = model.QuantityUnit; parameters[5].Value = model.SentialFactor; parameters[6].Value = model.LocalComposition; parameters[7].Value = model.SupervisionCondition; parameters[8].Value = model.DoubleOrSet; parameters[9].Value = model.Description; parameters[10].Value = model.ExaminingReport; parameters[11].Value = model.Size; parameters[12].Value = model.ModelCodeID; int rows = SqlHelper.ExecuteSql(SqlHelper.LocalSqlServer, strSql.ToString( ), parameters); if (rows > 0) { return(true); } else { return(false); } }