Пример #1
0
    protected void cashout_Click(object sender, EventArgs e)
    {
        if (Session["CashoutAmount"] == null)
        {
            Response.Write("<script>alert('Please select Reward Amount you want to get')</script>");
        }
        else
        {
            SqlConnection sc = new SqlConnection();
            sc.ConnectionString = ConfigurationManager.ConnectionStrings["GroupProjectConnectionString"].ConnectionString;
            sc.Open();
            SqlCommand insert = new SqlCommand();
            insert.Connection = sc;

            insert.CommandText = "SELECT [TotalAmount] FROM [MoneyTransaction] where MoneyTransactionID=(select max(MoneyTransactionID) from MoneyTransaction)";
            SqlDataReader reader = insert.ExecuteReader();

            if (reader.HasRows)
            {
                reader.Read();
                int totalPoints       = Convert.ToInt32(reader["TotalAmount"]);
                int transactionAmount = Convert.ToInt32(rblcashout.SelectedValue);
                reader.Close();
                if (totalPoints >= transactionAmount && (Convert.ToInt32(Session["PointsBalance"]) > transactionAmount))
                {
                    MoneyTransaction newTransaction = new MoneyTransaction(totalPoints, DateTime.Today.ToShortDateString(), transactionAmount, DateTime.Today.ToShortDateString(), Session["loggedIn"].ToString(), Convert.ToInt32(Session["ID"]));
                    insert.CommandText = "INSERT INTO [dbo].[MoneyTransaction] ([Date],[TotalAmount],[TransactionAmount],[LastUpdated],[LastUpdatedBy],[PersonID])" +
                                         "VALUES (@Date,@TotalAmount,@TransactionAmount,@LastUpdated,@LastUpdatedBy,@PersonID)";
                    insert.Parameters.AddWithValue("@TotalAmount", totalPoints - transactionAmount);
                    insert.Parameters.AddWithValue("@Date", newTransaction.getDate());
                    insert.Parameters.AddWithValue("@TransactionAmount", newTransaction.getTransactionAmount());
                    insert.Parameters.AddWithValue("@LastUpdated", newTransaction.getLUD());
                    insert.Parameters.AddWithValue("@LastUpdatedBy", newTransaction.getLUDB());
                    insert.Parameters.AddWithValue("@PersonID", newTransaction.getPersonID());
                    insert.ExecuteNonQuery();
                    sc.Close();
                    Response.Write("<script>alert('Transaction Submited')</script>");
                    Send_Mail(Session["E-mail"].ToString(), newTransaction.getTransactionAmount());
                    rewardpool();
                }
                else
                {
                    Response.Write("<script>alert('personal points not enough or Bank balance low')</script>");
                }
            }
        }
    }
