/*On Page Load, This function connects to the database, redirects users to login if they are not connected and displays the account information of the linked Sagicor account*/
        protected void Page_Load(object sender, EventArgs e)
        {
            if (System.Web.HttpContext.Current.User == null || !System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
            {
                Response.Redirect("~/Account/Login.aspx");
                return;
            }
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
            con.Open();

            SqlCommand cmd = con.CreateCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "select * from LinkedSagicorAccounts where CustUserName = '******'";
            SqlDataReader rdr = cmd.ExecuteReader();

            rdr.Read();
            List <string> accountInfo        = client.GetSagicorInfo(rdr["SagicorAccNum"].ToString());
            Label         accountNumber      = new Label();
            Label         accountHolder      = new Label();
            Label         accountEmail       = new Label();
            Label         accountPhonenumber = new Label();
            Label         accountBalance     = new Label();

            accountNumber.Text          = "Sagicor Account Number: " + accountInfo[0];
            accountNumber.CssClass      = "full-label";
            accountHolder.Text          = "Sagicor Account Holder: " + accountInfo[1];
            accountHolder.CssClass      = "full-label";
            accountEmail.Text           = "Sagicor Account Email: " + accountInfo[2];
            accountEmail.CssClass       = "full-label";
            accountPhonenumber.Text     = "Sagicor Account Phone Number: " + accountInfo[3];
            accountPhonenumber.CssClass = "full-label";
            accountBalance.Text         = "Sagicor Current Balance: $" + accountInfo[4];
            accountBalance.CssClass     = "full-label";

            SagicorAccInfoHolder.Controls.Add(accountNumber);
            SagicorAccInfoHolder.Controls.Add(accountHolder);
            SagicorAccInfoHolder.Controls.Add(accountEmail);
            SagicorAccInfoHolder.Controls.Add(accountPhonenumber);
            SagicorAccInfoHolder.Controls.Add(accountBalance);

            rdr.Close();
            cmd.Dispose();
        }
示例#2
0
        /*On Page Load, The page calls this function which connects to the database, checks if the user is logged in and displays wither the account details for linked accounts or the options to link to that account*/
        protected void Page_Load(object sender, EventArgs e)
        {
            if (System.Web.HttpContext.Current.User == null || !System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Must be logged in the Link Accounts');window.location ='/Account/Login.aspx';", true);
                return;
            }
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
            con.Open();

            SqlCommand cmd = con.CreateCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "select * from LinkedFlowAccounts where CustUserName = '******'";
            SqlDataReader rdr = cmd.ExecuteReader();

            if (!rdr.Read())
            {
                rdr.Close();
                Button LinkAcc = new Button();
                LinkAcc.Text     = "Link a Flow Acount";
                LinkAcc.Enabled  = true;
                LinkAcc.CssClass = "btn btn-primary";
                LinkAcc.Click   += this.LoadFlowLinkPage;
                FlowAccInfoHolder.Controls.Add(LinkAcc);
            }
            else
            {
                rdr.Close();
                rdr = cmd.ExecuteReader();
                rdr.Read();
                List <string> accountInfo        = client.GetFlowInfo(rdr["FlowAccNum"].ToString());
                Label         accountNumber      = new Label();
                Label         accountHolder      = new Label();
                Label         accountEmail       = new Label();
                Label         accountPhonenumber = new Label();
                Label         accountBalance     = new Label();
                Button        unLinkAccBtn       = new Button();
                Button        makePaymentBtn     = new Button();

                unLinkAccBtn.Text       = "Unlink";
                unLinkAccBtn.Enabled    = true;
                unLinkAccBtn.Click     += this.UnlinkFlow;
                unLinkAccBtn.CssClass   = "btn btn-primary mr-4";
                makePaymentBtn.Text     = "Make a Payment";
                makePaymentBtn.Enabled  = true;
                makePaymentBtn.Click   += this.PaymentFlow;
                makePaymentBtn.CssClass = "btn btn-primary mr-4";

                accountNumber.Text          = "Flow Account Number: " + accountInfo[0];
                accountNumber.CssClass      = "full-label";
                accountHolder.Text          = "Flow Account Holder: " + accountInfo[1];
                accountHolder.CssClass      = "full-label";
                accountEmail.Text           = "Flow Account Email: " + accountInfo[2];
                accountEmail.CssClass       = "full-label";
                accountPhonenumber.Text     = "Flow Account Phone Number: " + accountInfo[3];
                accountPhonenumber.CssClass = "full-label";
                accountBalance.Text         = "Flow Current Balance: $" + accountInfo[4];
                accountBalance.CssClass     = "full-label";

                FlowAccInfoHolder.Controls.Add(accountNumber);
                FlowAccInfoHolder.Controls.Add(accountHolder);
                FlowAccInfoHolder.Controls.Add(accountEmail);
                FlowAccInfoHolder.Controls.Add(accountPhonenumber);
                FlowAccInfoHolder.Controls.Add(accountBalance);
                FlowAccInfoHolder.Controls.Add(unLinkAccBtn);
                FlowAccInfoHolder.Controls.Add(makePaymentBtn);
            }

            rdr.Close();
            cmd.Dispose();
            con.Close();
            con.Open();
            cmd             = con.CreateCommand();
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "select * from LinkedSagicorAccounts where CustUserName = '******'";
            rdr             = cmd.ExecuteReader();
            if (!rdr.Read())
            {
                rdr.Close();
                Button LinkAcc = new Button();
                LinkAcc.Text     = "Link a Sagicor Acount";
                LinkAcc.Enabled  = true;
                LinkAcc.CssClass = "btn btn-primary";
                LinkAcc.Click   += this.LoadSagicorLinkPage;
                SagicorAccInfoHolder.Controls.Add(LinkAcc);
            }
            else
            {
                rdr.Close();
                rdr = cmd.ExecuteReader();
                rdr.Read();
                List <string> accountInfo        = client2.GetSagicorInfo(rdr["SagicorAccNum"].ToString());
                Label         accountNumber      = new Label();
                Label         accountHolder      = new Label();
                Label         accountEmail       = new Label();
                Label         accountPhonenumber = new Label();
                Label         accountBalance     = new Label();
                Button        unLinkAccBtn       = new Button();
                Button        makePaymentBtn     = new Button();

                unLinkAccBtn.Text       = "Unlink";
                unLinkAccBtn.Enabled    = true;
                unLinkAccBtn.Click     += this.UnlinkSagicor;
                unLinkAccBtn.CssClass   = "btn btn-primary mr-4";
                makePaymentBtn.Text     = "Make a Payment";
                makePaymentBtn.Enabled  = true;
                makePaymentBtn.Click   += this.PaymentSagicor;
                makePaymentBtn.CssClass = "btn btn-primary mr-4";

                accountNumber.Text          = "Sagicor Account Number: " + accountInfo[0];
                accountNumber.CssClass      = "full-label";
                accountHolder.Text          = "Sagicor Account Holder: " + accountInfo[1];
                accountHolder.CssClass      = "full-label";
                accountEmail.Text           = "Sagicor Account Email: " + accountInfo[2];
                accountEmail.CssClass       = "full-label";
                accountPhonenumber.Text     = "Sagicor Account Phone Number: " + accountInfo[3];
                accountPhonenumber.CssClass = "full-label";
                accountBalance.Text         = "Sagicor Current Balance: $" + accountInfo[4];
                accountBalance.CssClass     = "full-label";

                SagicorAccInfoHolder.Controls.Add(accountNumber);
                SagicorAccInfoHolder.Controls.Add(accountHolder);
                SagicorAccInfoHolder.Controls.Add(accountEmail);
                SagicorAccInfoHolder.Controls.Add(accountPhonenumber);
                SagicorAccInfoHolder.Controls.Add(accountBalance);
                SagicorAccInfoHolder.Controls.Add(unLinkAccBtn);
                SagicorAccInfoHolder.Controls.Add(makePaymentBtn);
            }
            rdr.Close();
            cmd.Dispose();
        }