protected void btnSave_Click(object sender, EventArgs e) { string[] accouts = hdnAllSelected.Value.Split(','); int TopMenuId = DataConvert.GetInt32(ddlTopMenus.SelectedValue); Johnny.CMS.BLL.SystemInfo.TopMenuBinding bll = new Johnny.CMS.BLL.SystemInfo.TopMenuBinding(); bll.Delete(TopMenuId); for (int ix = 0; ix < accouts.Length; ix++) { if (accouts[ix] != string.Empty) { Johnny.CMS.OM.SystemInfo.TopMenuBinding model = new Johnny.CMS.OM.SystemInfo.TopMenuBinding(); model.TopMenuId = TopMenuId; model.MenuCategoryId = DataConvert.GetInt32(accouts[ix]); if (bll.Add(model) > 0) { SetMessage(GetMessage("C00001")); } else { SetMessage(GetMessage("C00002")); } } } CreateMenuCategoryList(); }
/// <summary> /// Method to get records with condition /// </summary> public IList<Johnny.CMS.OM.SystemInfo.TopMenuBinding> GetList(int topmenuid) { IList<Johnny.CMS.OM.SystemInfo.TopMenuBinding> list = new List<Johnny.CMS.OM.SystemInfo.TopMenuBinding>(); StringBuilder strSql = new StringBuilder(); //strSql.Append("SELECT [TopMenuId], [MenuCategoryId] "); //strSql.Append(" FROM [cms_topmenubinding] "); //strSql.Append(" ORDER BY [Sequence]"); strSql.Append(" SELECT [cms_topmenubinding].[TopMenuId],[cms_topmenu].[TopMenuName],[cms_topmenubinding].[MenuCategoryId],[cms_menucategory].[MenuCategoryName]"); strSql.Append(" FROM [cms_topmenubinding]"); strSql.Append(" LEFT OUTER JOIN [cms_topmenu]"); strSql.Append(" ON [cms_topmenubinding].[TopMenuId] = [cms_topmenu].[TopMenuId]"); strSql.Append(" LEFT OUTER JOIN [cms_menucategory]"); strSql.Append(" ON [cms_topmenubinding].[MenuCategoryId] = [cms_menucategory].[MenuCategoryId]"); strSql.Append(" WHERE [cms_topmenubinding].[TopMenuId]=@topmenuid"); SqlParameter[] parameters = { new SqlParameter("@topmenuid", SqlDbType.Int,4)}; parameters[0].Value = topmenuid; using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString(), parameters)) { while (sdr.Read()) { //Johnny.CMS.OM.SystemInfo.TopMainMenu item = new Johnny.CMS.OM.SystemInfo.TopMainMenu(sdr.GetInt32(0), sdr.GetInt32(1)); Johnny.CMS.OM.SystemInfo.TopMenuBinding item = new Johnny.CMS.OM.SystemInfo.TopMenuBinding(sdr.GetInt32(0), sdr.GetString(1), sdr.GetInt32(2), sdr.GetString(3)); list.Add(item); } } return list; }
/// <summary> /// Method to get one record by primary key /// </summary> public Johnny.CMS.OM.SystemInfo.TopMenuBinding GetModel(int topmenuid) { //Set up a return value Johnny.CMS.OM.SystemInfo.TopMenuBinding model = null; StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT [TopMenuId], [MenuCategoryId] "); strSql.Append(" FROM [cms_topmenubinding] "); 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.TopMenuBinding(sdr.GetInt32(0), sdr.GetInt32(1)); } else { model = new Johnny.CMS.OM.SystemInfo.TopMenuBinding(); } } return(model); }
/// <summary> /// Method to get records with condition /// </summary> public IList <Johnny.CMS.OM.SystemInfo.TopMenuBinding> GetList(int topmenuid) { IList <Johnny.CMS.OM.SystemInfo.TopMenuBinding> list = new List <Johnny.CMS.OM.SystemInfo.TopMenuBinding>(); StringBuilder strSql = new StringBuilder(); //strSql.Append("SELECT [TopMenuId], [MenuCategoryId] "); //strSql.Append(" FROM [cms_topmenubinding] "); //strSql.Append(" ORDER BY [Sequence]"); strSql.Append(" SELECT [cms_topmenubinding].[TopMenuId],[cms_topmenu].[TopMenuName],[cms_topmenubinding].[MenuCategoryId],[cms_menucategory].[MenuCategoryName]"); strSql.Append(" FROM [cms_topmenubinding]"); strSql.Append(" LEFT OUTER JOIN [cms_topmenu]"); strSql.Append(" ON [cms_topmenubinding].[TopMenuId] = [cms_topmenu].[TopMenuId]"); strSql.Append(" LEFT OUTER JOIN [cms_menucategory]"); strSql.Append(" ON [cms_topmenubinding].[MenuCategoryId] = [cms_menucategory].[MenuCategoryId]"); strSql.Append(" WHERE [cms_topmenubinding].[TopMenuId]=@topmenuid"); SqlParameter[] parameters = { new SqlParameter("@topmenuid", SqlDbType.Int, 4) }; parameters[0].Value = topmenuid; using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString(), parameters)) { while (sdr.Read()) { //Johnny.CMS.OM.SystemInfo.TopMainMenu item = new Johnny.CMS.OM.SystemInfo.TopMainMenu(sdr.GetInt32(0), sdr.GetInt32(1)); Johnny.CMS.OM.SystemInfo.TopMenuBinding item = new Johnny.CMS.OM.SystemInfo.TopMenuBinding(sdr.GetInt32(0), sdr.GetString(1), sdr.GetInt32(2), sdr.GetString(3)); list.Add(item); } } return(list); }
/// <summary> /// Add one record /// </summary> public int Add(Johnny.CMS.OM.SystemInfo.TopMenuBinding model) { StringBuilder strSql = new StringBuilder(); strSql.Append("INSERT INTO [cms_topmenubinding]("); strSql.Append("[TopMenuId],[MenuCategoryId]"); strSql.Append(")"); strSql.Append(" VALUES ("); strSql.Append("@topmenuid,"); strSql.Append("@menucategoryid"); strSql.Append(")"); strSql.Append(";SELECT @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@topmenuid", SqlDbType.Int, 4), new SqlParameter("@menucategoryid", SqlDbType.Int, 4) }; parameters[0].Value = model.TopMenuId; parameters[1].Value = model.MenuCategoryId; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
protected void btnSave_Click(object sender, EventArgs e) { string[] accouts = hdnAllSelected.Value.Split(','); int TopMenuId = DataConvert.GetInt32(ddlTopMenus.SelectedValue); Johnny.CMS.BLL.SystemInfo.TopMenuBinding bll = new Johnny.CMS.BLL.SystemInfo.TopMenuBinding(); bll.Delete(TopMenuId); for (int ix = 0; ix < accouts.Length; ix++) { if (accouts[ix] != string.Empty) { Johnny.CMS.OM.SystemInfo.TopMenuBinding model = new Johnny.CMS.OM.SystemInfo.TopMenuBinding(); model.TopMenuId = TopMenuId; model.MenuCategoryId = DataConvert.GetInt32(accouts[ix]); if (bll.Add(model) > 0) { SetMessage(GetMessage("C00001")); } else SetMessage(GetMessage("C00002")); } } CreateMenuCategoryList(); }
/// <summary> /// Update one record /// </summary> public void Update(Johnny.CMS.OM.SystemInfo.TopMenuBinding model) { StringBuilder strSql = new StringBuilder(); strSql.Append("UPDATE [cms_topmenubinding] SET "); strSql.Append("[MenuCategoryId]=@menucategoryid"); strSql.Append(" WHERE [TopMenuId]=@topmenuid "); SqlParameter[] parameters = { new SqlParameter("@topmenuid", SqlDbType.Int, 4), new SqlParameter("@menucategoryid", SqlDbType.Int, 4) }; parameters[0].Value = model.TopMenuId; parameters[1].Value = model.MenuCategoryId; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
/// <summary> /// Method to get one record by primary key /// </summary> public Johnny.CMS.OM.SystemInfo.TopMenuBinding GetModel(int topmenuid) { //Set up a return value Johnny.CMS.OM.SystemInfo.TopMenuBinding model = null; StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT [TopMenuId], [MenuCategoryId] "); strSql.Append(" FROM [cms_topmenubinding] "); 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.TopMenuBinding(sdr.GetInt32(0), sdr.GetInt32(1)); else model = new Johnny.CMS.OM.SystemInfo.TopMenuBinding(); } return model; }
/// <summary> /// Update one record /// </summary> public void Update(Johnny.CMS.OM.SystemInfo.TopMenuBinding model) { dal.Update(model); }
/// <summary> /// Add one record /// </summary> public int Add(Johnny.CMS.OM.SystemInfo.TopMenuBinding model) { return(dal.Add(model)); }