protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["usename"] != null) { if (Session["usename"].ToString() != "") { Maticsoft.BLL.ComPanyInfo combll = new Maticsoft.BLL.ComPanyInfo(); Maticsoft.Model.ComPanyInfo commodel = combll.GetgonggaoModel(1); if (combll.getfenleiExists(1) == true) { btnok.Visible = false; btntian.Visible = true; bind(); } else if (combll.getfenleiExists(1) == false) { btnok.Visible = true; btntian.Visible = false; } } else { Response.Redirect("login.aspx"); Response.End(); } } else { Response.Redirect("login.aspx"); Response.End(); } } }
/// <summary> /// 网站公告得到一个对象实体 /// </summary> public Maticsoft.Model.ComPanyInfo GetgonggaoModel(int FenleiID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 XianshiID,Gonggao,FenleiID from ComPanyInfo "); strSql.Append(" where FenleiID=@FenleiID"); SqlParameter[] parameters = { new SqlParameter("@FenleiID", SqlDbType.Int, 4) }; parameters[0].Value = FenleiID; Maticsoft.Model.ComPanyInfo model = new Maticsoft.Model.ComPanyInfo(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["XianshiID"].ToString() != "") { model.XianshiID = int.Parse(ds.Tables[0].Rows[0]["XianshiID"].ToString()); } model.Gonggao = ds.Tables[0].Rows[0]["Gonggao"].ToString(); if (ds.Tables[0].Rows[0]["FenleiID"].ToString() != "") { model.FenleiID = int.Parse(ds.Tables[0].Rows[0]["FenleiID"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 网站公告更新一条数据 /// </summary> public bool getupdate(Maticsoft.Model.ComPanyInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update ComPanyInfo set "); strSql.Append("Gonggao=@Gonggao,"); strSql.Append("GongTime=@GongTime,"); strSql.Append("FenleiID=@FenleiID"); strSql.Append(" where FenleiID=@FenleiID"); SqlParameter[] parameters = { new SqlParameter("@Gonggao", SqlDbType.Text), new SqlParameter("@GongTime", SqlDbType.DateTime), new SqlParameter("@FenleiID", SqlDbType.Int, 4) }; parameters[0].Value = model.Gonggao; parameters[1].Value = model.GongTime; parameters[2].Value = model.FenleiID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Maticsoft.Model.ComPanyInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ComPanyInfo("); strSql.Append("Gonggao,GongTime,ImageURL,FenleiID)"); strSql.Append(" values ("); strSql.Append("@Gonggao,@GongTime,@ImageURL,@FenleiID)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Gonggao", SqlDbType.Text), new SqlParameter("@GongTime", SqlDbType.DateTime), new SqlParameter("@ImageURL", SqlDbType.Text), new SqlParameter("@FenleiID", SqlDbType.Int, 4) }; parameters[0].Value = model.Gonggao; parameters[1].Value = model.GongTime; parameters[2].Value = model.ImageURL; parameters[3].Value = model.FenleiID; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
private void bind() { btnupdael.Visible = true; btnok.Visible = false; Maticsoft.BLL.ComPanyInfo combll = new Maticsoft.BLL.ComPanyInfo(); Maticsoft.Model.ComPanyInfo commodel = combll.GetgonggaoModel(2); txtwenhua.Text = commodel.Gonggao; }
protected void btnupdael_Click(object sender, EventArgs e) { Maticsoft.BLL.ComPanyInfo combll = new Maticsoft.BLL.ComPanyInfo(); Maticsoft.Model.ComPanyInfo commodel = combll.GetgonggaoModel(2); commodel.Gonggao = txtwenhua.Text.Trim(); combll.Update(commodel); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('信息提交成功')</script>"); bind(); }
private void ShowInfo(int XianshiID) { Maticsoft.BLL.ComPanyInfo bll = new Maticsoft.BLL.ComPanyInfo(); Maticsoft.Model.ComPanyInfo model = bll.GetModel(XianshiID); this.lblXianshiID.Text = model.XianshiID.ToString(); this.lblGonggao.Text = model.Gonggao; this.lblGongTime.Text = model.GongTime.ToString(); this.lblImageURL.Text = model.ImageURL; this.lblFenleiID.Text = model.FenleiID.ToString(); }
protected void btntian_Click(object sender, EventArgs e) { Maticsoft.BLL.ComPanyInfo combll = new Maticsoft.BLL.ComPanyInfo(); Maticsoft.Model.ComPanyInfo commodel = combll.GetgonggaoModel(1); commodel.Gonggao = txtgong.Text.Trim(); commodel.GongTime = Convert.ToDateTime(DateTime.Now.ToString()); combll.getupdate(commodel); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('信息提交成功!')</script>"); bind(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Maticsoft.BLL.ComPanyInfo combll = new Maticsoft.BLL.ComPanyInfo(); //int maxid = combll.GetgonggaoMaxID(2) - 1; Maticsoft.Model.ComPanyInfo commodel = combll.GetgonggaoModel(2); lblGonggao.Text = commodel.Gonggao; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { bind(); Maticsoft.BLL.ComPanyInfo combll = new Maticsoft.BLL.ComPanyInfo(); Maticsoft.Model.ComPanyInfo commodel = combll.GetgonggaoModel(1); lblgonggao.Text = commodel.Gonggao; } }
public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtGonggao.Text.Trim().Length == 0) { strErr += "Gonggao不能为空!\\n"; } if (!PageValidate.IsDateTime(txtGongTime.Text)) { strErr += "GongTime格式错误!\\n"; } if (this.txtImageURL.Text.Trim().Length == 0) { strErr += "ImageURL不能为空!\\n"; } if (!PageValidate.IsNumber(txtFenleiID.Text)) { strErr += "FenleiID格式错误!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int XianshiID = int.Parse(this.lblXianshiID.Text); string Gonggao = this.txtGonggao.Text; DateTime GongTime = DateTime.Parse(this.txtGongTime.Text); string ImageURL = this.txtImageURL.Text; int FenleiID = int.Parse(this.txtFenleiID.Text); Maticsoft.Model.ComPanyInfo model = new Maticsoft.Model.ComPanyInfo(); model.XianshiID = XianshiID; model.Gonggao = Gonggao; model.GongTime = GongTime; model.ImageURL = ImageURL; model.FenleiID = FenleiID; Maticsoft.BLL.ComPanyInfo bll = new Maticsoft.BLL.ComPanyInfo(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }
private void bind() { Maticsoft.BLL.ComPanyInfo combll = new Maticsoft.BLL.ComPanyInfo(); Maticsoft.Model.ComPanyInfo commodel1 = combll.GetgonggaoModel(1); txtgong.Text = commodel1.Gonggao; }