private bool SameApprover(Sars.Models.CBC.OutGoingCBCDeclarations outCBC) { if (fp.IsUserInRole("Approver")) { if (outCBC.UpdatedBy == ADUser.CurrentSID) { return(true); } return(false); } return(false); }
protected void Page_Load(object sender, EventArgs e) { var updatePanelControlIdThatCausedPostBack = String.Empty; var scriptManager = System.Web.UI.ScriptManager.GetCurrent(Page); Sars.Models.CBC.OutGoingCBCDeclarations outCBC = null; var countryCode = ""; var reportingPeriod = ""; int statusId = string.IsNullOrEmpty(Request.QueryString["StatusId"]) ? 0 : int.Parse(Request.QueryString["StatusId"].ToString()); if (Request.QueryString["xCountry"] != null & Request.QueryString["Period"] != null && (fp.IsUserInRole("Reviewer") || fp.IsUserInRole("Approver"))) { countryCode = Request.QueryString["xCountry"].ToString(); reportingPeriod = Request.QueryString["Period"].ToString(); outCBC = DBReadManager.OutGoingCBCDeclarationsDetails(countryCode, reportingPeriod); } if (!IsPostBack) { ViewState["prevPage"] = Request.UrlReferrer; lblHeader.Text = "VIEW"; countryCode = Request.QueryString["xCountry"].ToString(); reportingPeriod = Request.QueryString["Period"].ToString(); btnReject.Visible = false; btnApprove.Visible = false; //btnSendToReviewer.Visible = false; if (outCBC != null) { if (fp.IsUserInRole("Reviewer")) { btnApprove.Text = "Verify"; switch (outCBC.StatusId) { case 2: lblHeader.Text = "VERIFY"; break; case 7: lblHeader.Text = "VERIFY CORRECTED"; break; case 8: lblHeader.Text = "VERIFY VOIDED"; break; default: lblHeader.Text = "VIEW"; break; } } else if (fp.IsUserInRole("Approver")) { btnApprove.Text = "Approve"; lblHeader.Text = (outCBC.StatusId == 3) ? "APPROVE" : "VIEW"; } } else { btnDownloadXcel.Visible = false; btnDownload.Visible = false; } LoadCBC(countryCode, reportingPeriod, statusId); LoadCBCHsitory(countryCode, reportingPeriod); } else { if (scriptManager != null) { var smUniqueId = scriptManager.UniqueID; var smFieldValue = Request.Form[smUniqueId]; if (!String.IsNullOrEmpty(smFieldValue) && smFieldValue.Contains("|")) { updatePanelControlIdThatCausedPostBack = smFieldValue.Split('|')[1]; if (updatePanelControlIdThatCausedPostBack == "ctl00$MainContent$btnDownloadXcel" || updatePanelControlIdThatCausedPostBack == "ctl00$MainContent$btnDownload") { outCBC = DBReadManager.OutGoingCBCDeclarationsDetails(countryCode, reportingPeriod); if (fp.IsUserInRole("Approver")) { if (outCBC.StatusId == 3) { btnApprove.Visible = true; btnReject.Visible = true; if (SameApprover(outCBC)) { btnReject.Visible = false; btnApprove.Visible = false; } } } if (fp.IsUserInRole("Reviewer")) { if (outCBC.StatusId == 2 || outCBC.StatusId == 7 || outCBC.StatusId == 8) { btnApprove.Visible = true; } } } } } } }