Ejemplo n.º 1
0
        protected void btnCommit_Click(object sender, EventArgs e)
        {
            if (Session["ReceiverID"] == null || Session["ValueID"] == null || Session["CategoryID"] == null || Session["RewardAmount"] == null)
            {
                Response.Write("<script>alert('Please select Receiver Name,Value and Category')</script>");
                popReward.Show();
            }
            else if (Session["ValueID"].ToString() == "-1" || Session["CategoryID"].ToString() == "-1")
            {
                Response.Write("<script>alert('Please select Receiver Name,Value and Category')</script>");
                popReward.Show();
            }
            else
            {
                double pointsAmount     = Convert.ToDouble(rblRewardPoints.SelectedValue);
                string EventDate        = "2/17/2018"; // add textbox to enter
                string EventDescription = txtRDescription.Text;
                string LastUpdated      = DateTime.Now.ToShortDateString();
                string LastUpdatedBy    = Session["loggedIn"].ToString();
                int    ReceiverID       = Convert.ToInt32(Session["ReceiverID"]);
                int    RewarderID       = Convert.ToInt32(Session["ID"]);
                int    CategoryID       = Convert.ToInt32(ddlRCategory.SelectedValue);
                int    ValueID          = Convert.ToInt32(ddlRValue.SelectedValue);

                //try
                //{
                //Connect to Database
                SqlConnection sc = new SqlConnection();
                sc.ConnectionString = ConfigurationManager.ConnectionStrings["GroupProjectConnectionString"].ConnectionString;
                sc.Open();
                PeerTranscation emp = new PeerTranscation(pointsAmount, EventDate, EventDescription, LastUpdated, LastUpdatedBy, ReceiverID, RewarderID, CategoryID, ValueID);

                string sqlString = "INSERT INTO [dbo].[PeerTransaction]([PointsAmount],[Date],[EventDescription],[LastUpdated],[LastUpdatedBy],[ReceiverID],[RewarderID],[CategoryID],[ValueID]) VALUES (@PointsAmount,@Date,@EventDescription,@LastUpdated,@LastUpdatedBy,@ReceiverID,@RewarderID,@CategoryID,@ValueID)";

                SqlCommand insert = new SqlCommand(sqlString);
                insert.Connection = sc;

                insert.Parameters.AddWithValue("@PointsAmount", emp.getPoints());
                insert.Parameters.AddWithValue("@Date", emp.getDate());
                insert.Parameters.AddWithValue("@EventDescription", emp.getDescription());
                insert.Parameters.AddWithValue("@LastUpdated", emp.getLUD());
                insert.Parameters.AddWithValue("@LastUpdatedBy", emp.getLUDB());
                insert.Parameters.AddWithValue("@ReceiverID", emp.getReceiverID());
                insert.Parameters.AddWithValue("@RewarderID", emp.getRewarderID());
                insert.Parameters.AddWithValue("@CategoryID", emp.getCategoryID());
                insert.Parameters.AddWithValue("@ValueID", emp.getValueID());
                //set up paypal variables

                string     getEmBoy    = "SELECT 'e-mail' from person where personID = @receiverID";
                SqlCommand getReceiver = new SqlCommand(getEmBoy);
                getReceiver.Connection = sc;
                getReceiver.Parameters.AddWithValue("@ReceiverID", emp.getReceiverID());
                Session["whoToPaypal"]    = getReceiver.ExecuteNonQuery().ToString();
                Session["amountToPaypal"] = emp.getPoints();

                //new payout based on the reward given baby
                //KYLEEEEEEEEEEEEEEEEEEE

                SampleItem newPayout = new SampleItem {
                    Title = "Create a payout", ExecutePage = "PayoutCreate.aspx", HasSourcePage = true
                };

                //RunSample(); //this is the line that executes paypal

                //string whatIsThis = newPayout;
                //
                //
                //
                //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 = "0.99",//PeerTransaction.getTransaction().getAmount().toString();,
                //            currency = "USD"
                //        },
                //        receiver = "*****@*****.**",
                //        note = "Thank you.",
                //        sender_item_id = "item_1"
                //    }
                //}
                //};
                ////string token = payout.GetTokenFromApprovalUrl();
                ////payout.Create(Configuration.GetAPIContext(), true);


                //
                //
                //
                //

                insert.ExecuteNonQuery();
                sc.Close();
                //}


                //catch
                //{
                //    lblOutput.Text = "Fail add to database";
                //}
                LatestUpdates();
                reset();
                Response.Write("<script>alert('Peer reward Successful')</script>");
            }
        }
