protected void btnAdd_Click(object sender, System.EventArgs e) { //validation if (!CheckInputEmptyAndLength(txtBlogCategoryName, "E00801", "E00802", false)) return; Johnny.CMS.BLL.SeH.BlogCategory bll = new Johnny.CMS.BLL.SeH.BlogCategory(); Johnny.CMS.OM.SeH.BlogCategory model = new Johnny.CMS.OM.SeH.BlogCategory(); if (Request.QueryString["action"] == "modify") { //update model.BlogCategoryId = DataConvert.GetInt32(Request.QueryString["id"]); model.BlogCategoryName = txtBlogCategoryName.Text; bll.Update(model); SetMessage(GetMessage("C00003")); } else { //insert model.BlogCategoryName = txtBlogCategoryName.Text; if (bll.Add(model) > 0) { SetMessage(GetMessage("C00001")); txtBlogCategoryName.Text = ""; } else SetMessage(GetMessage("C00002")); } }
/// <summary> /// Add one record /// </summary> public int Add(Johnny.CMS.OM.SeH.BlogCategory model) { StringBuilder strSql = new StringBuilder(); strSql.Append("DECLARE @Sequence int"); strSql.Append(" SELECT @Sequence=(max(Sequence)+1) FROM [seh_blogcategory]"); strSql.Append(" if @Sequence is NULL"); strSql.Append(" Set @Sequence=1"); strSql.Append("INSERT INTO [seh_blogcategory]("); strSql.Append("[BlogCategoryName],[Sequence]"); strSql.Append(")"); strSql.Append(" VALUES ("); strSql.Append("@blogcategoryname,@sequence"); strSql.Append(")"); strSql.Append(";SELECT @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@blogcategoryname", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.BlogCategoryName; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
protected override void Page_Load(object sender, EventArgs e) { base.Page_Load(sender, e); if (!this.IsPostBack) { litPageTitle.Text = GetLabelText("BlogCategory_Title"); litBlogCategoryName.Text = GetLabelText("Blogcategory_BlogCategoryName"); txtBlogCategoryName.ToolTip = GetLabelText("Blogcategory_BlogCategoryName"); if (Request.QueryString["action"] == "modify") { //primary key int BlogCategoryId = DataConvert.GetInt32(Request.QueryString["id"]); Johnny.CMS.BLL.SeH.BlogCategory bll = new Johnny.CMS.BLL.SeH.BlogCategory(); Johnny.CMS.OM.SeH.BlogCategory model = new Johnny.CMS.OM.SeH.BlogCategory(); model = bll.GetModel(BlogCategoryId); txtBlogCategoryName.Text = model.BlogCategoryName; btnAdd.ButtonType = Johnny.Controls.Web.Button.Button.EnumButtonType.Save; //btnAdd.Text = CONST_BUTTONTEXT_SAVE; } //RFVldtMenuCategoryName.ErrorMessage = GetMessage("E00801", txtMenuCategoryName.MaxLength.ToString()); } }
protected void btnSave_Click(object sender, EventArgs e) { foreach (GridViewRow row in myManageGridView.Rows) { string strId = ((Label)row.FindControl(STR_LABEL_ID)).Text; TextBox uptBlogCategoryName = (TextBox)row.FindControl("txtUptBlogCategoryName"); //validation if (!CheckInputEmptyAndLength(uptBlogCategoryName, "E00801", "E00802", false)) { return; } //update Johnny.CMS.OM.SeH.BlogCategory model = new Johnny.CMS.OM.SeH.BlogCategory(); model.BlogCategoryId = DataConvert.GetInt32(strId); model.BlogCategoryName = uptBlogCategoryName.Text; Johnny.CMS.BLL.SeH.BlogCategory bll = new Johnny.CMS.BLL.SeH.BlogCategory(); bll.Update(model); } SetMessage(GetMessage("C00003")); //update grid getData(); }
/// <summary> /// Method to get one recoder by primary key /// </summary> public Johnny.CMS.OM.SeH.BlogCategory GetModel(int blogcategoryid) { //Set up a return value Johnny.CMS.OM.SeH.BlogCategory model = null; StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT [BlogCategoryId], [BlogCategoryName], [Sequence] "); strSql.Append(" FROM [seh_blogcategory] "); strSql.Append(" WHERE [BlogCategoryId]=@blogcategoryid"); SqlParameter[] parameters = { new SqlParameter("@blogcategoryid", SqlDbType.Int, 4) }; parameters[0].Value = blogcategoryid; using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString(), parameters)) { if (sdr.Read()) { model = new Johnny.CMS.OM.SeH.BlogCategory(sdr.GetInt32(0), sdr.GetString(1), sdr.GetInt32(2)); } else { model = new Johnny.CMS.OM.SeH.BlogCategory(); } } return(model); }
protected override void Page_Load(object sender, EventArgs e) { base.Page_Load(sender, e); if (!this.IsPostBack) { litPageTitle.Text = GetLabelText("BlogCategory_Title"); litBlogCategoryName.Text = GetLabelText("Blogcategory_BlogCategoryName"); txtBlogCategoryName.ToolTip = GetLabelText("Blogcategory_BlogCategoryName"); if (Request.QueryString["action"] == "modify") { //primary key int BlogCategoryId = DataConvert.GetInt32(Request.QueryString["id"]); Johnny.CMS.BLL.SeH.BlogCategory bll = new Johnny.CMS.BLL.SeH.BlogCategory(); Johnny.CMS.OM.SeH.BlogCategory model = new Johnny.CMS.OM.SeH.BlogCategory(); model = bll.GetModel(BlogCategoryId); txtBlogCategoryName.Text = model.BlogCategoryName; btnAdd.ButtonType = Johnny.Controls.Web.Button.Button.EnumButtonType.Save; //btnAdd.Text = CONST_BUTTONTEXT_SAVE; } //RFVldtMenuCategoryName.ErrorMessage = GetMessage("E00801", txtMenuCategoryName.MaxLength.ToString()); } }
protected void btnSave_Click(object sender, EventArgs e) { foreach (GridViewRow row in myManageGridView.Rows) { string strId = ((Label)row.FindControl(STR_LABEL_ID)).Text; TextBox uptBlogCategoryName = (TextBox)row.FindControl("txtUptBlogCategoryName"); //validation if (!CheckInputEmptyAndLength(uptBlogCategoryName, "E00801", "E00802", false)) return; //update Johnny.CMS.OM.SeH.BlogCategory model = new Johnny.CMS.OM.SeH.BlogCategory(); model.BlogCategoryId = DataConvert.GetInt32(strId); model.BlogCategoryName = uptBlogCategoryName.Text; Johnny.CMS.BLL.SeH.BlogCategory bll = new Johnny.CMS.BLL.SeH.BlogCategory(); bll.Update(model); } SetMessage(GetMessage("C00003")); //update grid getData(); }
protected override void Page_Load(object sender, EventArgs e) { base.Page_Load(sender, e); Johnny.CMS.OM.SeH.BlogCategory model = new Johnny.CMS.OM.SeH.BlogCategory(); base.ManageTable = model.TableName; base.ManageKey = model.PrimaryKey; base.IsDesc = model.IsDesc; if (!IsPostBack) { myManageGridView.Columns[2].HeaderText = GetLabelText("Blogcategory_BlogCategoryName"); getData(); } }
protected override void Page_Load(object sender, EventArgs e) { base.Page_Load(sender, e); Johnny.CMS.OM.SeH.BlogCategory model = new Johnny.CMS.OM.SeH.BlogCategory(); base.ManageTable = model.TableName; base.ManageKey = model.PrimaryKey; base.IsDesc = model.IsDesc; if (!IsPostBack) { myManageGridView.Columns[2].HeaderText = GetLabelText("Blogcategory_BlogCategoryName"); getData(); } }
/// <summary> /// Update one record /// </summary> public void Update(Johnny.CMS.OM.SeH.BlogCategory model) { StringBuilder strSql = new StringBuilder(); strSql.Append("UPDATE [seh_blogcategory] SET "); strSql.Append("[BlogCategoryName]=@blogcategoryname"); strSql.Append(" WHERE [BlogCategoryId]=@blogcategoryid "); SqlParameter[] parameters = { new SqlParameter("@blogcategoryid", SqlDbType.Int, 4), new SqlParameter("@blogcategoryname", SqlDbType.NVarChar, 50), }; parameters[0].Value = model.BlogCategoryId; parameters[1].Value = model.BlogCategoryName; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
/// <summary> /// Method to get recoders with condition /// </summary> public IList<Johnny.CMS.OM.SeH.BlogCategory> GetList() { IList<Johnny.CMS.OM.SeH.BlogCategory> list = new List<Johnny.CMS.OM.SeH.BlogCategory>(); StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT [BlogCategoryId], [BlogCategoryName], [Sequence] "); strSql.Append(" FROM [seh_blogcategory] "); strSql.Append(" ORDER BY [Sequence]"); using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString())) { while (sdr.Read()) { Johnny.CMS.OM.SeH.BlogCategory item = new Johnny.CMS.OM.SeH.BlogCategory(sdr.GetInt32(0), sdr.GetString(1), sdr.GetInt32(2)); list.Add(item); } } return list; }
/// <summary> /// Method to get recoders with condition /// </summary> public IList <Johnny.CMS.OM.SeH.BlogCategory> GetList() { IList <Johnny.CMS.OM.SeH.BlogCategory> list = new List <Johnny.CMS.OM.SeH.BlogCategory>(); StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT [BlogCategoryId], [BlogCategoryName], [Sequence] "); strSql.Append(" FROM [seh_blogcategory] "); strSql.Append(" ORDER BY [Sequence]"); using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString())) { while (sdr.Read()) { Johnny.CMS.OM.SeH.BlogCategory item = new Johnny.CMS.OM.SeH.BlogCategory(sdr.GetInt32(0), sdr.GetString(1), sdr.GetInt32(2)); list.Add(item); } } return(list); }
/// <summary> /// Method to get one recoder by primary key /// </summary> public Johnny.CMS.OM.SeH.BlogCategory GetModel(int blogcategoryid) { //Set up a return value Johnny.CMS.OM.SeH.BlogCategory model = null; StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT [BlogCategoryId], [BlogCategoryName], [Sequence] "); strSql.Append(" FROM [seh_blogcategory] "); strSql.Append(" WHERE [BlogCategoryId]=@blogcategoryid"); SqlParameter[] parameters = { new SqlParameter("@blogcategoryid", SqlDbType.Int,4)}; parameters[0].Value = blogcategoryid; using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString(), parameters)) { if (sdr.Read()) model = new Johnny.CMS.OM.SeH.BlogCategory(sdr.GetInt32(0), sdr.GetString(1), sdr.GetInt32(2)); else model = new Johnny.CMS.OM.SeH.BlogCategory(); } return model; }
protected void btnAdd_Click(object sender, System.EventArgs e) { //validation if (!CheckInputEmptyAndLength(txtBlogCategoryName, "E00801", "E00802", false)) { return; } Johnny.CMS.BLL.SeH.BlogCategory bll = new Johnny.CMS.BLL.SeH.BlogCategory(); Johnny.CMS.OM.SeH.BlogCategory model = new Johnny.CMS.OM.SeH.BlogCategory(); if (Request.QueryString["action"] == "modify") { //update model.BlogCategoryId = DataConvert.GetInt32(Request.QueryString["id"]); model.BlogCategoryName = txtBlogCategoryName.Text; bll.Update(model); SetMessage(GetMessage("C00003")); } else { //insert model.BlogCategoryName = txtBlogCategoryName.Text; if (bll.Add(model) > 0) { SetMessage(GetMessage("C00001")); txtBlogCategoryName.Text = ""; } else { SetMessage(GetMessage("C00002")); } } }
/// <summary> /// Update one record /// </summary> public void Update(Johnny.CMS.OM.SeH.BlogCategory model) { dal.Update(model); }
/// <summary> /// Add one record /// </summary> public int Add(Johnny.CMS.OM.SeH.BlogCategory model) { return(dal.Add(model)); }