Пример #2
0
    protected void btnCommit_Click(object sender, EventArgs e)
    {
        SqlConnection sc = new SqlConnection();

        sc.ConnectionString = ConfigurationManager.ConnectionStrings["GroupProjectConnectionString"].ConnectionString;
        sc.Open();
        SqlCommand insert = new SqlCommand();

        insert.Connection = sc;

        insert.CommandText = "SELECT [TotalAmount] FROM [MoneyTransaction] where MoneyTransactionID=(select max(MoneyTransactionID) from MoneyTransaction)";
        SqlDataReader reader = insert.ExecuteReader();

        if (reader.HasRows)
        {
            reader.Read();
            int totalPoints       = Convert.ToInt32(reader["TotalAmount"]);
            int transactionAmount = Convert.ToInt32(txtFrontLoad.Text);
            reader.Close();

            MoneyTransaction newTransaction = new MoneyTransaction(totalPoints, DateTime.Today.ToShortDateString(), transactionAmount, DateTime.Today.ToShortDateString(), Session["loggedIn"].ToString(), Convert.ToInt32(Session["ID"]));
            insert.CommandText = "INSERT INTO [dbo].[MoneyTransaction] ([Date],[TotalAmount],[TransactionAmount],[LastUpdated],[LastUpdatedBy],[PersonID])" +
                                 "VALUES (@Date,@TotalAmount,@TransactionAmount,@LastUpdated,@LastUpdatedBy,@PersonID)";
            insert.Parameters.AddWithValue("@TotalAmount", totalPoints + transactionAmount);
            insert.Parameters.AddWithValue("@Date", newTransaction.getDate());
            insert.Parameters.AddWithValue("@TransactionAmount", transactionAmount);
            insert.Parameters.AddWithValue("@LastUpdated", newTransaction.getLUD());
            insert.Parameters.AddWithValue("@LastUpdatedBy", newTransaction.getLUDB());
            insert.Parameters.AddWithValue("@PersonID", newTransaction.getPersonID());
            insert.ExecuteNonQuery();

            //insert.CommandText = "Update person set [PointsBalance]=[PointsBalance]+@TransactionAmount where personid=PersonID";
            //insert.ExecuteNonQuery();
            sc.Close();
            rewardpool();
        }
    }
        protected void cashout_Click(object sender, EventArgs e)
        {
            if (Session["CashoutAmount"] == null)
            {
                Response.Write("<script>alert('Please select Reward Amount you want to get')</script>");
            }
            else
            {
                SqlConnection sc = new SqlConnection();
                sc.ConnectionString = ConfigurationManager.ConnectionStrings["GroupProjectConnectionString"].ConnectionString;
                sc.Open();
                SqlCommand insert = new SqlCommand();
                insert.Connection = sc;

                insert.CommandText = "SELECT [TotalAmount] FROM [MoneyTransaction] where MoneyTransactionID=(select max(MoneyTransactionID) from MoneyTransaction)";
                SqlDataReader reader = insert.ExecuteReader();

                if (reader.HasRows)
                {
                    reader.Read();
                    int totalPoints = Convert.ToInt32(reader["TotalAmount"]);
                    reader.Close();
                    int        sessionID = (int)(Session["ID"]);
                    SqlCommand trans     = new SqlCommand("select value from giftcard where giftcardID = @giftcardID");
                    trans.Parameters.AddWithValue("@giftcardID", rblcashout.SelectedValue);
                    trans.Connection = sc;
                    SqlDataReader transReader = trans.ExecuteReader();
                    transReader.Read();
                    Session["transAmount"] = Convert.ToInt32(transReader["value"]);
                    int transactionAmount = (int)(Session["transAmount"]);
                    transReader.Close();
                    if (totalPoints >= transactionAmount && (Convert.ToInt32(Session["PointsBalance"]) > transactionAmount))
                    {
                        MoneyTransaction newTransaction = new MoneyTransaction(totalPoints, DateTime.Today.ToShortDateString(), transactionAmount, DateTime.Today.ToShortDateString(), Session["loggedIn"].ToString(), Convert.ToInt32(Session["ID"]));
                        insert.CommandText = "INSERT INTO [dbo].[MoneyTransaction] ([Date],[TotalAmount],[TransactionAmount],[LastUpdated],[LastUpdatedBy],[PersonID])" +
                                             "VALUES (@Date,@TotalAmount,@TransactionAmount,@LastUpdated,@LastUpdatedBy,@PersonID)";
                        insert.Parameters.AddWithValue("@TotalAmount", totalPoints - transactionAmount);
                        insert.Parameters.AddWithValue("@Date", newTransaction.getDate());
                        insert.Parameters.AddWithValue("@TransactionAmount", newTransaction.getTransactionAmount());
                        insert.Parameters.AddWithValue("@LastUpdated", newTransaction.getLUD());
                        insert.Parameters.AddWithValue("@LastUpdatedBy", newTransaction.getLUDB());
                        insert.Parameters.AddWithValue("@PersonID", newTransaction.getPersonID());
                        insert.ExecuteNonQuery();
                        //amount to pay billyjacks son, this is
                        Session["payProvider"]      = newTransaction.getTransactionAmount();
                        Session["providerToPaypal"] = "*****@*****.**";//sql statement to grab email of the provider of giftcard based on provider name of card - from/in table provider
                        //
                        string payp       = Session["PointsBalance"].ToString();
                        var    apiContext = Configuration.GetAPIContext();

                        // ### Initialize `Payout` Object
                        // Initialize a new `Payout` object with details of the batch payout to be created.
                        var payout = new Payout
                        {
                            // #### sender_batch_header
                            // Describes how the payments defined in the `items` array are to be handled.
                            sender_batch_header = new PayoutSenderBatchHeader
                            {
                                sender_batch_id = "batch_" + System.Guid.NewGuid().ToString().Substring(0, 8),
                                email_subject   = "You have a payment"
                            },
                            // #### items
                            // The `items` array contains the list of payout items to be included in this payout.
                            // If `syncMode` is set to `true` when calling `Payout.Create()`, then the `items` array must only
                            // contain **one** item.  If `syncMode` is set to `false` when calling `Payout.Create()`, then the `items`
                            // array can contain more than one item.
                            items = new List <PayoutItem>
                            {
                                new PayoutItem
                                {
                                    recipient_type = PayoutRecipientType.EMAIL,
                                    amount         = new Currency
                                    {
                                        value    = payp,//paypalAmount.ToString(),
                                        currency = "USD"
                                    },
                                    receiver       = "*****@*****.**",//Session["providerToPaypal"].ToString(),
                                    note           = "Thank you.",
                                    sender_item_id = "item_1"
                                }//,
                                 //new PayoutItem
                                 //{
                                 //    recipient_type = PayoutRecipientType.EMAIL,
                                 //    amount = new Currency
                                 //    {
                                 //        value = "0.90",
                                 //        currency = "USD"
                                 //    },
                                 //    receiver = "*****@*****.**",
                                 //    note = "Thank you.",
                                 //    sender_item_id = "item_2"
                                 //},
                                 //new PayoutItem
                                 //{
                                 //    recipient_type = PayoutRecipientType.EMAIL,
                                 //    amount = new Currency
                                 //    {
                                 //        value = "2.00",
                                 //        currency = "USD"
                                 //    },
                                 //    receiver = "*****@*****.**",
                                 //    note = "Thank you.",
                                 //    sender_item_id = "item_3"
                                 //}
                            }
                        };

                        // ^ Ignore workflow code segment
                        //#region Track Workflow
                        //this.flow.AddNewRequest("Create payout", payout);
                        //#endregion

                        // ### Payout.Create()
                        // Creates the batch payout resource.
                        // `syncMode = false` indicates that this call will be performed **asynchronously**,
                        // and will return a `payout_batch_id` that can be used to check the status of the payouts in the batch.
                        // `syncMode = true` indicates that this call will be performed **synchronously** and will return once the payout has been processed.
                        // > **NOTE**: The `items` array can only have **one** item if `syncMode` is set to `true`.
                        var createdPayout = payout.Create(apiContext, false);
                        //RunSample();

                        //employee receipt
                        SqlCommand insertgcr = new SqlCommand();
                        insertgcr.Connection  = sc;
                        insertgcr.CommandText = "INSERT INTO [dbo].[GiftCardReceipt]([GiftCardID],[PersonID],[PurchaseDate],[LastUpdated],[LastUpdatedBy],[ConfirmationNumber]) VALUES ( @GiftCardID, @PersonID, @PurchaseDate, @LastUpdated, @LastUpdatedBy, @ConfirmationNumber)";


                        string giftcardID   = rblcashout.SelectedValue;
                        Random rnd          = new Random();
                        int    confirmation = rnd.Next(5, 100);


                        insertgcr.Parameters.AddWithValue("@GiftCardReceiptID", 1);
                        insertgcr.Parameters.AddWithValue("@GiftCardID", giftcardID);
                        insertgcr.Parameters.AddWithValue("@PersonID", Session["ID"]);
                        insertgcr.Parameters.AddWithValue("@PurchaseDate", DateTime.Now);
                        insertgcr.Parameters.AddWithValue("@LastUpdated", DateTime.Now);
                        insertgcr.Parameters.AddWithValue("@LastUpdatedby", Session["loggedIn"].ToString());
                        insertgcr.Parameters.AddWithValue("@ConfirmationNumber", confirmation);

                        insertgcr.ExecuteNonQuery();



                        Response.Redirect("EmployeeReciept.aspx");
                        SqlCommand getItBoy = new SqlCommand();

                        //employee receipt end
                        sc.Close();
                        Response.Write("<script>alert('Transaction Submited')</script>");

                        rewardpool();
                    }
                    else
                    {
                        Response.Write("<script>alert('personal points not enough or Bank balance low')</script>");
                    }
                    SampleItem newPayout = new SampleItem {
                        Title = "Create a payout", ExecutePage = "PayoutCreate.aspx", HasSourcePage = true
                    };
                }
            }
        }