protected void btnSave_Click(object sender, EventArgs e) { foreach (GridViewRow row in myManageGridView.Rows) { string strId = ((Label)row.FindControl(STR_LABEL_ID)).Text; TextBox uptTopMenuName = (TextBox)row.FindControl("txtUptTopMenuName"); TextBox uptTips = (TextBox)row.FindControl("txtUptTips"); TextBox uptPageLink = (TextBox)row.FindControl("txtUptPageLink"); if (!CheckInputEmptyAndLength(uptTopMenuName, "E00401", "E00402", false)) return; if (!CheckInputEmptyAndLength(uptTips, "E00401", "E00402", false)) return; if (!CheckInputEmptyAndLength(uptPageLink, "E00403", "E00404")) return; //update Johnny.CMS.OM.SystemInfo.TopMenu model = new Johnny.CMS.OM.SystemInfo.TopMenu(); model.TopMenuId = DataConvert.GetInt32(strId); model.TopMenuName = uptTopMenuName.Text; model.ToolTip = uptTips.Text; model.PageLink = uptPageLink.Text; Johnny.CMS.BLL.SystemInfo.TopMenu bll = new Johnny.CMS.BLL.SystemInfo.TopMenu(); bll.Update(model); } SetMessage(GetMessage("C00003")); //update grid getData(); }
/// <summary> /// Method to get one record by primary key /// </summary> public Johnny.CMS.OM.SystemInfo.TopMenu GetModel(int topmenuid) { //Set up a return value Johnny.CMS.OM.SystemInfo.TopMenu model = null; StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT [TopMenuId], [TopMenuName], [ToolTip], [PageLink], [Sequence] "); strSql.Append(" FROM [cms_topmenu] "); strSql.Append(" WHERE [TopMenuId]=@topmenuid"); SqlParameter[] parameters = { new SqlParameter("@topmenuid", SqlDbType.Int, 4) }; parameters[0].Value = topmenuid; using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString(), parameters)) { if (sdr.Read()) { model = new Johnny.CMS.OM.SystemInfo.TopMenu(sdr.GetInt32(0), sdr.GetString(1), sdr.GetString(2), sdr.GetString(3), sdr.GetInt32(4)); } else { model = new Johnny.CMS.OM.SystemInfo.TopMenu(); } } return(model); }
protected void btnAdd_Click(object sender, System.EventArgs e) { if (!CheckInputEmptyAndLength(txtTopMenuName, "E00401", "E00402", false)) { return; } if (!CheckInputEmptyAndLength(txtToolTip, "E00401", "E00402", false)) { return; } if (!CheckInputEmptyAndLength(txtPageLink, "E00403", "E00404")) { return; } Johnny.CMS.BLL.SystemInfo.TopMenu bll = new Johnny.CMS.BLL.SystemInfo.TopMenu(); Johnny.CMS.OM.SystemInfo.TopMenu model = new Johnny.CMS.OM.SystemInfo.TopMenu(); if (Request.QueryString["action"] == "modify") { //update model.TopMenuId = Convert.ToInt32(Request.QueryString["id"]); model.TopMenuName = txtTopMenuName.Text; model.ToolTip = txtToolTip.Text; model.PageLink = txtPageLink.Text; //model.Image = txtImage.Text; bll.Update(model); SetMessage(GetMessage("C00003")); } else { //insert model.TopMenuName = txtTopMenuName.Text; model.ToolTip = txtToolTip.Text; model.PageLink = txtPageLink.Text; //model.Image = txtImage.Text; if (bll.Add(model) > 0) { SetMessage(GetMessage("C00001")); txtTopMenuName.Text = ""; txtToolTip.Text = ""; txtPageLink.Text = ""; } else { SetMessage(GetMessage("C00002")); } } }
protected override void Page_Load(object sender, EventArgs e) { base.Page_Load(sender, e); Johnny.CMS.OM.SystemInfo.TopMenu model = new Johnny.CMS.OM.SystemInfo.TopMenu(); base.ManageTable = model.TableName; base.ManageKey = model.PrimaryKey; base.IsDesc = model.IsDesc; if (!IsPostBack) { myManageGridView.Columns[2].HeaderText = GetLabelText("Topmenu_TopMenuName"); myManageGridView.Columns[3].HeaderText = GetLabelText("Topmenu_ToolTip"); myManageGridView.Columns[4].HeaderText = GetLabelText("Topmenu_PageLink"); getData(); } }
protected override void Page_Load(object sender, EventArgs e) { base.Page_Load(sender, e); Johnny.CMS.OM.SystemInfo.TopMenu model = new Johnny.CMS.OM.SystemInfo.TopMenu(); base.ManageTable = model.TableName; base.ManageKey = model.PrimaryKey; base.IsDesc = model.IsDesc; if (!IsPostBack) { myManageGridView.Columns[2].HeaderText = GetLabelText("Topmenu_TopMenuName"); myManageGridView.Columns[3].HeaderText = GetLabelText("Topmenu_ToolTip"); myManageGridView.Columns[4].HeaderText = GetLabelText("Topmenu_PageLink"); getData(); } }
/// <summary> /// Method to get records with condition /// </summary> public IList<Johnny.CMS.OM.SystemInfo.TopMenu> GetList() { IList<Johnny.CMS.OM.SystemInfo.TopMenu> list = new List<Johnny.CMS.OM.SystemInfo.TopMenu>(); StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT [TopMenuId], [TopMenuName], [ToolTip], [PageLink], [Sequence] "); strSql.Append(" FROM [cms_topmenu] "); strSql.Append(" ORDER BY [Sequence]"); using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString())) { while (sdr.Read()) { Johnny.CMS.OM.SystemInfo.TopMenu item = new Johnny.CMS.OM.SystemInfo.TopMenu(sdr.GetInt32(0), sdr.GetString(1), sdr.GetString(2), sdr.GetString(3), sdr.GetInt32(4)); list.Add(item); } } return list; }
protected void btnAdd_Click(object sender, System.EventArgs e) { if (!CheckInputEmptyAndLength(txtTopMenuName, "E00401","E00402", false)) return; if (!CheckInputEmptyAndLength(txtToolTip, "E00401", "E00402", false)) return; if (!CheckInputEmptyAndLength(txtPageLink, "E00403", "E00404")) return; Johnny.CMS.BLL.SystemInfo.TopMenu bll = new Johnny.CMS.BLL.SystemInfo.TopMenu(); Johnny.CMS.OM.SystemInfo.TopMenu model = new Johnny.CMS.OM.SystemInfo.TopMenu(); if (Request.QueryString["action"] == "modify") { //update model.TopMenuId = Convert.ToInt32(Request.QueryString["id"]); model.TopMenuName = txtTopMenuName.Text; model.ToolTip = txtToolTip.Text; model.PageLink = txtPageLink.Text; //model.Image = txtImage.Text; bll.Update(model); SetMessage(GetMessage("C00003")); } else { //insert model.TopMenuName = txtTopMenuName.Text; model.ToolTip = txtToolTip.Text; model.PageLink = txtPageLink.Text; //model.Image = txtImage.Text; if (bll.Add(model) > 0) { SetMessage(GetMessage("C00001")); txtTopMenuName.Text = ""; txtToolTip.Text = ""; txtPageLink.Text = ""; } else SetMessage(GetMessage("C00002")); } }
/// <summary> /// Method to get records with condition /// </summary> public IList <Johnny.CMS.OM.SystemInfo.TopMenu> GetList() { IList <Johnny.CMS.OM.SystemInfo.TopMenu> list = new List <Johnny.CMS.OM.SystemInfo.TopMenu>(); StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT [TopMenuId], [TopMenuName], [ToolTip], [PageLink], [Sequence] "); strSql.Append(" FROM [cms_topmenu] "); strSql.Append(" ORDER BY [Sequence]"); using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString())) { while (sdr.Read()) { Johnny.CMS.OM.SystemInfo.TopMenu item = new Johnny.CMS.OM.SystemInfo.TopMenu(sdr.GetInt32(0), sdr.GetString(1), sdr.GetString(2), sdr.GetString(3), sdr.GetInt32(4)); list.Add(item); } } return(list); }
/// <summary> /// Method to get one record by primary key /// </summary> public Johnny.CMS.OM.SystemInfo.TopMenu GetModel(int topmenuid) { //Set up a return value Johnny.CMS.OM.SystemInfo.TopMenu model = null; StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT [TopMenuId], [TopMenuName], [ToolTip], [PageLink], [Sequence] "); strSql.Append(" FROM [cms_topmenu] "); strSql.Append(" WHERE [TopMenuId]=@topmenuid"); SqlParameter[] parameters = { new SqlParameter("@topmenuid", SqlDbType.Int,4)}; parameters[0].Value = topmenuid; using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString(), parameters)) { if (sdr.Read()) model = new Johnny.CMS.OM.SystemInfo.TopMenu(sdr.GetInt32(0), sdr.GetString(1), sdr.GetString(2), sdr.GetString(3), sdr.GetInt32(4)); else model = new Johnny.CMS.OM.SystemInfo.TopMenu(); } return model; }
protected void btnSave_Click(object sender, EventArgs e) { foreach (GridViewRow row in myManageGridView.Rows) { string strId = ((Label)row.FindControl(STR_LABEL_ID)).Text; TextBox uptTopMenuName = (TextBox)row.FindControl("txtUptTopMenuName"); TextBox uptTips = (TextBox)row.FindControl("txtUptTips"); TextBox uptPageLink = (TextBox)row.FindControl("txtUptPageLink"); if (!CheckInputEmptyAndLength(uptTopMenuName, "E00401", "E00402", false)) { return; } if (!CheckInputEmptyAndLength(uptTips, "E00401", "E00402", false)) { return; } if (!CheckInputEmptyAndLength(uptPageLink, "E00403", "E00404")) { return; } //update Johnny.CMS.OM.SystemInfo.TopMenu model = new Johnny.CMS.OM.SystemInfo.TopMenu(); model.TopMenuId = DataConvert.GetInt32(strId); model.TopMenuName = uptTopMenuName.Text; model.ToolTip = uptTips.Text; model.PageLink = uptPageLink.Text; Johnny.CMS.BLL.SystemInfo.TopMenu bll = new Johnny.CMS.BLL.SystemInfo.TopMenu(); bll.Update(model); } SetMessage(GetMessage("C00003")); //update grid getData(); }
/// <summary> /// Update one record /// </summary> public void Update(Johnny.CMS.OM.SystemInfo.TopMenu model) { StringBuilder strSql = new StringBuilder(); strSql.Append("UPDATE [cms_topmenu] SET "); strSql.Append("[TopMenuName]=@topmenuname,"); strSql.Append("[ToolTip]=@toolTip,"); strSql.Append("[PageLink]=@pagelink"); strSql.Append(" WHERE [TopMenuId]=@topmenuid "); SqlParameter[] parameters = { new SqlParameter("@topmenuid", SqlDbType.Int, 4), new SqlParameter("@topmenuname", SqlDbType.NVarChar, 50), new SqlParameter("@toolTip", SqlDbType.NVarChar, 50), new SqlParameter("@pagelink", SqlDbType.VarChar, 100) }; parameters[0].Value = model.TopMenuId; parameters[1].Value = model.TopMenuName; parameters[2].Value = model.ToolTip; parameters[3].Value = model.PageLink; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
protected override void Page_Load(object sender, EventArgs e) { base.Page_Load(sender, e); if (!this.IsPostBack) { litPageTitle.Text = GetLabelText("TopMenu_Title"); litTopMenuName.Text = GetLabelText("Topmenu_TopMenuName"); txtTopMenuName.ToolTip = GetLabelText("Topmenu_TopMenuName"); litToolTip.Text = GetLabelText("Topmenu_ToolTip"); txtToolTip.ToolTip = GetLabelText("Topmenu_ToolTip"); litPageLink.Text = GetLabelText("Topmenu_PageLink"); txtPageLink.ToolTip = GetLabelText("Topmenu_PageLink"); if (Request.QueryString["action"] == "modify") { //get TopMenuId int TopMenuId = Convert.ToInt32(Request.QueryString["id"]); Johnny.CMS.BLL.SystemInfo.TopMenu bll = new Johnny.CMS.BLL.SystemInfo.TopMenu(); Johnny.CMS.OM.SystemInfo.TopMenu model = new Johnny.CMS.OM.SystemInfo.TopMenu(); model = bll.GetModel(TopMenuId); txtTopMenuName.Text = model.TopMenuName; txtToolTip.Text = model.ToolTip; txtPageLink.Text = model.PageLink; //txtImage.Text = model.Image; btnAdd.ButtonType = Johnny.Controls.Web.Button.Button.EnumButtonType.Save; //btnAdd.Text = CONST_BUTTONTEXT_SAVE; } //RFVldtTopMenuName.ErrorMessage = GetMessage("E00401", txtTopMenuName.MaxLength.ToString()); //RFVldtPageLink.ErrorMessage = GetMessage("E00403", txtPageLink.MaxLength.ToString()); } }
/// <summary> /// Add one record /// </summary> public int Add(Johnny.CMS.OM.SystemInfo.TopMenu model) { StringBuilder strSql = new StringBuilder(); strSql.Append("DECLARE @Sequence int"); strSql.Append(" SELECT @Sequence=(max(Sequence)+1) FROM [cms_topmenu]"); strSql.Append(" if @Sequence is NULL"); strSql.Append(" Set @Sequence=1"); strSql.Append("INSERT INTO [cms_topmenu]("); strSql.Append("[TopMenuName],[toolTip],[PageLink],[Sequence]"); strSql.Append(")"); strSql.Append(" VALUES ("); strSql.Append("@topmenuname,@toolTip,@pagelink,@Sequence"); strSql.Append(")"); strSql.Append(";SELECT @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@topmenuname", SqlDbType.NVarChar, 50), new SqlParameter("@toolTip", SqlDbType.NVarChar, 50), new SqlParameter("@pagelink", SqlDbType.VarChar, 100) }; parameters[0].Value = model.TopMenuName; parameters[1].Value = model.ToolTip; parameters[2].Value = model.PageLink; 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("TopMenu_Title"); litTopMenuName.Text = GetLabelText("Topmenu_TopMenuName"); txtTopMenuName.ToolTip = GetLabelText("Topmenu_TopMenuName"); litToolTip.Text = GetLabelText("Topmenu_ToolTip"); txtToolTip.ToolTip = GetLabelText("Topmenu_ToolTip"); litPageLink.Text = GetLabelText("Topmenu_PageLink"); txtPageLink.ToolTip = GetLabelText("Topmenu_PageLink"); if (Request.QueryString["action"] == "modify") { //get TopMenuId int TopMenuId = Convert.ToInt32(Request.QueryString["id"]); Johnny.CMS.BLL.SystemInfo.TopMenu bll = new Johnny.CMS.BLL.SystemInfo.TopMenu(); Johnny.CMS.OM.SystemInfo.TopMenu model = new Johnny.CMS.OM.SystemInfo.TopMenu(); model = bll.GetModel(TopMenuId); txtTopMenuName.Text = model.TopMenuName; txtToolTip.Text = model.ToolTip; txtPageLink.Text = model.PageLink; //txtImage.Text = model.Image; btnAdd.ButtonType = Johnny.Controls.Web.Button.Button.EnumButtonType.Save; //btnAdd.Text = CONST_BUTTONTEXT_SAVE; } //RFVldtTopMenuName.ErrorMessage = GetMessage("E00401", txtTopMenuName.MaxLength.ToString()); //RFVldtPageLink.ErrorMessage = GetMessage("E00403", txtPageLink.MaxLength.ToString()); } }
/// <summary> /// Update one record /// </summary> public void Update(Johnny.CMS.OM.SystemInfo.TopMenu model) { dal.Update(model); }
/// <summary> /// Add one record /// </summary> public int Add(Johnny.CMS.OM.SystemInfo.TopMenu model) { return(dal.Add(model)); }