protected void ctlUserGroupLookupPopupCaller_NotifyPopupResult(object sender, string action, string value) { if (action != "ok") { return; } object returnValue = new object(); if (!IsMultiple) { SuRole userGroup = QueryProvider.SuRoleQuery.FindByIdentity(UIHelper.ParseShort(value)); returnValue = userGroup; NotifyPopUpReturn(new PopUpReturnArgs(PopUpReturnType.OK, returnValue)); } else { string[] listID = value.Split('|'); IList <SuRole> userGroupList = new List <SuRole>(); foreach (string id in listID) { SuRole userGroup = QueryProvider.SuRoleQuery.FindByIdentity(UIHelper.ParseShort(id)); if (userGroup != null) { userGroupList.Add(userGroup); } } returnValue = userGroupList; CallOnObjectLookUpReturn(returnValue); } }
public Object RequestData(int startRow, int pageSize, string sortExpression) { SuRole role = new SuRole(); role.RoleID = RoleID; return(QueryProvider.SuProgramRoleQuery.FindProgramInfoByRole(role, UserAccount.UserLanguageID, sortExpression)); }
public SuRole GetUserGroupCriteria() { SuRole userGroup = new SuRole(); userGroup.RoleCode = ctlUserGroupCode.Text; userGroup.RoleName = ctlUserGroupName.Text; return(userGroup); }
public int RequestCount() { SuRole role = new SuRole(); role.RoleCode = ctlTxtGroupCode.Text; role.RoleName = ctlTxtGroupName.Text; int count = QueryProvider.SuRoleQuery.CountByRoleCriteria(role); return(count); }
public Object RequestData(int startRow, int pageSize, string sortExpression) { //role lang for criteria. SuRole role = new SuRole(); role.RoleCode = ctlTxtGroupCode.Text; role.RoleName = ctlTxtGroupName.Text; return(QueryProvider.SuRoleQuery.GetRoleList(role, UserAccount.CurrentLanguageID, startRow, pageSize, sortExpression)); }
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); } }
public IList <ProgramInformation> FindProgramInfoByRole(SuRole role, short languageID, string sortExpression) { StringBuilder sqlBuilder = new StringBuilder(); sqlBuilder.Append("SELECT spr.id AS ProgramRoleID,"); sqlBuilder.Append("sp.programCode AS ProgramCode,"); sqlBuilder.Append("spl.programsName AS ProgramsName "); sqlBuilder.Append("FROM suprogramrole spr,"); sqlBuilder.Append("suprogramlang spl,"); sqlBuilder.Append("suprogram sp "); sqlBuilder.Append("WHERE 1=1 "); sqlBuilder.Append("AND spr.roleid=:roleID "); sqlBuilder.Append("AND spr.programid = sp.programid "); sqlBuilder.Append("AND spl.programid = sp.programid "); sqlBuilder.Append("AND spl.languageid = :languageID "); sqlBuilder.Append("AND spr.active=1 "); if (!string.IsNullOrEmpty(sortExpression)) { sqlBuilder.AppendLine(string.Format(" ORDER BY {0}", sortExpression)); } else { sqlBuilder.Append(" ORDER BY ProgramRoleID,ProgramCode,ProgramsName "); } QueryParameterBuilder paramBuilder = new QueryParameterBuilder(); paramBuilder.AddParameterData("roleID", typeof(short), role.RoleID); paramBuilder.AddParameterData("languageID", typeof(short), languageID); ISQLQuery query = GetCurrentSession().CreateSQLQuery(sqlBuilder.ToString()); paramBuilder.FillParameters(query); query.AddScalar("ProgramRoleID", NHibernateUtil.Int16) .AddScalar("ProgramCode", NHibernateUtil.String) .AddScalar("ProgramsName", NHibernateUtil.String); query.SetResultTransformer(Transformers.AliasToBean(typeof(ProgramInformation))); return(query.List <ProgramInformation>()); }
protected void ctlRoleSearchLookupPopupCaller_NotifyPopupResult(object sender, string action, string value) { if (action != "ok") { return; } object returnValue = new object(); string[] listID = value.Split('|'); IList <SuRole> roleList = new List <SuRole>(); foreach (string id in listID) { SuRole role = SuRoleService.FindByIdentity(UIHelper.ParseShort(id)); if (role != null) { roleList.Add(role); } } returnValue = roleList; CallOnObjectLookUpReturn(returnValue); }
public int RequestCount() { SuRole role = GetUserGroupCriteria(); return(QueryProvider.SuRoleQuery.CountUserGroupByCriteria(role)); }
public Object RequestData(int startRow, int pageSize, string sortExpression) { SuRole role = GetUserGroupCriteria(); return(QueryProvider.SuRoleQuery.GetUserGroupList(role, startRow, pageSize, sortExpression)); }
public int FindCount(SuRole role, short languageID) { return(NHibernateQueryHelper.CountByCriteria(QueryProvider.SuRolePBQuery, "FindRolePBByCriteria", new object[] { role, true, string.Empty, languageID })); }
public IList <PBInformation> FindPBInfoByRole(SuRole role, int firstResult, int maxResult, string sortExpression, short languageID) { return(FindRolePBByCriteria(role, false, sortExpression, languageID).List <PBInformation>()); }
public ISQLQuery FindRolePBByCriteria(SuRole role, bool isCount, string sortExpression, short languageID) { StringBuilder sqlBuilder = new StringBuilder(); QueryParameterBuilder parameterBuilder = new QueryParameterBuilder(); if (!isCount) { //quering sqlBuilder.Append("select rpb.rolepbid as RolePbID,rpb.pbid as PBID,pb.pbcode as PBCode,pbl.description as PBName,c.companyname as Company "); sqlBuilder.Append("from dbpb pb,dbpblang pbl,dbcompany c,surolepb rpb "); sqlBuilder.Append("where 1=1 "); sqlBuilder.Append("and c.companycode = pb.companycode "); sqlBuilder.Append("and rpb.pbid = pb.pbid "); sqlBuilder.Append("and pbl.pbid = pb.pbid "); sqlBuilder.Append("and pbl.languageID = :languageID "); sqlBuilder.Append("and rpb.roleid= :roleID "); sqlBuilder.Append("and rpb.active=1 "); if (string.IsNullOrEmpty(sortExpression)) { sqlBuilder.AppendLine("ORDER BY PBID,PBCode,PBName,Company"); } else { sqlBuilder.AppendLine(string.Format(" ORDER BY {0}", sortExpression)); } } else { //counting sqlBuilder.Append("select count(1) as RolePBCount "); sqlBuilder.Append("from dbpb pb,dbpblang pbl,dbcompany c,surolepb rpb "); sqlBuilder.Append("where 1=1 "); sqlBuilder.Append("and c.companycode = pb.companycode "); sqlBuilder.Append("and rpb.pbid = pb.pbid "); sqlBuilder.Append("and pbl.pbid = pb.pbid "); sqlBuilder.Append("and pbl.languageID = :languageID "); sqlBuilder.Append("and rpb.roleid= :roleID "); } parameterBuilder.AddParameterData("languageID", typeof(string), languageID); parameterBuilder.AddParameterData("roleID", typeof(short), role.RoleID); ISQLQuery query = GetCurrentSession().CreateSQLQuery(sqlBuilder.ToString()); parameterBuilder.FillParameters(query); if (!isCount) { query.AddScalar("RolePbID", NHibernateUtil.Int64); query.AddScalar("PBID", NHibernateUtil.Int64); query.AddScalar("PBCode", NHibernateUtil.String); query.AddScalar("PBName", NHibernateUtil.String); query.AddScalar("Company", NHibernateUtil.String); query.SetResultTransformer(Transformers.AliasToBean(typeof(PBInformation))); } else { query.AddScalar("RolePBCount", NHibernateUtil.Int32); query.UniqueResult(); } return(query); }
protected void ctlGridRole_RowCommand(object sender, GridViewCommandEventArgs e) { InvisibleAllPopUpcontrol(); int rowIndex = 0; if (e.CommandName == "RoleDelete") { try { rowIndex = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex; short roleID = short.Parse(ctlGridRole.DataKeys[rowIndex].Value.ToString()); SuRole role = SuRoleService.FindByIdentity(roleID); SuRoleService.DeleteRole(role); } catch (ServiceValidationException ex) { ValidationErrors.MergeErrors(ex.ValidationErrors); } 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); } } ctlGridRole.DataCountAndBind(); } if (e.CommandName == "RoleEdit") { //find role id for current setup. rowIndex = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex; short roleID = short.Parse(ctlGridRole.DataKeys[rowIndex].Value.ToString()); CtlUserRoleEditor1.Initialize(FlagEnum.EditFlag, roleID); CtlUserRoleEditor1.ShowPopUp(); } if (e.CommandName == "PB") { //find role id for current setup. rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex; short roleID = short.Parse(ctlGridRole.DataKeys[rowIndex].Value.ToString()); ctlPBInfo1.Initialize(roleID); ctlPBInfo1.Show(); } if (e.CommandName == "Service") { //find role id for current setup. rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex; short roleID = short.Parse(ctlGridRole.DataKeys[rowIndex].Value.ToString()); ctlServiceTeamInfo1.Initialize(roleID); ctlServiceTeamInfo1.Show(); } if (e.CommandName == "Program") { //find role id for current setup. rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex; short roleID = short.Parse(ctlGridRole.DataKeys[rowIndex].Value.ToString()); ctlProgramInfo1.Initialize(roleID); ctlProgramInfo1.Show(); } ctlGridRole.SelectedIndex = rowIndex; ctlUpdPanelGridView.Update(); // แก้ไขการกด link ในกริด ที่จะเป็น Editor มาในหน้าเดียวกัน ไม่ต้องทำการ CountAndBind จะทำให้ไม่เกิด Event ในการกด Link ครั้งต่อไป //ctlGridRole.DataCountAndBind(); //try //{ // int selectIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex; // //ctlGridRole.Rows[selectIndex].BackColor = Color.WhiteSmoke; //} //catch (Exception) //{ //} }
public void Initialize(string mode, short roleID) { Mode = mode.ToString(); RoleID = roleID; if (mode.ToString() == FlagEnum.EditFlag) { role = SuRoleService.FindByIdentity(roleID); ctlTextBoxGroupName.Text = role.RoleName; ctlTextBoxGroupCode.Text = role.RoleCode; ctlCheckboxActive.Checked = role.Active; ctlCheckboxRecieveDoc.Checked = role.ReceiveDocument; ctlCheckboxVerifyDoc.Checked = role.VerifyDocument; ctlCheckboxApproveVerifyDoc.Checked = role.ApproveVerifyDocument; ctlCheckBoxApproveVerifyPayment.Checked = role.ApproveVerifyPayment; if (role.VerifyMinLimit == 0) { ctlTextBoxVerifyMin.Text = string.Empty; } else { ctlTextBoxVerifyMin.Text = role.VerifyMinLimit.ToString(); } if (role.VerifyMaxLimit == int.MaxValue) { ctlTextBoxVerifyMax.Text = string.Empty; } else { ctlTextBoxVerifyMax.Text = role.VerifyMaxLimit.ToString(); } if (role.ApproveVerifyMinLimit == 0) { ctlTextBoxApproveVerifyMin.Text = string.Empty; } else { ctlTextBoxApproveVerifyMin.Text = role.ApproveVerifyMinLimit.ToString(); } if (role.ApproveVerifyMaxLimit == int.MaxValue) { ctlTextBoxApproveVerifyMax.Text = string.Empty; } else { ctlTextBoxApproveVerifyMax.Text = role.ApproveVerifyMaxLimit.ToString(); } ctlCheckboxAllowMultipleApproveAccountant.Checked = role.AllowMultipleApproveAccountant; ctlCheckBoxAllowMultipleApprovePayment.Checked = role.AllowMultipleApprovePayment; ctlCheckBoxVerifyPayment.Checked = role.VerifyPayment; if (ctlCheckBoxAllowMultipleApprovePayment.Checked) { ctlCheckBoxApproveVerifyPayment.Checked = true; ctlCheckBoxApproveVerifyPayment.Enabled = false; } if (ctlCheckboxAllowMultipleApproveAccountant.Checked) { ctlCheckboxApproveVerifyDoc.Checked = true; ctlCheckboxApproveVerifyDoc.Enabled = false; } ctlCheckBoxCounterCashier.Checked = role.CounterCashier; ctlUseCustomizationLimitAmount.Checked = role.UseCustomizationLimitAmount; ctlLimitAmountForVerifierChange.Text = UIHelper.BindDecimal(role.LimitAmountForVerifierChange.ToString()); if (!ctlUseCustomizationLimitAmount.Checked) { ctlLimitAmountForVerifierChange.Text = string.Empty; ctlSpecialUseCustomizationLimitAmount.Visible = false; } else { ctlSpecialUseCustomizationLimitAmount.Visible = true; } ctlPanelUserRole.Update(); } }
protected void ctlButtonSave_Click(object sender, EventArgs e) { #region create DTO for save Role role = new SuRole(); //role = SuRoleService.FindByIdentity(RoleID); role.Active = ctlCheckboxActive.Checked; role.UpdBy = UserAccount.UserID; role.UpdPgm = base.ProgramCode; if (Mode == FlagEnum.EditFlag) { role.CreBy = UserAccount.UserID; } role.RoleCode = ctlTextBoxGroupCode.Text; role.RoleName = ctlTextBoxGroupName.Text; role.ApproveVerifyDocument = ctlCheckboxApproveVerifyDoc.Checked; role.ReceiveDocument = ctlCheckboxRecieveDoc.Checked; role.VerifyDocument = ctlCheckboxVerifyDoc.Checked; role.ApproveVerifyDocument = ctlCheckboxApproveVerifyDoc.Checked; role.VerifyPayment = ctlCheckBoxVerifyPayment.Checked; role.ApproveVerifyPayment = ctlCheckBoxApproveVerifyPayment.Checked; role.CounterCashier = ctlCheckBoxCounterCashier.Checked; role.AllowMultipleApproveAccountant = ctlCheckboxAllowMultipleApproveAccountant.Checked; role.AllowMultipleApprovePayment = ctlCheckBoxAllowMultipleApprovePayment.Checked; role.UseCustomizationLimitAmount = ctlUseCustomizationLimitAmount.Checked; role.LimitAmountForVerifierChange = UIHelper.ParseDouble(ctlLimitAmountForVerifierChange.Text); try { if (!string.IsNullOrEmpty(ctlTextBoxVerifyMax.Text)) { role.VerifyMaxLimit = UIHelper.ParseDouble(ctlTextBoxVerifyMax.Text); } else { role.VerifyMaxLimit = int.MaxValue; } if (!string.IsNullOrEmpty(ctlTextBoxVerifyMin.Text)) { role.VerifyMinLimit = UIHelper.ParseDouble(ctlTextBoxVerifyMin.Text); } else { role.VerifyMinLimit = 0; } if (!string.IsNullOrEmpty(ctlTextBoxApproveVerifyMax.Text)) { role.ApproveVerifyMaxLimit = UIHelper.ParseDouble(ctlTextBoxApproveVerifyMax.Text); } else { role.ApproveVerifyMaxLimit = int.MaxValue; } if (!string.IsNullOrEmpty(ctlTextBoxApproveVerifyMin.Text)) { role.ApproveVerifyMinLimit = UIHelper.ParseDouble(ctlTextBoxApproveVerifyMin.Text); } else { role.ApproveVerifyMinLimit = 0; } } catch (FormatException) { Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors(); errors.AddError("Role.Error", new ErrorMessage("Limit-field area be accept numeric only.")); ValidationErrors.MergeErrors(errors); return; } #endregion try { if (Mode == FlagEnum.NewFlag) { SuRoleService.AddRole(role); } else if (Mode == FlagEnum.EditFlag) { role.RoleID = RoleID; SuRoleService.UpdateRole(role); } //Auto computer will refresh workflow permission here. Notify_Ok(sender, e); HidePopUp(); } catch (ServiceValidationException ex) { ValidationErrors.MergeErrors(ex.ValidationErrors); } }