Ejemplo n.º 2
0
    protected void btnCommit_Click(object sender, EventArgs e)
    {
        if (Session["ReceiverID"] == null || Session["ValueID"] == null || Session["CategoryID"] == null || Session["RewardAmount"] == null)
        {
            Response.Write("<script>alert('Please select Receiver Name,Value and Category')</script>");
            popReward.Show();
        }
        else if (Session["ValueID"].ToString() == "-1" || Session["CategoryID"].ToString() == "-1")
        {
            Response.Write("<script>alert('Please select Receiver Name,Value and Category')</script>");
            popReward.Show();
        }
        else
        {
            double pointsAmount     = Convert.ToDouble(rblRewardPoints.SelectedValue);
            string EventDate        = "2/17/2018"; // add textbox to enter
            string EventDescription = txtRDescription.Text;
            string LastUpdated      = DateTime.Now.ToShortDateString();
            string LastUpdatedBy    = Session["loggedIn"].ToString();
            int    ReceiverID       = Convert.ToInt32(Session["ReceiverID"]);
            int    RewarderID       = Convert.ToInt32(Session["ID"]);
            int    CategoryID       = Convert.ToInt32(ddlRCategory.SelectedValue);
            int    ValueID          = Convert.ToInt32(ddlRValue.SelectedValue);

            //try
            //{
            //Connect to Database
            SqlConnection sc = new SqlConnection();
            sc.ConnectionString = ConfigurationManager.ConnectionStrings["GroupProjectConnectionString"].ConnectionString;
            sc.Open();
            PeerTranscation emp = new PeerTranscation(pointsAmount, EventDate, EventDescription, LastUpdated, LastUpdatedBy, ReceiverID, RewarderID, CategoryID, ValueID);

            string sqlString = "INSERT INTO [dbo].[PeerTransaction]([PointsAmount],[Date],[EventDescription],[LastUpdated],[LastUpdatedBy],[ReceiverID],[RewarderID],[CategoryID],[ValueID]) VALUES (@PointsAmount,@Date,@EventDescription,@LastUpdated,@LastUpdatedBy,@ReceiverID,@RewarderID,@CategoryID,@ValueID)";

            SqlCommand insert = new SqlCommand(sqlString);
            insert.Connection = sc;

            insert.Parameters.AddWithValue("@PointsAmount", emp.getPoints());
            insert.Parameters.AddWithValue("@Date", emp.getDate());
            insert.Parameters.AddWithValue("@EventDescription", emp.getDescription());
            insert.Parameters.AddWithValue("@LastUpdated", emp.getLUD());
            insert.Parameters.AddWithValue("@LastUpdatedBy", emp.getLUDB());
            insert.Parameters.AddWithValue("@ReceiverID", emp.getReceiverID());
            insert.Parameters.AddWithValue("@RewarderID", emp.getRewarderID());
            insert.Parameters.AddWithValue("@CategoryID", emp.getCategoryID());
            insert.Parameters.AddWithValue("@ValueID", emp.getValueID());


            insert.ExecuteNonQuery();
            sc.Close();
            //}


            //catch
            //{
            //    lblOutput.Text = "Fail add to database";
            //}
            LatestUpdates();
            reset();
            Response.Write("<script>alert('Peer reward Successful')</script>");
        }
    }