protected void btnSave_Click(object sender, EventArgs e) { foreach (GridViewRow row in myManageGridView.Rows) { string strId = ((Label)row.FindControl(STR_LABEL_ID)).Text; TextBox uptPermissionCategoryName = (TextBox)row.FindControl("txtUptPermissionCategoryName"); //check title if (!CheckInputEmptyAndLength(uptPermissionCategoryName, "E01201", "E01202", false)) { return; } //update Johnny.CMS.OM.Access.PermissionCategory model = new Johnny.CMS.OM.Access.PermissionCategory(); model.PermissionCategoryId = DataConvert.GetInt32(strId); model.PermissionCategoryName = uptPermissionCategoryName.Text; Johnny.CMS.BLL.Access.PermissionCategory bll = new Johnny.CMS.BLL.Access.PermissionCategory(); bll.Update(model); } SetMessage(GetMessage("C00003")); //update grid getData(); }
protected override void Page_Load(object sender, EventArgs e) { base.Page_Load(sender, e); if (!this.IsPostBack) { litPageTitle.Text = GetLabelText("PermissionCategory_Title"); litPermissionCategory.Text = GetLabelText("Permissioncategory_PermissionCategoryName"); txtPermissionCategoryName.ToolTip = GetLabelText("Permissioncategory_PermissionCategoryName"); if (Request.QueryString["action"] == "modify") { //get PermissionCategoryId int PermissionCategoryId = Convert.ToInt32(Request.QueryString["id"]); //PermissionCategory entity Johnny.CMS.BLL.Access.PermissionCategory bll = new Johnny.CMS.BLL.Access.PermissionCategory(); //bind data Johnny.CMS.OM.Access.PermissionCategory model = new Johnny.CMS.OM.Access.PermissionCategory(); model = bll.GetModel(PermissionCategoryId); txtPermissionCategoryName.Text = model.PermissionCategoryName; btnAdd.ButtonType = Johnny.Controls.Web.Button.Button.EnumButtonType.Save; //btnAdd.Text = CONST_BUTTONTEXT_SAVE; } //RFVldtPermissionName.ErrorMessage = GetMessage("E01201", txtDescription.MaxLength.ToString()); } }
/// <summary> /// Add one record /// </summary> public int Add(Johnny.CMS.OM.Access.PermissionCategory model) { StringBuilder strSql = new StringBuilder(); strSql.Append("DECLARE @Sequence int"); strSql.Append(" SELECT @Sequence=(max(Sequence)+1) FROM [cms_permissioncategory]"); strSql.Append(" if @Sequence is NULL"); strSql.Append(" Set @Sequence=1"); strSql.Append("INSERT INTO [cms_permissioncategory]("); strSql.Append("[PermissionCategoryName],[Sequence]"); strSql.Append(")"); strSql.Append(" VALUES ("); strSql.Append("@permissioncategoryname,@Sequence"); strSql.Append(")"); strSql.Append(";SELECT @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@permissioncategoryname", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.PermissionCategoryName; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
protected void btnAdd_Click(object sender, System.EventArgs e) { //check category name if (!CheckInputEmptyAndLength(txtPermissionCategoryName, "E01201", "E01202", false)) return; Johnny.CMS.BLL.Access.PermissionCategory bll = new Johnny.CMS.BLL.Access.PermissionCategory(); Johnny.CMS.OM.Access.PermissionCategory model = new Johnny.CMS.OM.Access.PermissionCategory(); if (Request.QueryString["action"] == "modify") { //update model.PermissionCategoryId = Convert.ToInt32(Request.QueryString["id"]); model.PermissionCategoryName = txtPermissionCategoryName.Text; bll.Update(model); SetMessage(GetMessage("C00003")); } else { //insert model.PermissionCategoryName = txtPermissionCategoryName.Text; if (bll.Add(model) > 0) { SetMessage(GetMessage("C00001")); txtPermissionCategoryName.Text = ""; } else SetMessage(GetMessage("C00002")); } }
protected override void Page_Load(object sender, EventArgs e) { base.Page_Load(sender, e); if (!this.IsPostBack) { litPageTitle.Text = GetLabelText("PermissionCategory_Title"); litPermissionCategory.Text = GetLabelText("Permissioncategory_PermissionCategoryName"); txtPermissionCategoryName.ToolTip = GetLabelText("Permissioncategory_PermissionCategoryName"); if (Request.QueryString["action"] == "modify") { //get PermissionCategoryId int PermissionCategoryId = Convert.ToInt32(Request.QueryString["id"]); //PermissionCategory entity Johnny.CMS.BLL.Access.PermissionCategory bll = new Johnny.CMS.BLL.Access.PermissionCategory(); //bind data Johnny.CMS.OM.Access.PermissionCategory model = new Johnny.CMS.OM.Access.PermissionCategory(); model = bll.GetModel(PermissionCategoryId); txtPermissionCategoryName.Text = model.PermissionCategoryName; btnAdd.ButtonType = Johnny.Controls.Web.Button.Button.EnumButtonType.Save; //btnAdd.Text = CONST_BUTTONTEXT_SAVE; } //RFVldtPermissionName.ErrorMessage = GetMessage("E01201", txtDescription.MaxLength.ToString()); } }
/// <summary> /// Method to get one record by primary key /// </summary> public Johnny.CMS.OM.Access.PermissionCategory GetModel(int permissioncategoryid) { //Set up a return value Johnny.CMS.OM.Access.PermissionCategory model = null; StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT [PermissionCategoryId], [PermissionCategoryName], [Sequence] "); strSql.Append(" FROM [cms_permissioncategory] "); strSql.Append(" WHERE [PermissionCategoryId]=@permissioncategoryid"); SqlParameter[] parameters = { new SqlParameter("@permissioncategoryid", SqlDbType.Int, 4) }; parameters[0].Value = permissioncategoryid; using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString(), parameters)) { if (sdr.Read()) { model = new Johnny.CMS.OM.Access.PermissionCategory(sdr.GetInt32(0), sdr.GetString(1), sdr.GetInt32(2)); } else { model = new Johnny.CMS.OM.Access.PermissionCategory(); } } return(model); }
protected override void Page_Load(object sender, EventArgs e) { base.Page_Load(sender, e); Johnny.CMS.OM.Access.PermissionCategory model = new Johnny.CMS.OM.Access.PermissionCategory(); base.ManageTable = model.TableName; base.ManageKey = model.PrimaryKey; base.IsDesc = model.IsDesc; if (!IsPostBack) { myManageGridView.Columns[2].HeaderText = GetLabelText("Permissioncategory_PermissionCategoryName"); getData(); } }
/// <summary> /// Update one record /// </summary> public void Update(Johnny.CMS.OM.Access.PermissionCategory model) { StringBuilder strSql = new StringBuilder(); strSql.Append("UPDATE [cms_permissioncategory] SET "); strSql.Append("[PermissionCategoryName]=@permissioncategoryname"); strSql.Append(" WHERE [PermissionCategoryId]=@permissioncategoryid "); SqlParameter[] parameters = { new SqlParameter("@permissioncategoryid", SqlDbType.Int, 4), new SqlParameter("@permissioncategoryname", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.PermissionCategoryId; parameters[1].Value = model.PermissionCategoryName; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
/// <summary> /// Method to get records with condition /// </summary> public IList<Johnny.CMS.OM.Access.PermissionCategory> GetList() { IList<Johnny.CMS.OM.Access.PermissionCategory> list = new List<Johnny.CMS.OM.Access.PermissionCategory>(); StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT [PermissionCategoryId], [PermissionCategoryName], [Sequence] "); strSql.Append(" FROM [cms_permissioncategory] "); strSql.Append(" ORDER BY [Sequence]"); using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString())) { while (sdr.Read()) { Johnny.CMS.OM.Access.PermissionCategory item = new Johnny.CMS.OM.Access.PermissionCategory(sdr.GetInt32(0), sdr.GetString(1), sdr.GetInt32(2)); list.Add(item); } } return list; }
/// <summary> /// Method to get records with condition /// </summary> public IList <Johnny.CMS.OM.Access.PermissionCategory> GetList() { IList <Johnny.CMS.OM.Access.PermissionCategory> list = new List <Johnny.CMS.OM.Access.PermissionCategory>(); StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT [PermissionCategoryId], [PermissionCategoryName], [Sequence] "); strSql.Append(" FROM [cms_permissioncategory] "); strSql.Append(" ORDER BY [Sequence]"); using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString())) { while (sdr.Read()) { Johnny.CMS.OM.Access.PermissionCategory item = new Johnny.CMS.OM.Access.PermissionCategory(sdr.GetInt32(0), sdr.GetString(1), sdr.GetInt32(2)); list.Add(item); } } return(list); }
/// <summary> /// Method to get one record by primary key /// </summary> public Johnny.CMS.OM.Access.PermissionCategory GetModel(int permissioncategoryid) { //Set up a return value Johnny.CMS.OM.Access.PermissionCategory model = null; StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT [PermissionCategoryId], [PermissionCategoryName], [Sequence] "); strSql.Append(" FROM [cms_permissioncategory] "); strSql.Append(" WHERE [PermissionCategoryId]=@permissioncategoryid"); SqlParameter[] parameters = { new SqlParameter("@permissioncategoryid", SqlDbType.Int,4)}; parameters[0].Value = permissioncategoryid; using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString(), parameters)) { if (sdr.Read()) model = new Johnny.CMS.OM.Access.PermissionCategory(sdr.GetInt32(0), sdr.GetString(1), sdr.GetInt32(2)); else model = new Johnny.CMS.OM.Access.PermissionCategory(); } return model; }
protected void btnAdd_Click(object sender, System.EventArgs e) { //check category name if (!CheckInputEmptyAndLength(txtPermissionCategoryName, "E01201", "E01202", false)) { return; } Johnny.CMS.BLL.Access.PermissionCategory bll = new Johnny.CMS.BLL.Access.PermissionCategory(); Johnny.CMS.OM.Access.PermissionCategory model = new Johnny.CMS.OM.Access.PermissionCategory(); if (Request.QueryString["action"] == "modify") { //update model.PermissionCategoryId = Convert.ToInt32(Request.QueryString["id"]); model.PermissionCategoryName = txtPermissionCategoryName.Text; bll.Update(model); SetMessage(GetMessage("C00003")); } else { //insert model.PermissionCategoryName = txtPermissionCategoryName.Text; if (bll.Add(model) > 0) { SetMessage(GetMessage("C00001")); txtPermissionCategoryName.Text = ""; } else { SetMessage(GetMessage("C00002")); } } }
/// <summary> /// Update one record /// </summary> public void Update(Johnny.CMS.OM.Access.PermissionCategory model) { dal.Update(model); }
/// <summary> /// Add one record /// </summary> public int Add(Johnny.CMS.OM.Access.PermissionCategory model) { return(dal.Add(model)); }