private static Tab_MedalProduct ToModel(DataRow row) { Tab_MedalProduct model = new Tab_MedalProduct(); model.Idx = row.IsNull("Idx")?null:(System.Int32?)row["Idx"]; model.ProductName = row.IsNull("ProductName")?null:(System.String)row["ProductName"]; model.ProductDescription = row.IsNull("ProductDescription")?null:(System.String)row["ProductDescription"]; model.ProductNeed_Medal = row.IsNull("ProductNeed_Medal")?null:(System.String)row["ProductNeed_Medal"]; model.NeedMedalCount = row.IsNull("NeedMedalCount")?null:(System.Int32?)row["NeedMedalCount"]; model.CreatedDate = row.IsNull("CreatedDate")?null:(System.DateTime?)row["CreatedDate"]; return(model); }
public int AddNew(Tab_MedalProduct model) { string sql = "insert into Tab_MedalProduct(ProductName,ProductDescription,ProductNeed_Medal,NeedMedalCount,CreatedDate) values(@ProductName,@ProductDescription,@ProductNeed_Medal,@NeedMedalCount,@CreatedDate); select @@identity ;"; int Idx = Convert.ToInt32(SqlHelper.ExecuteScalar(CommandType.Text, sql , new SqlParameter("@ProductName", model.ProductName) , new SqlParameter("@ProductDescription", model.ProductDescription) , new SqlParameter("@ProductNeed_Medal", model.ProductNeed_Medal) , new SqlParameter("@NeedMedalCount", model.NeedMedalCount) , new SqlParameter("@CreatedDate", model.CreatedDate) )); return(Idx); }
public bool Update(Tab_MedalProduct model) { string sql = "update Tab_MedalProduct set ProductName=@ProductName,ProductDescription=@ProductDescription,ProductNeed_Medal=@ProductNeed_Medal,NeedMedalCount=@NeedMedalCount,CreatedDate=@CreatedDate where Idx=@Idx"; int rows = SqlHelper.ExecuteNonQuery(CommandType.Text, sql , new SqlParameter("@ProductName", model.ProductName) , new SqlParameter("@ProductDescription", model.ProductDescription) , new SqlParameter("@ProductNeed_Medal", model.ProductNeed_Medal) , new SqlParameter("@NeedMedalCount", model.NeedMedalCount) , new SqlParameter("@CreatedDate", model.CreatedDate) , new SqlParameter("Idx", model.Idx) ); return(rows > 0); }
public Tab_MedalProduct Get(string Idx) { DataTable dt = SqlHelper.ExecuteDataset(CommandType.Text, "select * from Tab_MedalProduct where Idx=@Idx", new SqlParameter("Idx", Idx)).Tables[0]; if (dt.Rows.Count > 1) { throw new Exception("more than 1 row was found"); } if (dt.Rows.Count <= 0) { return(null); } DataRow row = dt.Rows[0]; Tab_MedalProduct model = ToModel(row); return(model); }