Example #1
0
    protected void btnDownloadXcel_Click(object sender, EventArgs e)
    {
        if (Request.QueryString["xCountry"] != null & Request.QueryString["Period"] != null)
        {
            var countryCode     = Request.QueryString["xCountry"].ToString();
            var reportingPeriod = Request.QueryString["Period"].ToString();
            var outCBC          = DBReadManager.OutGoingCBCDeclarationsDetails(countryCode, reportingPeriod);
            int statusId        = string.IsNullOrEmpty(Request.QueryString["StatusId"]) ? 0 : int.Parse(Request.QueryString["StatusId"].ToString());
            if (fp.IsUserInRole("Reviewer") && statusId == 2)
            {
                btnApprove.Visible = true;
            }

            if (fp.IsUserInRole("Approver") && statusId == 3)
            {
                btnApprove.Visible = true;
                btnReject.Visible  = true;
            }
            if (outCBC.UID != null)
            {
                string fullURL = "window.open('../queueMonitors/MANUAL/CbCReport.aspx?UID=" + outCBC.UID + "&src=OUT ', '_blank', 'status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,titlebar=no' );";
                //string fullURL = "window.open('CbCReport.aspx?UID=" + outCBC.UID + "&src=OUT ', '_blank', 'status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,titlebar=no' );";
                System.Web.UI.ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", fullURL, true);
                // Response.Redirect(string.Format("~/queueMonitors/MANUAL/CbCReport.aspx?UID={0}&src=OUT", outCBC.UID));
            }
        }
    }
Example #2
0
    protected void btnVoid_Click(object sender, EventArgs e)
    {
        Guid        newUid  = new Guid();
        Button      btnVoid = (Button)sender;
        GridViewRow gvRow   = (GridViewRow)btnVoid.Parent.Parent;
        var         email   = ADUser.CurrentUser.Mail;

        string[] senderEmail = { email };
        var      countryCode = gvRow.Cells[0].Text.Split('-')[1].Trim();
        var      reportingPeriod = gvRow.Cells[1].Text; var outCBC = DBReadManager.OutGoingCBCDeclarationsDetails(countryCode, reportingPeriod);
        var      id = string.IsNullOrEmpty(outCBC.Id.ToString()) ? 0 : outCBC.Id;
        var      reportP = DateTime.Parse(reportingPeriod).ToString("yyyy-MM-ddTHH:mm:ss");
        Guid     uid     = new Guid();

        if (outCBC != null)
        {
            var prepareVoidPackage = PrepareNMVoidPackage(id, countryCode, outCBC.NMCBC, reportingPeriod);
            var nmPackage          = prepareVoidPackage;
            uid = outCBC.UID;
            var voidedCBC = new OutGoingCBCDeclarations()
            {
                Id              = id,
                Country         = countryCode,
                CBCData         = prepareVoidPackage,
                StatusId        = 8,
                Year            = int.Parse(reportingPeriod.Substring(0, 4)),
                UID             = uid,
                ActionId        = 3,
                NSCBCData       = nmPackage,
                ReportingPeriod = DateTime.Parse(reportP),
                CreatedBy       = Sars.Systems.Security.ADUser.CurrentSID
            };
            decimal saved = DatabaseWriter.SaveOutgoingCBC(voidedCBC, ref uid);
            DBWriteManager.ApproveOutgoingPackage(id, countryCode, reportingPeriod, 8, ADUser.CurrentSID);
            DBWriteManager.Insert_OutgoingPackageAuditTrail(outCBC.UID, Sars.Systems.Security.ADUser.CurrentSID, string.Format("Outgoing Package for {0} Pending Void Review", gvRow.Cells[0].Text.Split('-')[0].Trim()));
            var Subject = "Outgoing Package pending void review ";
            Common.SendEmailToRole("Reviewer", outCBC.CountryName, Subject, FDRPage.Statuses.Voided, senderEmail);
            MessageBox.Show("Package pending void review");
            LoadCBC();
        }
    }
