Example #1
0
        public static OutGoingCBCDeclarations OutGoingCBCDeclarationsDetails(string countryCode, string reportingPeriod)
        {
            var result = new OutGoingCBCDeclarations("[dbo].[uspREAD_OutGoingCBCDeclarationsDetails]", new Dictionary <string, object> {
                { "@CountryCode", countryCode }, { "@ReportingPeriod", reportingPeriod }
            });

            return(result.GetRecord <OutGoingCBCDeclarations>());
        }
    protected void btnGenerate_Click(object sender, EventArgs e)
    {
        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", null);
        var         countryCode = gvRow.Cells[0].Text.Split('-')[1].Trim();
        var         country     = gvRow.Cells[0].Text.Split('-')[0].Trim();
        var         year        = int.Parse(gvRow.Cells[1].Text);

        if (ValidateRequiredFields(year))
        {
            decimal id      = 0;
            var     package = Common.GenerateNewPackage(countryCode, dpReportingPeriod.Text, ref messageSpec, id);
            if (!string.IsNullOrEmpty(package.ToString()))
            {
                var outgoingCBC = new OutGoingCBCDeclarations()
                {
                    Id              = id,
                    Country         = countryCode,
                    CBCData         = package.ToString(),
                    NSCBCData       = null,
                    StatusId        = 2,
                    Year            = year,
                    ReportingPeriod = DateTime.Parse(dpReportingPeriod.Text),
                    CreatedBy       = Sars.Systems.Security.ADUser.CurrentSID
                };

                id = DatabaseWriter.SaveOutgoingCBC(outgoingCBC, ref newUID);
                if (id > 0)
                {
                    var newPackage     = Common.GenerateNewPackage(countryCode, dpReportingPeriod.Text, ref messageSpec, id);
                    var newMessageSpec = messageSpec;
                    var nmPackage      = Common.GenerateNMPackage(countryCode, dpReportingPeriod.Text, newMessageSpec);
                    var newPackagedCBC = new OutGoingCBCDeclarations()
                    {
                        Id        = id,
                        Country   = countryCode,
                        CBCData   = newPackage.ToString(),
                        NSCBCData = nmPackage,
                        StatusId  = 2,
                        Year      = year,
                        CreatedBy = Sars.Systems.Security.ADUser.CurrentSID
                    };
                    var saved = DatabaseWriter.SaveOutgoingCBC(newPackagedCBC, ref newUID);
                }

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

                LoadCBC();
                MessageBox.Show(string.Format("Package for {0} was successfully generated", country));
            }
        }
    }
Example #3
0
        public static OutGoingCBCDeclarations IncomingCBCDeclaration(int statusId, string countryCode, string ReportingPeriod)
        {
            var oParams = new Dictionary <string, object>
            {
                { "@CountryCode", countryCode },
                { "@ReportingPeriod", ReportingPeriod },
                { "@StatusId", statusId }
            };
            var result = new OutGoingCBCDeclarations("[dbo].[uspREAD_IncomingForeignDeclaration]", oParams);

            return(result.GetRecord <OutGoingCBCDeclarations>());
        }
Example #4
0
 private bool SameApprover(OutGoingCBCDeclarations outCBC)
 {
     if (fp.IsUserInRole("Approver"))
     {
         if (outCBC.UpdatedBy == ADUser.CurrentSID)
         {
             return(true);
         }
         return(false);
     }
     return(false);
 }
Example #5
0
        public static OutGoingCBCDeclarations OutGoingCBCDeclarationsDetails(string countryCode, int year)
        {
            var oParams = new DBParamCollection
            {
                { "@CountryCode", countryCode },
                { "@Year", year }
            };
            var result = new OutGoingCBCDeclarations("[dbo].[uspREAD_OutGoingCBCDeclarationsDetails]", new Dictionary <string, object> {
                { "@CountryCode", countryCode }, { "@Year", year }
            });

            return(result.GetRecord <OutGoingCBCDeclarations>());
        }
Example #6
0
 private void SavePackage(StringBuilder package, decimal id, string countryCode, int year)
 {
     Guid newUid      = new Guid();
     var  outgoingCBC = new OutGoingCBCDeclarations()
     {
         Id        = id,
         Country   = countryCode,
         NSCBCData = package.ToString(),
         StatusId  = 3,
         Year      = year,
         CreatedBy = Sars.Systems.Security.ADUser.CurrentSID
     };
     decimal saved = DatabaseWriter.SaveOutgoingCBC(outgoingCBC, ref newUid);
 }
Example #7
0
    public static OutGoingCBCDeclarations GetOutgoingCBCR(string newPackage, string countryCode, int year,
                                                          DateTime reportingPeriod, string userId, string nmPackage = null, decimal id = 0)
    {
        var newPackagedCBC = new OutGoingCBCDeclarations()
        {
            Id              = id,
            Country         = countryCode,
            CBCData         = newPackage.ToString(),
            NSCBCData       = nmPackage,
            StatusId        = 2,
            Year            = year,
            ActionId        = 1,
            ReportingPeriod = reportingPeriod,
            CreatedBy       = Sars.Systems.Security.ADUser.CurrentSID
        };

        return(newPackagedCBC);
    }
Example #8
0
    public static OutGoingCBCDeclarations OutGoingCBCDeclarationsDetails(string countryCode, string reportingPeriod)
    {
        var oParams = new DBParamCollection
        {
            { "@CountryCode", countryCode },
            { "@ReportingPeriod", reportingPeriod }
        };
        var result = new OutGoingCBCDeclarations("[dbo].[uspREAD_OutGoingCBCDeclarationsDetails]", new Dictionary <string, object> {
            { "@CountryCode", countryCode }, { "@ReportingPeriod", reportingPeriod }
        });

        if (result.Id > 0)
        {
            return(result.GetRecord <OutGoingCBCDeclarations>());
        }
        else
        {
            return(null);
        }
    }
Example #9
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 #10
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 #11
0
    public static decimal SaveOutgoingCBC(OutGoingCBCDeclarations cbcDeclarations, ref Guid newUid)
    {
        var oParams = new DBParamCollection
        {
            { "@Id", cbcDeclarations.Id },
            { "@Country", cbcDeclarations.Country },
            { "@StatusId", cbcDeclarations.StatusId },
            { "@CBCData", cbcDeclarations.CBCData },
            { "@CreatedBy", cbcDeclarations.CreatedBy },
            { "@CBCWithNaspace", cbcDeclarations.NSCBCData },
            { "@ActionId", cbcDeclarations.ActionId },
            { "@Year", cbcDeclarations.Year },
            { "@ReportingPeriod", cbcDeclarations.ReportingPeriod },
            { "@NewIdentity", null, ParameterDirection.Output },
            { "@UID", null, ParameterDirection.Output }
        };

        using (var command = new DBCommand("[dbo].[uspUPSERT_OutGoingCBCDeclarations]", QueryType.StoredProcedure, oParams))
        {
            Hashtable oHashTable;
            var       scopeIdentity = 0L;
            command.Execute(out oHashTable);

            if (oHashTable.Count > 0)
            {
                if (!string.IsNullOrEmpty(oHashTable["@NewIdentity"].ToString()))
                {
                    scopeIdentity = long.Parse(oHashTable["@NewIdentity"].ToString());
                }
                if (!string.IsNullOrEmpty(oHashTable["@UID"].ToString()))
                {
                    newUid = Guid.Parse(oHashTable["@UID"].ToString());
                }
            }
            return(scopeIdentity);
            //return command.Execute();
        }
    }