Пример #1
0
    public static string BuildEmail(FDRPage.Statuses status, string country, string voidAction)
    {
        FDRPage fp        = new FDRPage();
        string  body      = string.Empty;
        var     url       = fp.Url(status);
        var     userList  = ADUser.SearchAdUsersBySid(ADUser.CurrentSID);
        var     user      = userList[0];
        var     appUrl    = ConfigurationManager.AppSettings["fdrUrl"];
        string  strStatus = "";

        using (StreamReader reader = new StreamReader(url))
        {
            body = reader.ReadToEnd();
        }

        if (voidAction == null)
        {
            strStatus = status.ToString();
        }
        else
        {
            strStatus = voidAction;
        }
        body = body.Replace("{country}", country);
        body = body.Replace("{status}", strStatus);
        body = body.Replace("{dateRejected}", DateTime.Now.ToString());
        body = body.Replace("{rejectedBy}", user.FullName);
        body = body.Replace("{url}", appUrl);


        return(body);
    }
    protected void gvCBC_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        FDRPage fp = new FDRPage();

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            string   ActionId          = "";
            string   ReturnStatus      = "";
            Button   btnGenerateSingle = (e.Row.FindControl("btnGenerateSingle") as Button);
            Button   btnVerify         = (e.Row.FindControl("btnVerifyPackage") as Button);
            CheckBox chkSelect         = e.Row.FindControl("chkSelect") as CheckBox;
            Label    lblActionId       = e.Row.FindControl("lblActionId") as Label;
            Label    lblReturnStatus   = e.Row.FindControl("lblReturningStatus") as Label;
            if (lblActionId != null)
            {
                ActionId = lblActionId.Text;
            }
            if (lblReturnStatus != null)
            {
                ReturnStatus = lblReturnStatus.Text;
            }
            if (fp.IsUserInRole("Reviewer") || fp.IsUserInRole("Approver"))
            {
                var strStatus       = Server.HtmlDecode(e.Row.Cells[3].Text);
                var reportingPeriod = Server.HtmlDecode(e.Row.Cells[1].Text);
                btnVerify.Enabled         = true;
                btnGenerateSingle.Enabled = true;
                if (!string.IsNullOrWhiteSpace(strStatus) && strStatus.Trim() !=
                    "Rejected" && strStatus.Trim() != "Generated")
                {
                    btnGenerateSingle.Enabled = false;
                }

                if ((ActionId == "3" && ReturnStatus.ToLower() == "accepted") ||
                    ReturnStatus.ToLower() == "rejected")
                {
                    btnGenerateSingle.Enabled = true;
                }
            }
            else
            {
                btnGenerate.Enabled = false; btnGenerateSingle.Enabled = false;
            }
        }
    }
Пример #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");
            }
        }
    }
Пример #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!IsPostBack)
            {
                fsVerify.Visible = false;
                FDRPage fp = new FDRPage();
                if (fp.IsUserInRole("CBC Administrator"))
                // if (User.CanPerformFunction("CBC_ApproveDataReady"))
                {
                    if (Request["refno"] != null && Request["year"] != null)
                    {
                        var isApproved = DatabaseReader.CheckIfCBCApproved(Request["refno"].ToString(), int.Parse(Request["year"].ToString()));
                        switch (isApproved)
                        {
                        case -1:
                            fsVerify.Visible = true;
                            break;

                        case 0:
                        case 1:
                            fsVerify.Visible = false;
                            break;
                        }
                    }
                }
                if (!Page.IsPostBack)
                {
                    ViewState["prevPage"] = Request.UrlReferrer;
                }
            }
        }
        catch (Exception x)
        {
            throw new Exception(x.Message);
        }
    }