Example #3
0
    protected void btnCorrect_Click(object sender, EventArgs e)
    {
        if (Request.QueryString["ccode"] != null && Request.QueryString["period"] != null)
        {
            FDRPage  fPage           = new FDRPage();
            Guid     newUid          = new Guid();
            var      country         = Request.QueryString["ccode"].ToString();
            var      reportingPeriod = Request.QueryString["period"].ToString();
            var      outCBC          = DBReadManager.OutGoingCBCDeclarationsDetails(country, reportingPeriod);
            decimal  id          = string.IsNullOrEmpty(outCBC.Id.ToString()) ? 0 : outCBC.Id;
            var      package     = Common.GenerateCorrectionPackage(country, reportingPeriod);
            var      email       = ADUser.CurrentUser.Mail;
            string[] senderEmail = { email };
            if (!string.IsNullOrEmpty(package.ToString()))
            {
                var outgoingCBC = new OutGoingCBCDeclarations()
                {
                    Id        = id,
                    Country   = country,
                    CBCData   = package.ToString(),
                    StatusId  = 7,
                    Year      = int.Parse(reportingPeriod.Substring(0, 4)),
                    CreatedBy = Sars.Systems.Security.ADUser.CurrentSID
                };
                decimal saved = DatabaseWriter.SaveOutgoingCBC(outgoingCBC, ref newUid);
                DBWriteManager.ApproveOutgoingPackage(id, country, reportingPeriod, 7, ADUser.CurrentSID);
                DBWriteManager.Insert_OutgoingPackageAuditTrail(outCBC.UID, Sars.Systems.Security.ADUser.CurrentSID, string.Format("Outgoing Package for {0} corrected", gvCBC.Rows[0].Cells[0].Text.Split('-')[0].Trim()));

                var Subject = "Outgoing CBC Report has been corrected ";
                Common.SendEmailToRole("Reviewer", outCBC.CountryName, Subject, FDRPage.Statuses.Corrected, senderEmail);
                LoadCBC(country, reportingPeriod);
                MessageBox.Show("Package has been corrected successfully");
            }
            else
            {
                MessageBox.Show("No package was corrected");
            }
        }
    }
Example #4
0
    protected void btnAddComments_Click(object sender, EventArgs e)
    {
        var hiddenValue = Parent.FindControl("hdnDone") as HiddenField;
        var mpeMe       = Parent.FindControl("ModalPopupExtender1") as AjaxControlToolkit.ModalPopupExtender;

        hiddenValue.Value = txtComments.Text;
        var gvCBC = Parent.FindControl("gvCBC") as GridView;

        if (!string.IsNullOrEmpty(txtComments.Text))
        {
            var      email       = ADUser.CurrentUser.Mail;
            string[] senderEmail = { email };
            string   Subject     = "";
            if (Request.QueryString["idx"] == null)
            {
                return;
            }

            if (Request.QueryString["idx"] == "0")
            {
                var countryCode = Request.QueryString["xCountry"].ToString();

                if (gvCBC != null)
                {
                    string ReportingPeriod = gvCBC.Rows[0].Cells[4].Text;
                    var    outCBC          = DBReadManager.OutGoingCBCDeclarationsDetails(countryCode, ReportingPeriod);
                    var    comments        = new Comments()
                    {
                        OutGoingCBCDeclarationsID = outCBC.Id,
                        Notes   = txtComments.Text,
                        AddedBy = ADUser.CurrentSID
                    };
                    if (SaveComments(comments, 2) > 0)
                    {
                        DBWriteManager.ApproveOutgoingPackage(outCBC.Id, countryCode, ReportingPeriod, 4, ADUser.CurrentSID);
                        Subject = "Outgoing CBC Package has been rejected";
                        FDR.DataLayer.DBWriteManager.Insert_OutgoingPackageAuditTrail(outCBC.UID, Sars.Systems.Security.ADUser.CurrentSID, string.Format("Outgoing Package for {0} has been rejected", outCBC.CountryName));
                        Common.SendEmailToRole("Reviewer", outCBC.CountryName, Subject, FDRPage.Statuses.Rejected, senderEmail);
                        MessageBox.Show(string.Format("Outgoing Package for {0} has been successfully rejected", outCBC.CountryName));
                    }
                }
            }
            else
            {
                if (Request.QueryString["idx"] != null)
                {
                    string  ReportingPeriod = gvCBC.Rows[0].Cells[6].Text;
                    decimal msgSpecId       = decimal.Parse(Request.QueryString["idx"].ToString());
                    var     comments        = new Comments()
                    {
                        OutGoingCBCDeclarationsID = msgSpecId,
                        Notes   = txtComments.Text,
                        AddedBy = ADUser.CurrentSID
                    };
                    if (SaveComments(comments, 1) > 0)
                    {
                        DBWriteManager.ApproveForeignPackage(4, msgSpecId, ADUser.CurrentSID);
                        var mspec = DBReadManager.GetMessageSpecById(msgSpecId);
                        DBWriteManager.Insert_OutgoingPackageAuditTrail(mspec.UID, Sars.Systems.Security.ADUser.CurrentSID, string.Format("Incoming Package for {0} from {1} rejected",
                                                                                                                                          gvCBC.Rows[0].Cells[4].Text.Split('-')[0].Trim(), gvCBC.Rows[0].Cells[3].Text.Split('-')[0].Trim()));
                        Subject = string.Format("Incoming Package for {0} has been rejected", gvCBC.Rows[0].Cells[4].Text.Split('-')[0].Trim());
                        Common.SendEmailToRole("Reviewer", gvCBC.Rows[0].Cells[4].Text.Split('-')[0].Trim(), Subject, FDRPage.Statuses.Approved, senderEmail);
                        MessageBox.Show(string.Format("Incoming Foreign Package for {0} has been rejected successfully", gvCBC.Rows[0].Cells[3].Text.Split('-')[0]));
                    }
                }
            }
            txtComments.Text = "";
            var btnApprove = Parent.FindControl("btnApprove") as Button;
            var btnReject  = Parent.FindControl("btnReject") as Button;
            btnReject.Enabled  = false;
            btnApprove.Enabled = false;
        }

        else
        {
            MessageBox.Show("Please Enter comments");
            if (mpeMe != null)
            {
                mpeMe.Show();
            }
        }
    }
    protected void btnGenerateSingle_Click(object sender, EventArgs e)
    {
        System.Threading.Thread.Sleep(1000);
        try
        {
            Button      btnGenerate = (Button)sender;
            GridViewRow gvRow       = (GridViewRow)btnGenerate.Parent.Parent;
            Guid        newUID      = new Guid();
            var         xmldoc      = new XmlDocument();
            XmlNode     messageSpec = xmldoc.CreateNode(XmlNodeType.Element, "MessageSpec", xmldoc.NamespaceURI);
            var         countryCode = gvRow.Cells[0].Text.Split('-')[1].Trim();
            var         country     = gvRow.Cells[0].Text.Split('-')[0].Trim();
            var         period      = ddlReportingPeriod.SelectedIndex == 0? gvRow.Cells[1].Text: ddlReportingPeriod.SelectedValue;
            var         year        = int.Parse(gvRow.Cells[2].Text);
            if (ValidateRequiredFields(period))
            {
                decimal id         = 0;
                var     outgoinCBC = DBReadManager.OutGoingCBCDeclarationsDetails(countryCode, period);
                if (outgoinCBC != null)
                {
                    id = outgoinCBC.Id;
                    var newPackage     = Common.GenerateNewPackage(countryCode, period, ref messageSpec, id);
                    var newMessageSpec = messageSpec;
                    var nmPackage      = newPackage;
                    var newPackagedCBC = Utils.GetOutgoingCBCR(newPackage, countryCode, year,
                                                               DateTime.Parse(period), Sars.Systems.Security.ADUser.CurrentSID,
                                                               nmPackage, id);
                    var saved = DatabaseWriter.SaveOutgoingCBC(newPackagedCBC, ref newUID);
                    if (saved > 0)
                    {
                        DBWriteManager.Insert_OutgoingPackageAuditTrail(newUID, Sars.Systems.Security.ADUser.CurrentSID, string.Format("Outgoing Package for {0} generated", country));
                    }
                    else
                    {
                        DBWriteManager.Insert_OutgoingPackageAuditTrail(outgoinCBC.UID, Sars.Systems.Security.ADUser.CurrentSID, string.Format("Outgoing Package for {0} generated", country));
                    }
                    LoadCBC();
                    MessageBox.Show(string.Format("Package for {0} was successfully generated", country));
                    return;
                }

                var package = Common.GenerateNewPackage(countryCode, period, ref messageSpec, id);
                if (!string.IsNullOrEmpty(package.ToString()))
                {
                    var outgoingCBC = Utils.GetOutgoingCBCR(package.ToString(), countryCode, year,
                                                            DateTime.Parse(period), Sars.Systems.Security.ADUser.CurrentSID,
                                                            null, id);
                    id = DatabaseWriter.SaveOutgoingCBC(outgoingCBC, ref newUID);
                    if (id > 0)
                    {
                        var newPackage     = Common.GenerateNewPackage(countryCode, period, ref messageSpec, id);
                        var newMessageSpec = messageSpec;
                        var nmPackage      = newPackage;
                        var newPackagedCBC = Utils.GetOutgoingCBCR(newPackage, countryCode, year,
                                                                   DateTime.Parse(period), Sars.Systems.Security.ADUser.CurrentSID,
                                                                   nmPackage, id);
                        var saved = DatabaseWriter.SaveOutgoingCBC(newPackagedCBC, ref newUID);
                    }

                    DBWriteManager.Insert_OutgoingPackageAuditTrail(newUID, Sars.Systems.Security.ADUser.CurrentSID, string.Format("Outgoing Package for {0} generated", country));

                    LoadCBC();
                    MessageBox.Show(string.Format("Outgoing Package for {0} was successfully generated", country));
                }
                else
                {
                    MessageBox.Show("No package was generated");
                }
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }
Example #6
0
    protected void btnApprove_Click(object sender, EventArgs e)
    {
        System.Threading.Thread.Sleep(1000);
        var countryCode = Request.QueryString["xCountry"].ToString();
        var period      = Request.QueryString["Period"].ToString();

        if (string.IsNullOrEmpty(countryCode) && string.IsNullOrEmpty(period))
        {
            return;
        }
        if (fp.IsUserInRole("Reviewer") || fp.IsUserInRole("Approver"))
        {
            try
            {
                string reportingPeriod = period;
                var    outCBC          = DBReadManager.OutGoingCBCDeclarationsDetails(countryCode, reportingPeriod);
                int    statusId        = fp.IsUserInRole("Reviewer") ? 3 : 5;

                string Subject = "";
                var    email   = string.IsNullOrEmpty(ADUser.CurrentUser.Mail) ? "*****@*****.**" : ADUser.CurrentUser.Mail;
                // DBWriteManager.ApproveOutgoingPackage(outCBC.Id, countryCode, reportingPeriod, statusId, ADUser.CurrentSID);
                string[] senderEmail = { email };
                if (fp.IsUserInRole("Reviewer"))
                {
                    try
                    {
                        DBWriteManager.Insert_OutgoingPackageAuditTrail(outCBC.UID, Sars.Systems.Security.ADUser.CurrentSID, string.Format("Outgoing Package for {0} verified", outCBC.CountryName));
                        Subject = string.Format("Outgoing Package for {0} has been verified ", outCBC.CountryName);
                        Common.SendEmailToRole("Approver", outCBC.CountryName, Subject, FDRPage.Statuses.Verified, senderEmail);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else
                {
                    try
                    {
                        DBWriteManager.Insert_OutgoingPackageAuditTrail(outCBC.UID, Sars.Systems.Security.ADUser.CurrentSID, string.Format("Outgoing Package for {0} approved", outCBC.CountryName));
                        Subject = string.Format("Outgoing Package for {0} has been approved", outCBC.CountryName);
                        Common.SendEmailToRole("Reviewer", outCBC.CountryName, Subject, FDRPage.Statuses.Approved, senderEmail);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                LoadCBCHsitory(countryCode, reportingPeriod);
                MessageBox.Show(Subject + " successfully");
                if (fp.IsUserInRole("Reviewer"))
                {
                    if (statusId > 2)
                    {
                        btnApprove.Enabled = false;
                    }
                }
                else
                {
                    if (statusId > 3)
                    {
                        btnApprove.Enabled = false;
                        btnReject.Enabled  = true;
                    }
                }
                btnApprove.Enabled = false;
                btnReject.Enabled  = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
Example #7
0
    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;
                            }
                        }
                    }
                }
            }
        }
    }