/// <summary> /// 得到一个对象实体 /// </summary> public StorageProductLogDataInfo DataRowToStorageProductLogDataInfoModel(DataRow row) { StorageProductLogDataInfo model = new StorageProductLogDataInfo(); if (row != null) { if (row["StorageProductLogDataID"] != null && row["StorageProductLogDataID"].ToString() != "") { model.StorageProductLogDataID = int.Parse(row["StorageProductLogDataID"].ToString()); } if (row["StorageProductLogID"] != null && row["StorageProductLogID"].ToString() != "") { model.StorageProductLogID = int.Parse(row["StorageProductLogID"].ToString()); } if (row["StorageID"] != null && row["StorageID"].ToString() != "") { model.StorageID = int.Parse(row["StorageID"].ToString()); } if (row["ProductsID"] != null && row["ProductsID"].ToString() != "") { model.ProductsID = int.Parse(row["ProductsID"].ToString()); } if (row["pQuantity"] != null && row["pQuantity"].ToString() != "") { model.pQuantity = int.Parse(row["pQuantity"].ToString()); } if (row["OrderListID"] != null && row["OrderListID"].ToString() != "") { model.OrderListID = int.Parse(row["OrderListID"].ToString()); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int AddStorageProductLogDataInfo(StorageProductLogDataInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into tbStorageProductLogDataInfo("); strSql.Append("StorageProductLogID,StorageID,ProductsID,pQuantity,OrderListID)"); strSql.Append(" values ("); strSql.Append("@StorageProductLogID,@StorageID,@ProductsID,@pQuantity,@OrderListID)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@StorageProductLogID", SqlDbType.Int, 4), new SqlParameter("@StorageID", SqlDbType.Int, 4), new SqlParameter("@ProductsID", SqlDbType.Int, 4), new SqlParameter("@pQuantity", SqlDbType.Int, 4), new SqlParameter("@OrderListID", SqlDbType.Int, 4) }; parameters[0].Value = model.StorageProductLogID; parameters[1].Value = model.StorageID; parameters[2].Value = model.ProductsID; parameters[3].Value = model.pQuantity; parameters[4].Value = model.OrderListID; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> public bool UpdateStorageProductLogDataInfo(StorageProductLogDataInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tbStorageProductLogDataInfo set "); strSql.Append("OrderListID=@OrderListID,"); strSql.Append("StorageProductLogID=@StorageProductLogID,"); strSql.Append("StorageID=@StorageID,"); strSql.Append("ProductsID=@ProductsID,"); strSql.Append("pQuantity=@pQuantity"); strSql.Append(" where StorageProductLogDataID=@StorageProductLogDataID"); SqlParameter[] parameters = { new SqlParameter("@StorageProductLogID", SqlDbType.Int, 4), new SqlParameter("@StorageID", SqlDbType.Int, 4), new SqlParameter("@ProductsID", SqlDbType.Int, 4), new SqlParameter("@pQuantity", SqlDbType.Int, 4), new SqlParameter("@StorageProductLogDataID", SqlDbType.Int, 4), new SqlParameter("@OrderListID", SqlDbType.Int, 4) }; parameters[0].Value = model.StorageProductLogID; parameters[1].Value = model.StorageID; parameters[2].Value = model.ProductsID; parameters[3].Value = model.pQuantity; parameters[4].Value = model.StorageProductLogDataID; parameters[5].Value = model.OrderListID; int rows = DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 更新一条数据 /// </summary> public static bool UpdateStorageProductLogDataInfo(StorageProductLogDataInfo model) { return(DatabaseProvider.GetInstance().UpdateStorageProductLogDataInfo(model)); }
/// <summary> /// 增加一条数据 /// </summary> public static int AddStorageProductLogDataInfo(StorageProductLogDataInfo model) { return(DatabaseProvider.GetInstance().AddStorageProductLogDataInfo(model)); }