private void bind(int weilanid) { Maticsoft.BLL.WeiLanInfo weilanbll = new Maticsoft.BLL.WeiLanInfo(); Maticsoft.Model.WeiLanInfo weilanmodel = weilanbll.GetModel(weilanid); lblFatime.Text = Convert.ToDateTime(weilanmodel.Fatime.ToString()).ToString("yyyy-MM-dd"); lblWeicontent.Text = weilanmodel.Weicontent; lblWeiTitle.Text = weilanmodel.WeiTitle; lblWrite.Text = weilanmodel.Write; if (weilanmodel.HitNum == null) { int hitnum = 0; hitnum += 1; weilanmodel.HitNum = hitnum; weilanbll.Update(weilanmodel); lblhitnum.Text = hitnum.ToString(); } else { int hitnum = int.Parse(weilanmodel.HitNum.ToString()); hitnum += 1; weilanmodel.HitNum = hitnum; weilanbll.Update(weilanmodel); lblhitnum.Text = hitnum.ToString(); } }
public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtWeiTitle.Text.Trim().Length == 0) { strErr += "WeiTitle不能为空!\\n"; } if (this.txtWeiKey.Text.Trim().Length == 0) { strErr += "WeiKey不能为空!\\n"; } if (!PageValidate.IsDateTime(txtFatime.Text)) { strErr += "Fatime格式错误!\\n"; } if (this.txtWrite.Text.Trim().Length == 0) { strErr += "Write不能为空!\\n"; } if (!PageValidate.IsNumber(txtHitNum.Text)) { strErr += "HitNum格式错误!\\n"; } if (this.txtWeicontent.Text.Trim().Length == 0) { strErr += "Weicontent不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int WeiID = int.Parse(this.lblWeiID.Text); string WeiTitle = this.txtWeiTitle.Text; string WeiKey = this.txtWeiKey.Text; DateTime Fatime = DateTime.Parse(this.txtFatime.Text); string Write = this.txtWrite.Text; int HitNum = int.Parse(this.txtHitNum.Text); string Weicontent = this.txtWeicontent.Text; Maticsoft.Model.WeiLanInfo model = new Maticsoft.Model.WeiLanInfo(); model.WeiID = WeiID; model.WeiTitle = WeiTitle; model.WeiKey = WeiKey; model.Fatime = Fatime; model.Write = Write; model.HitNum = HitNum; model.Weicontent = Weicontent; Maticsoft.BLL.WeiLanInfo bll = new Maticsoft.BLL.WeiLanInfo(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }
private void ShowInfo(int WeiID) { Maticsoft.BLL.WeiLanInfo bll = new Maticsoft.BLL.WeiLanInfo(); Maticsoft.Model.WeiLanInfo model = bll.GetModel(WeiID); this.lblWeiID.Text = model.WeiID.ToString(); this.txtWeiTitle.Text = model.WeiTitle; this.txtWeiKey.Text = model.WeiKey; this.txtFatime.Text = model.Fatime.ToString(); this.txtWrite.Text = model.Write; this.txtHitNum.Text = model.HitNum.ToString(); this.txtWeicontent.Text = model.Weicontent; }
private void bind() { Maticsoft.BLL.WeiLanInfo weilanbll = new Maticsoft.BLL.WeiLanInfo(); int index = int.Parse(Request.QueryString["WeiID"].ToString()); Maticsoft.Model.WeiLanInfo weilanmodel = weilanbll.GetModel(index); txtcontent.Text = weilanmodel.Weicontent; txtFatime.Text = Convert.ToDateTime(weilanmodel.Fatime.ToString()).ToString("yyyy-MM-dd"); txtkeyword.Text = weilanmodel.WeiKey; txtwrite.Text = weilanmodel.Write; txtzhishititle.Text = weilanmodel.WeiTitle; }
protected void btnok_Click(object sender, EventArgs e) { Maticsoft.BLL.WeiLanInfo weilanbll = new Maticsoft.BLL.WeiLanInfo(); Maticsoft.Model.WeiLanInfo weilanmodel = new Maticsoft.Model.WeiLanInfo(); if (txtzhishititle.Text.Trim() == "") { lbltitle.Text = "请填写围栏标题"; return; } weilanmodel.WeiTitle = txtzhishititle.Text.Trim(); lbltitle.Text = ""; if (txtkeyword.Text.Trim() == "") { lblkeyword.Text = "请填写关键字"; return; } weilanmodel.WeiKey = txtkeyword.Text.Trim(); lblkeyword.Text = ""; if (txtFatime.Text.Trim() == "") { lblfatime.Text = "请填写发布时间"; return; } weilanmodel.Fatime = Convert.ToDateTime(txtFatime.Text.Trim()); lblfatime.Text = ""; if (txtwrite.Text.Trim() == "") { lblwrite.Text = "请填写发布人"; return; } weilanmodel.Write = txtwrite.Text.Trim(); lblwrite.Text = ""; weilanmodel.Weicontent = txtcontent.Text.Trim(); weilanbll.Add(weilanmodel); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('信息添加成功!')</script>"); txtcontent.Text = string.Empty; txtFatime.Text = string.Empty; txtkeyword.Text = string.Empty; txtwrite.Text = string.Empty; txtzhishititle.Text = string.Empty; }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.WeiLanInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update WeiLanInfo set "); strSql.Append("WeiTitle=@WeiTitle,"); strSql.Append("WeiKey=@WeiKey,"); strSql.Append("Fatime=@Fatime,"); strSql.Append("Write=@Write,"); strSql.Append("HitNum=@HitNum,"); strSql.Append("Weicontent=@Weicontent"); strSql.Append(" where WeiID=@WeiID"); SqlParameter[] parameters = { new SqlParameter("@WeiID", SqlDbType.Int, 4), new SqlParameter("@WeiTitle", SqlDbType.VarChar, 200), new SqlParameter("@WeiKey", SqlDbType.VarChar, 200), new SqlParameter("@Fatime", SqlDbType.DateTime), new SqlParameter("@Write", SqlDbType.VarChar, 200), new SqlParameter("@HitNum", SqlDbType.Int, 4), new SqlParameter("@Weicontent", SqlDbType.Text) }; parameters[0].Value = model.WeiID; parameters[1].Value = model.WeiTitle; parameters[2].Value = model.WeiKey; parameters[3].Value = model.Fatime; parameters[4].Value = model.Write; parameters[5].Value = model.HitNum; parameters[6].Value = model.Weicontent; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.WeiLanInfo GetModel(int WeiID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 WeiID,WeiTitle,WeiKey,Fatime,Write,HitNum,Weicontent from WeiLanInfo "); strSql.Append(" where WeiID=@WeiID"); SqlParameter[] parameters = { new SqlParameter("@WeiID", SqlDbType.Int, 4) }; parameters[0].Value = WeiID; Maticsoft.Model.WeiLanInfo model = new Maticsoft.Model.WeiLanInfo(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["WeiID"].ToString() != "") { model.WeiID = int.Parse(ds.Tables[0].Rows[0]["WeiID"].ToString()); } model.WeiTitle = ds.Tables[0].Rows[0]["WeiTitle"].ToString(); model.WeiKey = ds.Tables[0].Rows[0]["WeiKey"].ToString(); if (ds.Tables[0].Rows[0]["Fatime"].ToString() != "") { model.Fatime = DateTime.Parse(ds.Tables[0].Rows[0]["Fatime"].ToString()); } model.Write = ds.Tables[0].Rows[0]["Write"].ToString(); if (ds.Tables[0].Rows[0]["HitNum"].ToString() != "") { model.HitNum = int.Parse(ds.Tables[0].Rows[0]["HitNum"].ToString()); } model.Weicontent = ds.Tables[0].Rows[0]["Weicontent"].ToString(); return(model); } else { return(null); } }
protected void btnok_Click(object sender, EventArgs e) { Maticsoft.BLL.WeiLanInfo weilanbll = new Maticsoft.BLL.WeiLanInfo(); int index = int.Parse(Request.QueryString["WeiID"].ToString()); Maticsoft.Model.WeiLanInfo weilanmodel = weilanbll.GetModel(index); if (txtzhishititle.Text.Trim() == "") { lbltitle.Text = "请填写围栏标题"; return; } weilanmodel.WeiTitle = txtzhishititle.Text.Trim(); lbltitle.Text = ""; if (txtkeyword.Text.Trim() == "") { lblkeyword.Text = "请填写关键字"; return; } weilanmodel.WeiKey = txtkeyword.Text.Trim(); lblkeyword.Text = ""; if (txtFatime.Text.Trim() == "") { lblfatime.Text = "请填写发布时间"; return; } weilanmodel.Fatime = Convert.ToDateTime(txtFatime.Text.Trim()); lblfatime.Text = ""; if (txtwrite.Text.Trim() == "") { lblwrite.Text = "请填写发布人"; return; } weilanmodel.Write = txtwrite.Text.Trim(); lblwrite.Text = ""; weilanmodel.Weicontent = txtcontent.Text.Trim(); weilanbll.Update(weilanmodel); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('信息添加成功!')</script>"); bind(); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Maticsoft.Model.WeiLanInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into WeiLanInfo("); strSql.Append("WeiTitle,WeiKey,Fatime,Write,HitNum,Weicontent)"); strSql.Append(" values ("); strSql.Append("@WeiTitle,@WeiKey,@Fatime,@Write,@HitNum,@Weicontent)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@WeiTitle", SqlDbType.VarChar, 200), new SqlParameter("@WeiKey", SqlDbType.VarChar, 200), new SqlParameter("@Fatime", SqlDbType.DateTime), new SqlParameter("@Write", SqlDbType.VarChar, 200), new SqlParameter("@HitNum", SqlDbType.Int, 4), new SqlParameter("@Weicontent", SqlDbType.Text) }; parameters[0].Value = model.WeiTitle; parameters[1].Value = model.WeiKey; parameters[2].Value = model.Fatime; parameters[3].Value = model.Write; parameters[4].Value = model.HitNum; parameters[5].Value = model.Weicontent; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }