Ejemplo n.º 1
0
        public void storeUserPayment(object sender, EventArgs e)
        {
            if (billPayEntry == null)
            {
                billPayEntry = new List <BillPayEntry>();
            }

            billPay = new BillPayEntry();
            billPay.PaymentTransactionDate   = datepicker.Text;
            billPay.RecipientBusinessName    = businessname.Text;
            billPay.RecipientBusinessAddress = businessaddress.Text;
            billPay.AmountPaid     = amount.Text;
            billPay.PaymentDetails = describePayment.Text;
            billPay.Status         = 0;
            billPayEntry.Add(billPay);


            // send email
            String msgTo      = "*****@*****.**";
            String msgSubject = "We have received your message!";
            String msgBody    = "Dear User " + email + "\n" +
                                "You have scheduled a transaction in Rapid Bill Pay on" + datepicker.Text +
                                "You can check the status of the transaction by visiting" + " http://dcm.uhcl.edu/c432017fa01karigondanahallm/Assignment6/userLogin.aspx" + "\n" +
                                "Thank you for using BillPay" + "\n" +

                                "With best wishes\n" + "\n" +
                                "Billpay Team";
            MailMessage mailObj = new MailMessage();

            mailObj.Body = msgBody;
            mailObj.From = new MailAddress("*****@*****.**", "KC");
            mailObj.To.Add(new MailAddress(msgTo));
            mailObj.Subject    = msgSubject;
            mailObj.IsBodyHtml = true;
            SmtpClient SMTPClient = new System.Net.Mail.SmtpClient();

            // SMTPClient.Host = "smtp.gmail.com";
            //SMTPClient.Port = 587;
            SMTPClient.Credentials = new NetworkCredential("*****@*****.**", "13@m15o51h14AN");
            SMTPClient.EnableSsl   = true;
            try { SMTPClient.Send(mailObj); }
            catch (Exception) { }
        }
    protected void ok(object sender, EventArgs e)
    {
        UserInfo     temp     = (UserInfo)Session["currentUser"];
        BillPayEntry bpstatus = new BillPayEntry();

        if (temp.MyBillPayments == null)
        {
        }
        else
        {
            // foreach (BillPayEntry i in temp.MyBillPayments)
            //{
            //  i.Status = 1;
            //}

            MySql.Data.MySqlClient.MySqlConnection co;
            string connection = System.Configuration.ConfigurationManager.ConnectionStrings["MySqlConnectionString"].ToString();
            co = new MySql.Data.MySqlClient.MySqlConnection(connection);
            co.Open();
            try
            {
                string query = $"UPDATE `c432017fa01tirunagarus`.`tirunagarus_WADfl17_RapidBillPay` SET `status` = 1 WHERE `emailAddress` = '{temp.EmailAddress}'; ";
                MySql.Data.MySqlClient.MySqlCommand command = new MySql.Data.MySqlClient.MySqlCommand(query, co);

                int rows = command.ExecuteNonQuery();
                co.Close();
            }

            catch (Exception ex)
            {
                Console.WriteLine("session abandon: " + ex.Message);
            }
        }
        Session.Abandon(); //abandons the current session user. no need of argument
        //  Session.Remove("currentUser");
        Response.Redirect("~/default.aspx");
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["currentUser"] == null)
        {
            //  Response.Redirect("default.aspx");
        }
        else
        {
            UserInfo populate = (UserInfo)Session["currentuser"];
            string   emailid  = populate.EmailAddress;
            MySql.Data.MySqlClient.MySqlConnection co;
            string connection = System.Configuration.ConfigurationManager.ConnectionStrings["MySqlConnectionString"].ToString();
            try
            {
                using (co = new MySql.Data.MySqlClient.MySqlConnection(connection))
                {
                    co.Open();
                    MySql.Data.MySqlClient.MySqlCommand command = new MySql.Data.MySqlClient.MySqlCommand
                                                                      ("select * from tirunagarus_WADfl17_RapidBillPay where EmailAddress='" + emailid + "'", co);


                    MySql.Data.MySqlClient.MySqlDataReader sqlReader = command.ExecuteReader();

                    if (sqlReader.HasRows == true)
                    {
                        while (sqlReader.Read())
                        {
                            //   StudentInfor astudInfor = new StudentInfor();
                            BillPayEntry bill = new BillPayEntry();
                            bill.Emailaddress             = ((string)sqlReader["emailAddress"]);
                            bill.PaymentTransactionDate   = ((string)sqlReader["paymentTransactionDate"]);
                            bill.RecipientBusinessName    = ((string)sqlReader["recipientBusinessName"]);
                            bill.RecipientBusinessAddress = ((string)sqlReader["recipientBusinessAddress"]);
                            bill.AmountPaid     = ((string)sqlReader["amountPaid"]);
                            bill.PaymentDetails = ((string)sqlReader["paymentDetails"]);
                            bill.Status         = ((int)sqlReader["status"]);


                            string stat = "In Progress";
                            if (bill.Status == 1)
                            {
                                stat = "Completed";
                            }

                            TableRow row = new TableRow
                            {
                                Cells =
                                {
                                    new TableCell {
                                        Text = bill.PaymentTransactionDate
                                    },
                                    new TableCell {
                                        Text = bill.RecipientBusinessName
                                    },
                                    new TableCell {
                                        Text = bill.RecipientBusinessAddress
                                    },
                                    new TableCell {
                                        Text = bill.AmountPaid
                                    },
                                    new TableCell {
                                        Text = stat
                                    },
                                }
                            };
                            // studentTable.Rows.Add(row);
                            transaction_details.Rows.AddAt(2, row);
                        } //while sql reader()
                    }     //HasRows

                    else
                    {
                        TableRow  tRow  = new TableRow();
                        TableCell tCell = new TableCell();
                        tCell.Text = "No records found";
                        tRow.Cells.Add(tCell);
                        transaction_details.Rows.AddAt(2, tRow);
                    }
                } //sql connection
            }     //try
            catch { }
        }     // else main
    }
    protected void scheduleTransaction(object sender, EventArgs e)
    {
        BillPayEntry bp = new BillPayEntry();

        bp.PaymentTransactionDate   = date_text_box.Text;
        bp.RecipientBusinessName    = bussiness_name.Text;
        bp.RecipientBusinessAddress = address_bussiness.Text;
        bp.AmountPaid     = payment_amount.Text;
        bp.PaymentDetails = amount_description.Text;
        bp.Status         = 0;
        UserInfo temp = (UserInfo)Session["currentUser"];

        bp.Emailaddress = temp.EmailAddress;
        if (temp.MyBillPayments == null)
        {
            List <BillPayEntry> newpay = new List <BillPayEntry>();
            newpay.Add(bp);
            temp.MyBillPayments = newpay;
        }
        else
        {
            temp.MyBillPayments.Add(bp);
        }
        string stat = "null";

        if (bp.Status == 0)
        {
            stat = "In Progress";
        }
        TableRow row = new TableRow
        {
            Cells =
            {
                new TableCell {
                    Text = bp.PaymentTransactionDate
                },
                new TableCell {
                    Text = bp.RecipientBusinessName
                },
                new TableCell {
                    Text = bp.RecipientBusinessAddress
                },
                new TableCell {
                    Text = bp.AmountPaid
                },
                new TableCell {
                    Text = stat
                }
            }
        };

        transaction_details.Rows.AddAt(2, row);


        string msgTo      = bp.Emailaddress;
        string msgSubject = "New Transaction Scheduling Notification";
        string msgBody    = "Dear User " + msgTo + ",<br /><br />" +
                            "You have scheduled a transaction in Rapid Bill Pay on" + bp.PaymentTransactionDate + " <br/> <br />" +
                            "You can check the status of the transaction by visiting <a href='http://dcm.uhcl.edu/c432017fa01tirunagarus/transactionDetails.aspx'> Compose a trasaction</a> " +
                            "<br /><br />" +
                            "Thank you again for using <a href='http://dcm.uhcl.edu/c432017fa01tirunagarus/'>Rapid Bill Pay</a> " +
                            "<br /><br />" +
                            "With Best Wishes, <br />" +
                            "Sumanjali Tirunagaru";

        MailMessage mailObj = new MailMessage();

        mailObj.Body = msgBody;
        mailObj.From = new MailAddress("*****@*****.**", "Admin Team");
        mailObj.To.Add(new MailAddress(msgTo));
        mailObj.Subject    = msgSubject;
        mailObj.IsBodyHtml = true;

        SmtpClient smtpClient = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587);

        smtpClient.UseDefaultCredentials = false;
        smtpClient.Credentials           = new System.Net.NetworkCredential("*****@*****.**", "!hahahaha");
        smtpClient.EnableSsl             = true;

        try
        {
            smtpClient.Send(mailObj);
        }

        catch (Exception ex)
        {
        }


        //db updating

        MySql.Data.MySqlClient.MySqlConnection co;
        string connection = System.Configuration.ConfigurationManager.ConnectionStrings["MySqlConnectionString"].ToString();

        co = new MySql.Data.MySqlClient.MySqlConnection(connection);
        co.Open();

        string query = "INSERT INTO `c432017fa01tirunagarus`.`tirunagarus_WADfl17_RapidBillPay`(`emailAddress`, `paymentTransactionDate`, `recipientBusinessName`, `recipientBusinessAddress`, `amountPaid`, `paymentDetails`, `status`) VALUES ('" + bp.Emailaddress + "','" + bp.PaymentTransactionDate + "','" + bp.RecipientBusinessName + "','" + bp.RecipientBusinessAddress + "','" + bp.AmountPaid + "','" + bp.PaymentDetails + "'," + bp.Status + ") ";


        MySql.Data.MySqlClient.MySqlCommand command = new MySql.Data.MySqlClient.MySqlCommand(query, co);

        command.ExecuteNonQuery();
        co.Close();


        Response.Redirect("~/transactionDetails.aspx");
    }
Ejemplo n.º 5
0
        protected void BtnSchedule_Click(object sender, EventArgs e)
        {
            sendMail(sender, e);

            int          ind   = 0;
            BillPayEntry entry = new BillPayEntry();

            entry.PaymentTransactionDate   = PaymentDateField.Text;
            entry.RecipientBusinessAddress = BusinessAddressField.Text;
            entry.RecipientBusinessName    = BusinessNameField.Text;
            entry.AmountPaid     = AmountField.Text;
            entry.PaymentDetails = PaymentDetailsField.Text;

            UserInfo temp = (UserInfo)Session["currentuser"];

            entry.EmailAddress = temp.EmailAddress;

            if (temp.MybillPayments == null)
            {
                List <BillPayEntry> newBill = new List <BillPayEntry>();
                newBill.Add(entry);
                temp.MybillPayments = newBill;
            }

            else
            {
                temp.MybillPayments.Add(entry);
            }

            // Response.Redirect("payment.aspx");
            ///gridview
            DataTable dt = new DataTable();

            dt.Columns.Add("Transaction Date");
            dt.Columns.Add("Recipient Name");
            dt.Columns.Add("Recipient Address");
            dt.Columns.Add("Amount");
            dt.Columns.Add("Status");
            DataRow dr = null;

            if (ViewState["transactions"] != null)
            {
                for (int i = 0; i < 1; i++)
                {
                    dt = (DataTable)ViewState["transactions"];
                    if (dt.Rows.Count > 0)
                    {
                        dr = dt.NewRow();
                        dr["Transaction Date"]  = PaymentDateField.Text;
                        dr["Recipient Name"]    = BusinessNameField.Text;
                        dr["Recipient Address"] = BusinessAddressField.Text;
                        dr["Amount"]            = AmountField.Text;
                        dr["Status"]            = "In progress";
                        dt.Rows.InsertAt(dr, 0);
                        GridView1.DataSource = dt;
                        GridView1.DataBind();
                        updateDatabase(sender, e);

                        PaymentDateField.Text     = "";
                        BusinessNameField.Text    = "";
                        BusinessAddressField.Text = "";
                        AmountField.Text          = "";
                        PaymentDetailsField.Text  = "";
                    }
                }
            }
            else
            {
                dr = dt.NewRow();
                dr["Transaction Date"]  = PaymentDateField.Text;
                dr["Recipient Name"]    = BusinessNameField.Text;
                dr["Recipient Address"] = BusinessAddressField.Text;
                dr["Amount"]            = AmountField.Text;
                dr["Status"]            = "In progress";
                dt.Rows.Add(dr);
                GridView1.DataSource = dt;
                GridView1.DataBind();
                updateDatabase(sender, e);

                PaymentDateField.Text     = "";
                BusinessNameField.Text    = "";
                BusinessAddressField.Text = "";
                AmountField.Text          = "";
                PaymentDetailsField.Text  = "";
            }
            ViewState["transactions"] = dt;
            updateDatabase(sender, e);

            PaymentDateField.Text     = "";
            BusinessNameField.Text    = "";
            BusinessAddressField.Text = "";
            AmountField.Text          = "";
            PaymentDetailsField.Text  = "";
            ///gridview
        }