protected void Button1_Click(object sender, EventArgs e) { NCPEP.Model.T_News model = new NCPEP.Model.T_News(); model.Content = Request.Form["Content"]; try { model.CreateDate = DateTime.Parse(Request.Form["txtshijian"]); } catch { } model.Editor = ""; model.IsCheck = 0; model.Keyword = Request.Form["Keyword"]; model.NewsContent = Request.Form["NewsContent"]; model.NewsFile = ""; model.NewsImg = ""; model.NewsSource = ""; model.NewsSubheading = ""; model.NewsTitle = Request.Form["NewsTitle"]; try { model.NewsTypeId = int.Parse(Request.Form["NewsTypeId"]); } catch { } model.NumClicks = 0; model.OrgCode = adminUser.OrgCode; NCPEP.Bll.T_News bll = new NCPEP.Bll.T_News(); bll.Add(model); ClientScript.RegisterStartupScript(this.GetType(), "myscript", "<script>MyFun();</script>"); }
private void BindData() { if (Request.QueryString["id"] != null) { NCPEP.Model.T_News model = new NCPEP.Model.T_News(); NCPEP.Bll.T_News bll = new NCPEP.Bll.T_News(); model = bll.GetModel(int.Parse(Request.QueryString["id"])); this.txtContent.Text = model.Content; this.txtKeyword.Text = model.Keyword; this.txtNewsSource.Text = model.NewsSource; this.txtNewsSubheading.Text = model.NewsSubheading; this.txtNewsTitle.Text = model.NewsTitle; this.txtNewsTypeId.Text = model.NewsTypeId.ToString();//新闻类型 this.ddlzt.SelectedValue = model.ztbz; this.txtsj.Text = model.CreateDate.ToString("yyyy-MM-dd"); this.content1.Value = model.NewsContent; this.HyperLink1.NavigateUrl = "../../newsimg/max/" + model.NewsImg; this.HyperLink1.Text = model.NewsImg; NCPEP.Bll.T_Fujian fjbll = new NCPEP.Bll.T_Fujian(); DataSet ds = fjbll.GetList("fid='" + model.Id + "'"); if (ds.Tables[0].Rows.Count > 0) { this.repsfz.Visible = true; this.repsfz.DataSource = ds; this.repsfz.DataBind(); } } }
protected void Button1_Click(object sender, EventArgs e) { NCPEP.Model.T_News model = new NCPEP.Model.T_News(); NCPEP.Bll.T_News bll = new NCPEP.Bll.T_News(); if (Request.QueryString["id"] != null) { model = bll.GetModel(int.Parse(Request.QueryString["id"])); } model.Content = content1.Value; try { model.CreateDate = DateTime.Parse(this.txtsj.Text); } catch { } model.Editor = adminUser.AdminName; model.IsCheck = 0; model.Keyword = this.txtKeyword.Text; model.NewsContent = this.content1.Value; model.Content = this.txtContent.Text; model.NewsSource = this.txtNewsSource.Text; model.NewsSubheading = this.txtNewsSubheading.Text; model.NewsTitle = this.txtNewsTitle.Text; try { model.NewsTypeId = int.Parse(this.txtNewsTypeId.SelectedValue); } catch { } if (fileNewsImg.HasFile) { string newsImgName = new UpLoadNewsImgPlug().UploadImg("147", "147"); model.NewsImg = newsImgName == string.Empty ? fileNewsImg.FileName : newsImgName; } model.NumClicks = 0; model.OrgCode = adminUser.OrgCode; bool fid = bll.Update(model); if (fid) { if (!string.IsNullOrEmpty(this.hdfile.Value) && !string.IsNullOrEmpty(this.hdfilename.Value)) { string[] strs = hdfile.Value.Split('|'); string[] strsname = hdfilename.Value.Split('|'); NCPEP.Bll.T_Fujian fjbll = new NCPEP.Bll.T_Fujian(); for (int i = 1; i < strs.Length; i++) { NCPEP.Model.T_Fujian fjmodel = new NCPEP.Model.T_Fujian(); fjmodel.fid = model.Id.ToString(); fjmodel.fjlx = ""; fjmodel.fjname = strsname[i]; fjmodel.fjpath = strs[i]; fjbll.Add(fjmodel); } } } MessageBox.ShowAndRedirect(this, "修改成功", "newslist.aspx"); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(NCPEP.Model.T_News model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into T_News("); strSql.Append("NewsTypeId,Keyword,Content,OrgCode,NewsTitle,NewsSubheading,NewsSource,NewsContent,NewsImg,NewsFile,NumClicks,IsCheck,Editor,CreateDate,ztbz,TZZT)"); strSql.Append(" values ("); strSql.Append("@NewsTypeId,@Keyword,@Content,@OrgCode,@NewsTitle,@NewsSubheading,@NewsSource,@NewsContent,@NewsImg,@NewsFile,@NumClicks,@IsCheck,@Editor,@CreateDate,@ztbz,@TZZT)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@NewsTypeId", SqlDbType.Int, 4), new SqlParameter("@Keyword", SqlDbType.NVarChar, 50), new SqlParameter("@Content", SqlDbType.NVarChar, 50), new SqlParameter("@OrgCode", SqlDbType.VarChar, 150), new SqlParameter("@NewsTitle", SqlDbType.NVarChar, 100), new SqlParameter("@NewsSubheading", SqlDbType.NVarChar, 50), new SqlParameter("@NewsSource", SqlDbType.NVarChar, 50), new SqlParameter("@NewsContent", SqlDbType.Text), new SqlParameter("@NewsImg", SqlDbType.VarChar, 50), new SqlParameter("@NewsFile", SqlDbType.VarChar, 50), new SqlParameter("@NumClicks", SqlDbType.Int, 4), new SqlParameter("@IsCheck", SqlDbType.Int, 4), new SqlParameter("@Editor", SqlDbType.NVarChar, 50), new SqlParameter("@CreateDate", SqlDbType.DateTime), new SqlParameter("@ztbz", SqlDbType.VarChar, 50), new SqlParameter("@TZZT", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.NewsTypeId; parameters[1].Value = model.Keyword; parameters[2].Value = model.Content; parameters[3].Value = model.OrgCode; parameters[4].Value = model.NewsTitle; parameters[5].Value = model.NewsSubheading; parameters[6].Value = model.NewsSource; parameters[7].Value = model.NewsContent; parameters[8].Value = model.NewsImg; parameters[9].Value = model.NewsFile; parameters[10].Value = model.NumClicks; parameters[11].Value = model.IsCheck; parameters[12].Value = model.Editor; parameters[13].Value = model.CreateDate; parameters[14].Value = model.ztbz; parameters[15].Value = model.TZZT; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
private void Bindfj() { if (Request.QueryString["id"] != null) { NCPEP.Model.T_News model = new NCPEP.Model.T_News(); NCPEP.Bll.T_News bll = new NCPEP.Bll.T_News(); model = bll.GetModel(int.Parse(Request.QueryString["id"])); NCPEP.Bll.T_Fujian fjbll = new NCPEP.Bll.T_Fujian(); DataSet ds = fjbll.GetList("fid='" + model.Id + "'"); if (ds.Tables[0].Rows.Count > 0) { this.repsfz.Visible = true; this.repsfz.DataSource = ds; this.repsfz.DataBind(); } } }
/// <summary> /// 得到一个对象实体 /// </summary> public NCPEP.Model.T_News GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,NewsTypeId,Keyword,Content,OrgCode,NewsTitle,NewsSubheading,NewsSource,NewsContent,NewsImg,NewsFile,NumClicks,IsCheck,Editor,CreateDate,ztbz,TZZT from T_News "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; NCPEP.Model.T_News model = new NCPEP.Model.T_News(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(NCPEP.Model.T_News model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update T_News set "); strSql.Append("NewsTypeId=@NewsTypeId,"); strSql.Append("Keyword=@Keyword,"); strSql.Append("Content=@Content,"); strSql.Append("OrgCode=@OrgCode,"); strSql.Append("NewsTitle=@NewsTitle,"); strSql.Append("NewsSubheading=@NewsSubheading,"); strSql.Append("NewsSource=@NewsSource,"); strSql.Append("NewsContent=@NewsContent,"); strSql.Append("NewsImg=@NewsImg,"); strSql.Append("NewsFile=@NewsFile,"); strSql.Append("NumClicks=@NumClicks,"); strSql.Append("IsCheck=@IsCheck,"); strSql.Append("Editor=@Editor,"); strSql.Append("CreateDate=@CreateDate,"); strSql.Append("ztbz=@ztbz,"); strSql.Append("TZZT=@TZZT"); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@NewsTypeId", SqlDbType.Int, 4), new SqlParameter("@Keyword", SqlDbType.NVarChar, 50), new SqlParameter("@Content", SqlDbType.NVarChar, 50), new SqlParameter("@OrgCode", SqlDbType.VarChar, 150), new SqlParameter("@NewsTitle", SqlDbType.NVarChar, 100), new SqlParameter("@NewsSubheading", SqlDbType.NVarChar, 50), new SqlParameter("@NewsSource", SqlDbType.NVarChar, 50), new SqlParameter("@NewsContent", SqlDbType.Text), new SqlParameter("@NewsImg", SqlDbType.VarChar, 50), new SqlParameter("@NewsFile", SqlDbType.VarChar, 50), new SqlParameter("@NumClicks", SqlDbType.Int, 4), new SqlParameter("@IsCheck", SqlDbType.Int, 4), new SqlParameter("@Editor", SqlDbType.NVarChar, 50), new SqlParameter("@CreateDate", SqlDbType.DateTime), new SqlParameter("@ztbz", SqlDbType.VarChar, 50), new SqlParameter("@TZZT", SqlDbType.NVarChar, 50), new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = model.NewsTypeId; parameters[1].Value = model.Keyword; parameters[2].Value = model.Content; parameters[3].Value = model.OrgCode; parameters[4].Value = model.NewsTitle; parameters[5].Value = model.NewsSubheading; parameters[6].Value = model.NewsSource; parameters[7].Value = model.NewsContent; parameters[8].Value = model.NewsImg; parameters[9].Value = model.NewsFile; parameters[10].Value = model.NumClicks; parameters[11].Value = model.IsCheck; parameters[12].Value = model.Editor; parameters[13].Value = model.CreateDate; parameters[14].Value = model.ztbz; parameters[15].Value = model.TZZT; parameters[16].Value = model.Id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public NCPEP.Model.T_News DataRowToModel(DataRow row) { NCPEP.Model.T_News model = new NCPEP.Model.T_News(); if (row != null) { if (row["Id"] != null && row["Id"].ToString() != "") { model.Id = int.Parse(row["Id"].ToString()); } if (row["NewsTypeId"] != null && row["NewsTypeId"].ToString() != "") { model.NewsTypeId = int.Parse(row["NewsTypeId"].ToString()); } if (row["Keyword"] != null) { model.Keyword = row["Keyword"].ToString(); } if (row["Content"] != null) { model.Content = row["Content"].ToString(); } if (row["OrgCode"] != null) { model.OrgCode = row["OrgCode"].ToString(); } if (row["NewsTitle"] != null) { model.NewsTitle = row["NewsTitle"].ToString(); } if (row["NewsSubheading"] != null) { model.NewsSubheading = row["NewsSubheading"].ToString(); } if (row["NewsSource"] != null) { model.NewsSource = row["NewsSource"].ToString(); } if (row["NewsContent"] != null) { model.NewsContent = row["NewsContent"].ToString(); } if (row["NewsImg"] != null) { model.NewsImg = row["NewsImg"].ToString(); } if (row["NewsFile"] != null) { model.NewsFile = row["NewsFile"].ToString(); } if (row["NumClicks"] != null && row["NumClicks"].ToString() != "") { model.NumClicks = int.Parse(row["NumClicks"].ToString()); } if (row["IsCheck"] != null && row["IsCheck"].ToString() != "") { model.IsCheck = int.Parse(row["IsCheck"].ToString()); } if (row["Editor"] != null) { model.Editor = row["Editor"].ToString(); } if (row["CreateDate"] != null && row["CreateDate"].ToString() != "") { model.CreateDate = DateTime.Parse(row["CreateDate"].ToString()); } if (row["ztbz"] != null) { model.ztbz = row["ztbz"].ToString(); } if (row["TZZT"] != null) { model.TZZT = row["TZZT"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(NCPEP.Model.T_News model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(NCPEP.Model.T_News model) { return(dal.Add(model)); }