private void SetDesignationAuthority(DesignationAuthority objParentAuthority) { var obj = new DesignationAuthority() { eAuthority = objParentAuthority.eAuthority, DesignationId = objParentAuthority.DesignationId }; var lstDesignationAuthority = obj.SelectList <DesignationAuthority>(); obj.IsAllowView = objParentAuthority.IsAllowView; obj.IsAllowAddEdit = objParentAuthority.IsAllowAddEdit; obj.IsAllowDelete = objParentAuthority.IsAllowDelete; if (lstDesignationAuthority.Count > 0) { obj.DesignationAuthorityId = lstDesignationAuthority[0].DesignationAuthorityId; obj.Update(); } else { obj.Insert(); } }
private void SaveAuthority(bool ChangeUserAuthority) { if (IsDesignation()) { dtAuthority = new DesignationAuthority() { DesignationId = lblDesignationId.zToInt(), }.Select(); } var dtUser = new DataTable(); if (ChangeUserAuthority || IsUser()) { if (IsUser()) { dtAuthority = new UserAuthority() { UsersId = lblUsersId.zToInt() }.Select(); } dtUser = new Query() { UsersId = IsUser() ? lblUsersId.zToInt() : (int?)null, DesignationId = IsUser() ? (int?)null : lblDesignationId.zToInt(), eStatusNot = (int)eStatus.Delete, }.Select(eSP.qry_User); } foreach (RepeaterItem item in rptAuthority.Items) { var lblAuthorityId = item.FindControl("lblAuthorityId") as Label; var chkView = item.FindControl("chkView") as CheckBox; var chkAddEdit = item.FindControl("chkAddEdit") as CheckBox; var chkDelete = item.FindControl("chkDelete") as CheckBox; if (!lblAuthorityId.zIsNullOrEmpty() && lblAuthorityId.zToInt() != 0) { if (dtAuthority.Select(CS.eAuthority + " = " + lblAuthorityId.zToInt() + " AND " + CS.IsAllowView + " = " + chkView.Checked + " AND " + CS.IsAllowAddEdit + " = " + chkAddEdit.Checked + " AND " + CS.IsAllowDelete + " = " + chkDelete.Checked).Length == 0) { if (IsDesignation()) { #region Designation Authority var objAuthority = new DesignationAuthority() { eAuthority = lblAuthorityId.zToInt(), DesignationId = lblDesignationId.zToInt(), IsAllowView = chkView.Checked, IsAllowAddEdit = chkAddEdit.Checked, IsAllowDelete = chkDelete.Checked, }; SetDesignationAuthority(objAuthority); #endregion } if (ChangeUserAuthority || IsUser()) { var objUserAuthority = new UserAuthority() { eAuthority = lblAuthorityId.zToInt(), IsAllowView = chkView.Checked, IsAllowAddEdit = chkAddEdit.Checked, IsAllowDelete = chkDelete.Checked, }; SetUserAuthority(dtUser, objUserAuthority); } } } } CU.ZMessage(eMsgType.Success, string.Empty, "Authority Updated Successfully."); }