protected void ctlProgramForm_ItemUpdating(object sender, FormViewUpdateEventArgs e) { short programId = Convert.ToInt16(ctlProgramForm.DataKey.Value); TextBox ctlProgramCode = (TextBox)ctlProgramForm.FindControl("ctlProgramCode"); TextBox ctlComment = (TextBox)ctlProgramForm.FindControl("ctlComment"); CheckBox ctlActiveChk = (CheckBox)ctlProgramForm.FindControl("ctlActiveChk"); SuProgram program = SuProgramService.FindByIdentity(programId); program.ProgramCode = ctlProgramCode.Text; program.Comment = ctlComment.Text; program.Active = ctlActiveChk.Checked; program.UpdBy = UserAccount.UserID; program.UpdDate = DateTime.Now; program.UpdPgm = ProgramCode; try { SuProgramService.UpdateProgram(program); ctlProgramGrid.DataCountAndBind(); ctlProgramForm.ChangeMode(FormViewMode.ReadOnly); ClosePopUp(); } catch (ServiceValidationException ex) { ValidationErrors.MergeErrors(ex.ValidationErrors); } }
protected void ctlProgramForm_ItemInserting(object sender, FormViewInsertEventArgs e) { TextBox ctlProgramCode = (TextBox)ctlProgramForm.FindControl("ctlProgramCode"); TextBox ctlComment = (TextBox)ctlProgramForm.FindControl("ctlComment"); CheckBox ctlActiveChk = (CheckBox)ctlProgramForm.FindControl("ctlActiveChk"); SuProgram program = new SuProgram(); program.ProgramCode = ctlProgramCode.Text; program.Comment = ctlComment.Text; program.Active = ctlActiveChk.Checked; program.CreBy = UserAccount.UserID; program.CreDate = DateTime.Now; program.UpdBy = UserAccount.UserID; program.UpdDate = DateTime.Now; program.UpdPgm = ProgramCode; try { SuProgramService.AddProgram(program); ctlProgramGrid.DataCountAndBind(); ctlProgramForm.ChangeMode(FormViewMode.ReadOnly); ClosePopUp(); }catch (ServiceValidationException ex) { ValidationErrors.MergeErrors(ex.ValidationErrors); } }
protected void ctlSubmit_Click(object sender, EventArgs e) { IList <SuProgramLang> programLangList = new List <SuProgramLang>(); SuProgram program = new SuProgram(UIHelper.ParseShort(ctlProgramGrid.SelectedValue.ToString())); foreach (GridViewRow row in ctlProgramLanguageGrid.Rows) { TextBox ctlProgramName = (TextBox)ctlProgramLanguageGrid.Rows[row.RowIndex].FindControl("ctlProgramName"); TextBox ctlComment = (TextBox)ctlProgramLanguageGrid.Rows[row.RowIndex].FindControl("ctlComment"); CheckBox ctlActiveChk = (CheckBox)ctlProgramLanguageGrid.Rows[row.RowIndex].FindControl("ctlActive"); if (!string.IsNullOrEmpty(ctlProgramName.Text) || !string.IsNullOrEmpty(ctlComment.Text)) { SuProgramLang programLang = new SuProgramLang(); DbLanguage Lang = new DbLanguage(UIHelper.ParseShort(ctlProgramLanguageGrid.DataKeys[row.RowIndex].Value.ToString())); programLang.Language = Lang; programLang.Program = program; programLang.ProgramsName = ctlProgramName.Text; programLang.Comment = ctlComment.Text; programLang.Active = ctlActiveChk.Checked; programLang.CreBy = UserAccount.UserID; programLang.CreDate = DateTime.Now; programLang.UpdBy = UserAccount.UserID; programLang.UpdDate = DateTime.Now; programLang.UpdPgm = ProgramCode; programLangList.Add(programLang); } } SuProgramLangService.UpdateProgramLang(programLangList); ctlMessage.Message = GetMessage("SaveSuccessFully"); }
protected void ctlDelete_Click(object sender, ImageClickEventArgs e) { foreach (GridViewRow row in ctlProgramGrid.Rows) { if ((row.RowType == DataControlRowType.DataRow) && (((CheckBox)row.FindControl("ctlSelectChk")).Checked)) { try { short programId = Convert.ToInt16(ctlProgramGrid.DataKeys[row.RowIndex].Value); SuProgram program = SuProgramService.FindByIdentity(programId); SuProgramService.Delete(program); } catch (Exception ex) { if (((System.Data.SqlClient.SqlException)(ex.GetBaseException())).Number == 547) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertInUseData", "alert('This data is now in use.');", true); ctlProgramGrid.DataCountAndBind(); ctlUpdatePanelGridview.Update(); } } } } ProgramLangGridViewFinish(); ctlProgramGrid.DataCountAndBind(); ctlUpdatePanelGridview.Update(); }
protected void ctlSave_Click(object sender, ImageClickEventArgs e) { IList <SuProgramRole> list = new List <SuProgramRole>(); short roleId = UIHelper.ParseShort(ctlRoleGrid.SelectedValue.ToString()); //SuProgramRole translate = new SuProgramRole(roleId); try { foreach (GridViewRow row in ctlProgramRoleGrid.Rows) { CheckBox addState = row.FindControl("ctlAddState") as CheckBox; CheckBox editState = row.FindControl("ctlEditState") as CheckBox; CheckBox deleteState = row.FindControl("ctlDeleteState") as CheckBox; CheckBox displayState = row.FindControl("ctlDisplayState") as CheckBox; TextBox comment = row.FindControl("ctlCommentProgramRole") as TextBox; CheckBox active = row.FindControl("ctlActiveProgramRole") as CheckBox; short programId = UIHelper.ParseShort(ctlProgramRoleGrid.DataKeys[row.RowIndex].Values["ProgramId"].ToString()); SuProgram program = new SuProgram(programId); SuRole role = new SuRole(roleId); SuProgramRole programRole = new SuProgramRole(); programRole.Role = role; programRole.Program = program; programRole.AddState = addState.Checked; programRole.EditState = editState.Checked; programRole.DeleteState = deleteState.Checked; programRole.DisplayState = displayState.Checked; programRole.Comment = comment.Text; programRole.Active = active.Checked; programRole.CreBy = UserAccount.UserID; programRole.CreDate = DateTime.Now.Date; programRole.UpdBy = UserAccount.UserID; programRole.UpdDate = DateTime.Now.Date; programRole.UpdPgm = ProgramCode; list.Add(programRole); } SuProgramRoleService.UpdateProgramRole(list); ctlMessage.Message = GetMessage("SaveSuccessFully"); } catch (ServiceValidationException ex) { ValidationErrors.MergeErrors(ex.ValidationErrors); } }
protected void ctlProgramGrid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "UserEdit") { int rowIndex = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex; short programId = Convert.ToInt16(ctlProgramGrid.DataKeys[rowIndex].Value); ctlProgramForm.PageIndex = (ctlProgramGrid.PageIndex * ctlProgramGrid.PageSize) + rowIndex; ctlProgramForm.ChangeMode(FormViewMode.Edit); IList <SuProgram> programList = new List <SuProgram>(); SuProgram program = SuProgramService.FindByIdentity(programId); programList.Add(program); ctlProgramForm.DataSource = programList; ctlProgramForm.DataBind(); ctlProgramGrid.DataCountAndBind(); UpdatePanelProgramForm.Update(); ctlProgramModalPopupExtender.Show(); } if (e.CommandName == "Select") { int rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex; short programId = UIHelper.ParseShort(ctlProgramGrid.DataKeys[rowIndex].Value.ToString()); ctlProgramLanguageGrid.DataSource = SuProgramLangService.FindByProgramId(programId); ctlProgramLanguageGrid.DataBind(); if (ctlProgramLanguageGrid.Rows.Count > 0) { ctlSubmit.Visible = true; ctlProgramLangFds.Visible = true; ctlCancel.Visible = true; } else { ctlSubmit.Visible = false; ctlProgramLangFds.Visible = false; ctlCancel.Visible = false; } ctlProgramGrid.DataCountAndBind(); ctlProgramLanguageUpdatePanel.Update(); } }
public void UpdateProgramRole(IList <SuProgramRole> programRoleList) { Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors(); foreach (SuProgramRole pr in programRoleList) { SuProgram program = new SuProgram(); program = DaoProvider.SuProgramDao.FindByIdentity(pr.Program.Programid); if (program == null) { errors.AddError("ProgramRolelate.Error", new Spring.Validation.ErrorMessage("RequiredSymbol")); } } foreach (SuProgramRole pr in programRoleList) { DaoProvider.SuProgramRoleDao.DeleteByProgramRoleId(pr.Role.RoleID, pr.Program.Programid); } foreach (SuProgramRole pr in programRoleList) { SuProgramRole programRole = new SuProgramRole(); programRole.Role = DaoProvider.SuRoleDao.FindProxyByIdentity(pr.Role.RoleID); programRole.Program = DaoProvider.SuProgramDao.FindProxyByIdentity(pr.Program.Programid); programRole.AddState = pr.AddState; programRole.EditState = pr.EditState; programRole.DeleteState = pr.DeleteState; programRole.DisplayState = pr.DisplayState; programRole.Comment = pr.Comment; programRole.Active = pr.Active; programRole.CreBy = pr.CreBy; programRole.CreDate = DateTime.Now.Date; programRole.UpdBy = pr.UpdBy; programRole.UpdDate = DateTime.Now.Date; programRole.UpdPgm = pr.UpdPgm; DaoProvider.SuProgramRoleDao.Save(programRole); } }