private static Tab_SuperStarProduct ToModel(DataRow row) { Tab_SuperStarProduct model = new Tab_SuperStarProduct(); model.Idx = row.IsNull("Idx")?null:(System.Int32?)row["Idx"]; model.ProductTitle = row.IsNull("ProductTitle")?null:(System.String)row["ProductTitle"]; model.ProductPictures = row.IsNull("ProductPictures")?null:(System.String)row["ProductPictures"]; model.ProductDescription = row.IsNull("ProductDescription")?null:(System.String)row["ProductDescription"]; model.DateCreated = row.IsNull("DateCreated")?null:(System.DateTime?)row["DateCreated"]; return(model); }
public int AddNew(Tab_SuperStarProduct model) { string sql = "insert into Tab_SuperStarProduct(ProductTitle,ProductPictures,ProductDescription,DateCreated) values(@ProductTitle,@ProductPictures,@ProductDescription,@DateCreated); select @@identity ;"; int Idx = Convert.ToInt32(SqlHelper.ExecuteScalar(CommandType.Text, sql , new SqlParameter("@ProductTitle", model.ProductTitle) , new SqlParameter("@ProductPictures", model.ProductPictures) , new SqlParameter("@ProductDescription", model.ProductDescription) , new SqlParameter("@DateCreated", model.DateCreated) )); return(Idx); }
public bool Update(Tab_SuperStarProduct model) { string sql = "update Tab_SuperStarProduct set ProductTitle=@ProductTitle,ProductPictures=@ProductPictures,ProductDescription=@ProductDescription,DateCreated=@DateCreated where Idx=@Idx"; int rows = SqlHelper.ExecuteNonQuery(CommandType.Text, sql , new SqlParameter("@ProductTitle", model.ProductTitle) , new SqlParameter("@ProductPictures", model.ProductPictures) , new SqlParameter("@ProductDescription", model.ProductDescription) , new SqlParameter("@DateCreated", model.DateCreated) , new SqlParameter("Idx", model.Idx) ); return(rows > 0); }
public Tab_SuperStarProduct Get(string Idx) { DataTable dt = SqlHelper.ExecuteDataset(CommandType.Text, "select * from Tab_SuperStarProduct 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_SuperStarProduct model = ToModel(row); return(model); }