protected void ctlSubmit_Click(object sender, EventArgs e) { IList <SuMenuLang> list = new List <SuMenuLang>(); short menuId = UIHelper.ParseShort(ctlMenuGrid.SelectedValue.ToString()); SuMenu menu = new SuMenu(menuId); foreach (GridViewRow row in ctlMenuLangGrid.Rows) { TextBox ctlMenuName = row.FindControl("ctlMenuName") as TextBox; TextBox ctlCommentMenuLang = row.FindControl("ctlCommentMenuLang") as TextBox; CheckBox ctlActiveMenuLang = row.FindControl("ctlActiveMenuLang") as CheckBox; //if ((!string.IsNullOrEmpty(ctlMenuName.Text)) || (!string.IsNullOrEmpty(ctlCommentMenuLang.Text))) //{ short languageId = UIHelper.ParseShort(ctlMenuLangGrid.DataKeys[row.RowIndex].Values["LanguageId"].ToString()); DbLanguage lang = new DbLanguage(languageId); SuMenuLang menuLang = new SuMenuLang(); menuLang.Menu = menu; menuLang.Language = lang; menuLang.MenuName = ctlMenuName.Text; menuLang.Comment = ctlCommentMenuLang.Text; menuLang.Active = ctlActiveMenuLang.Checked; GetSuMenuLangInfo(menuLang); list.Add(menuLang); //} } SuMenuLangService.UpdateMenuLang(list); ctlMessage.Message = GetMessage("SaveSuccessFully"); //ctlUpdatePanelTranslateLangGridView.Update(); }
protected void ctlDelete_Click(object sender, ImageClickEventArgs e) { foreach (GridViewRow row in ctlMenuGrid.Rows) { if ((row.RowType == DataControlRowType.DataRow) && (((CheckBox)row.FindControl("ctlSelect")).Checked)) { try { short menuId = UIHelper.ParseShort(ctlMenuGrid.DataKeys[row.RowIndex].Value.ToString()); SuMenu menu = SuMenuService.FindByIdentity(menuId); SuMenuLangService.DeleteMenuLang(menuId); SuMenuService.Delete(menu); } catch (Exception ex) { Response.Write("Delete Error"); } } } ctlMenuGrid.SelectedIndex = -1; ctlMenuGrid.DataCountAndBind(); ctlUpdatePanelGridView.Update(); ctlMenuLangGrid.DataSource = null; ctlMenuLangGrid.DataBind(); fdsMenuLang.Visible = false; ctlUpdatePanelMenuLangGridView.Update(); }
protected void ctlMenuForm_DataBound(object sender, EventArgs e) { initDropdownList(); DropDownList ctlProgram = ctlMenuForm.FindControl("ctlProgramID") as DropDownList; if (ctlMenuForm.CurrentMode.Equals(FormViewMode.Edit)) { SuMenu menu = ctlMenuForm.DataItem as SuMenu; if (menu.Program != null) { ctlProgram.SelectedValue = menu.Program.Programid.ToString(); } } DropDownList ctlMainMenuId = ctlMenuForm.FindControl("ctlMainMenuID") as DropDownList; if (ctlMenuForm.CurrentMode.Equals(FormViewMode.Edit)) { SuMenu menu = ctlMenuForm.DataItem as SuMenu; if (!string.IsNullOrEmpty(menu.MenuMainid.ToString())) { ctlMainMenuId.SelectedValue = menu.MenuMainid.ToString(); } } }
protected void Page_Load(object sender, EventArgs e) { SuMenu m = new SuMenu(); //if (!Page.IsPostBack) //{ m.CreBy = UserAccount.UserID; m.CreDate = DateTime.Now.Date; m.UpdBy = UserAccount.UserID; m.UpdDate = DateTime.Now.Date; m.UpdPgm = "TestMasterGrid"; //} ctlMasterGrid1.ObjectQuery = suMenuQuery; ctlMasterGrid1.DTO = m; ctlMasterGrid1.ObjectService = suMenuService; }
protected void ctlMenuForm_Inserting(object sender, FormViewInsertEventArgs e) { SuMenu menu = new SuMenu(); GetSuMenuInfo(menu); try { SuMenuService.AddMenu(menu); ctlMenuGrid.DataCountAndBind(); ClosePopUp(); } catch (ServiceValidationException ex) { ValidationErrors.MergeErrors(ex.ValidationErrors); } }
protected void ctlMenuForm_Updating(object sender, FormViewUpdateEventArgs e) { short menuId = UIHelper.ParseShort(ctlMenuForm.DataKey.Value.ToString()); SuMenu menu = QueryProvider.SuMenuQuery.FindProxyByIdentity(menuId); GetSuMenuInfo(menu); try { SuMenuService.UpdateMenu(menu); ctlMenuGrid.DataCountAndBind(); ClosePopUp(); } catch (ServiceValidationException ex) { ValidationErrors.MergeErrors(ex.ValidationErrors); } }
private void GetSuMenuInfo(SuMenu menu) { //DropDownList program = ctlMenuForm.FindControl("ctlProgramList") as DropDownList; TextBox ctlMenuCode = ctlMenuForm.FindControl("ctlMenuCode") as TextBox; DropDownList ctlProgramID = ctlMenuForm.FindControl("ctlProgramID") as DropDownList; DropDownList ctlMainMenuID = ctlMenuForm.FindControl("ctlMainMenuID") as DropDownList; TextBox ctlMenuSeq = ctlMenuForm.FindControl("ctlMenuSeq") as TextBox; TextBox ctlComment = ctlMenuForm.FindControl("ctlComment") as TextBox; CheckBox ctlActive = ctlMenuForm.FindControl("ctlActive") as CheckBox; if (!string.IsNullOrEmpty(ctlProgramID.SelectedValue)) { short programId = UIHelper.ParseShort(ctlProgramID.SelectedValue); //modify by tom 28/01/2009 //menu.Program = SS.SU.Query.QueryProvider.SuProgramQuery.FindProxyByIdentity(programId); menu.Program = QueryProvider.SuProgramQuery.FindProxyByIdentity(programId); } //else //{ // menu.Programid = 0; //} if (!string.IsNullOrEmpty(ctlMainMenuID.SelectedValue)) { menu.MenuMainid = UIHelper.ParseShort(ctlMainMenuID.SelectedValue); } else { menu.MenuMainid = null; } menu.MenuCode = ctlMenuCode.Text; menu.MenuLevel = QueryProvider.SuMenuQuery.GetMenuLevel(menu.MenuMainid, menu.Menuid); menu.MenuSeq = UIHelper.ParseShort(ctlMenuSeq.Text); menu.Comment = ctlComment.Text; menu.Active = ctlActive.Checked; menu.CreBy = UserAccount.UserID; menu.CreDate = DateTime.Now.Date; menu.UpdBy = UserAccount.UserID; menu.UpdDate = DateTime.Now.Date; menu.UpdPgm = ProgramCode; }