private static Tab_UserArticle ToModel(DataRow row) { Tab_UserArticle model = new Tab_UserArticle(); model.Idx = row.IsNull("Idx")?null:(System.Int32?)row["Idx"]; model.UserUId_Fx = row.IsNull("UserUId_Fx")?null:(System.Int32?)row["UserUId_Fx"]; model.ForProductBool = row.IsNull("ForProductBool")?null:(System.String)row["ForProductBool"]; model.ArticleTitle = row.IsNull("ArticleTitle")?null:(System.String)row["ArticleTitle"]; model.ArticleContent = row.IsNull("ArticleContent")?null:(System.String)row["ArticleContent"]; model.CreatedDate = row.IsNull("CreatedDate")?null:(System.DateTime?)row["CreatedDate"]; model.PreviewAlternatePicture = row.IsNull("PreviewAlternatePicture")?null:(System.String)row["PreviewAlternatePicture"]; model.ProductScore = row.IsNull("ProductScore")?null:(System.String)row["ProductScore"]; model.ProductImpression = row.IsNull("ProductImpression")?null:(System.String)row["ProductImpression"]; model.ProductTryIdx_Fx = row.IsNull("ProductTryIdx_Fx")?null:(System.Int32?)row["ProductTryIdx_Fx"]; return(model); }
public int AddNew(Tab_UserArticle model) { string sql = "insert into Tab_UserArticle(UserUId_Fx,ForProductBool,ArticleTitle,ArticleContent,CreatedDate,PreviewAlternatePicture,ProductScore,ProductImpression,ProductTryIdx_Fx) values(@UserUId_Fx,@ForProductBool,@ArticleTitle,@ArticleContent,@CreatedDate,@PreviewAlternatePicture,@ProductScore,@ProductImpression,@ProductTryIdx_Fx); select @@identity ;"; int Idx = Convert.ToInt32(SqlHelper.ExecuteScalar(CommandType.Text, sql , new SqlParameter("@UserUId_Fx", model.UserUId_Fx) , new SqlParameter("@ForProductBool", model.ForProductBool) , new SqlParameter("@ArticleTitle", model.ArticleTitle) , new SqlParameter("@ArticleContent", model.ArticleContent) , new SqlParameter("@CreatedDate", model.CreatedDate) , new SqlParameter("@PreviewAlternatePicture", model.PreviewAlternatePicture) , new SqlParameter("@ProductScore", model.ProductScore) , new SqlParameter("@ProductImpression", model.ProductImpression) , new SqlParameter("@ProductTryIdx_Fx", model.ProductTryIdx_Fx) )); return(Idx); }
public bool Update(Tab_UserArticle model) { string sql = "update Tab_UserArticle set UserUId_Fx=@UserUId_Fx,ForProductBool=@ForProductBool,ArticleTitle=@ArticleTitle,ArticleContent=@ArticleContent,CreatedDate=@CreatedDate,PreviewAlternatePicture=@PreviewAlternatePicture,ProductScore=@ProductScore,ProductImpression=@ProductImpression,ProductTryIdx_Fx=@ProductTryIdx_Fx where Idx=@Idx"; int rows = SqlHelper.ExecuteNonQuery(CommandType.Text, sql , new SqlParameter("@UserUId_Fx", model.UserUId_Fx) , new SqlParameter("@ForProductBool", model.ForProductBool) , new SqlParameter("@ArticleTitle", model.ArticleTitle) , new SqlParameter("@ArticleContent", model.ArticleContent) , new SqlParameter("@CreatedDate", model.CreatedDate) , new SqlParameter("@PreviewAlternatePicture", model.PreviewAlternatePicture) , new SqlParameter("@ProductScore", model.ProductScore) , new SqlParameter("@ProductImpression", model.ProductImpression) , new SqlParameter("@ProductTryIdx_Fx", model.ProductTryIdx_Fx) , new SqlParameter("Idx", model.Idx) ); return(rows > 0); }
public Tab_UserArticle Get(string Idx) { DataTable dt = SqlHelper.ExecuteDataset(CommandType.Text, "select * from Tab_UserArticle 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 model = ToModel(row); return(model); }
protected void btnSubmit_Click(object sender, EventArgs e) { Cmn.uploadFile upF = new Cmn.uploadFile(); string[] allowExtensions = { ".jpg", ".gif", ".png" }; int maxSize = Convert.ToInt32(Cmn.WebConfig.getApp("app_MaxSizeUpload")); string savePath = Request.MapPath("~/upload/Article/"); string fileName = myFileUpload.FileName; try { upF.Upload(this.myFileUpload, allowExtensions, maxSize, savePath, fileName); } catch (Exception exp) { Cmn.Js.ShowAlert(exp.Message); return; } DBEntity.Tab_UserArticle ent = new DBEntity.Tab_UserArticle(); ent.UserUId_Fx = int.Parse(this.uId.Text); ent.ForProductBool = this.rdType.SelectedValue; ent.ArticleTitle = wenZhangTitle.Text; ent.ArticleContent = articleContent.Text; ent.CreatedDate = DateTime.Now; ent.PreviewAlternatePicture = fileName; if (this.rdType.SelectedValue == "产品测试") { ent.ProductScore = this.RadioButtonList1.SelectedItem.Text; ent.ProductImpression = this.ProductImpression.SelectedItem.Text; ent.ProductTryIdx_Fx = int.Parse(this.ProductTitle.SelectedValue); } ent.AddNew(ent); Cmn.Js.ShowAlert("操作成功!"); Cmn.Js.ExeScript("location.href='UserArticle_Manage.aspx'"); }