private static Tab_UserArticle_Product ToModel(DataRow row) { Tab_UserArticle_Product model = new Tab_UserArticle_Product(); model.Idx = row.IsNull("Idx")?null:(System.Int32?)row["Idx"]; model.ProductPictures = row.IsNull("ProductPictures")?null:(System.String)row["ProductPictures"]; model.ProductTitle = row.IsNull("ProductTitle")?null:(System.String)row["ProductTitle"]; model.ProductOverview = row.IsNull("ProductOverview")?null:(System.String)row["ProductOverview"]; model.ProductCategoryIdx_Fx = row.IsNull("ProductCategoryIdx_Fx")?null:(System.String)row["ProductCategoryIdx_Fx"]; model.ProductImpression = row.IsNull("ProductImpression")?null:(System.String)row["ProductImpression"]; return(model); }
public int AddNew(Tab_UserArticle_Product model) { string sql = "insert into Tab_UserArticle_Product(ProductPictures,ProductTitle,ProductOverview,ProductCategoryIdx_Fx,ProductImpression) values(@ProductPictures,@ProductTitle,@ProductOverview,@ProductCategoryIdx_Fx,@ProductImpression); select @@identity ;"; int Idx = Convert.ToInt32(SqlHelper.ExecuteScalar(CommandType.Text, sql , new SqlParameter("@ProductPictures", model.ProductPictures) , new SqlParameter("@ProductTitle", model.ProductTitle) , new SqlParameter("@ProductOverview", model.ProductOverview) , new SqlParameter("@ProductCategoryIdx_Fx", model.ProductCategoryIdx_Fx) , new SqlParameter("@ProductImpression", model.ProductImpression) )); return(Idx); }
public bool Update(Tab_UserArticle_Product model) { string sql = "update Tab_UserArticle_Product set ProductPictures=@ProductPictures,ProductTitle=@ProductTitle,ProductOverview=@ProductOverview,ProductCategoryIdx_Fx=@ProductCategoryIdx_Fx,ProductImpression=@ProductImpression where Idx=@Idx"; int rows = SqlHelper.ExecuteNonQuery(CommandType.Text, sql , new SqlParameter("@ProductPictures", model.ProductPictures) , new SqlParameter("@ProductTitle", model.ProductTitle) , new SqlParameter("@ProductOverview", model.ProductOverview) , new SqlParameter("@ProductCategoryIdx_Fx", model.ProductCategoryIdx_Fx) , new SqlParameter("@ProductImpression", model.ProductImpression) , new SqlParameter("Idx", model.Idx) ); return(rows > 0); }
protected void ProductTitle_SelectedIndexChanged(object sender, EventArgs e) { DBEntity.Tab_UserArticle_Product ent = new DBEntity.Tab_UserArticle_Product(); ent = ent.Get(this.ProductTitle.SelectedValue); this.ProductPictures.ImageUrl = string.Format("~/upload/UserProduct/{0}", ent.ProductPictures); ProductImpression.Items.Clear(); for (int i = 0; i < ent.ProductImpression.Split('|').Count(); i++) { this.ProductImpression.Items.Add(ent.ProductImpression.Split('|')[i].ToString() + "分"); } RadioButtonList1.Items.Clear(); for (int i = 1; i <= 5; i++) { this.RadioButtonList1.Items.Add(i.ToString() + "分"); } }
public Tab_UserArticle_Product Get(string Idx) { DataTable dt = SqlHelper.ExecuteDataset(CommandType.Text, "select * from Tab_UserArticle_Product 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_UserArticle_Product model = ToModel(row); return(model); }