// method to read the column values in the database (through the referenced reader) and assign it to the correct properties of the referenced Extension object
 // allows for easier editing of column names if needed, used only for methods with select statments regarding Extension
 private static void readAnExtension(ref Extension extent, ref SqlDataReader reader)
 {
     extent.ExtensionID       = reader["extentionID"].ToString();
     extent.NewReturnLocation = reader["newReturnLocation"].ToString();
     extent.NewReturnTime     = Convert.ToDateTime(reader["newReturnTime"]);
     extent.NewEndDate        = Convert.ToDateTime(reader["newEndDate"]);
     extent.Unit               = Convert.ToString(reader["unit"]);
     extent.Status             = Convert.ToString(reader["status"]);
     extent.ExtensionRentalFee = Convert.ToDecimal(reader["extensionRentalFee"]);
     extent.Payment            = PaymentDB.getPaymentbyID(reader["paymentID"].ToString());
     extent.Rental             = RentalDB.getRentalbyID(reader["rentalID"].ToString());
 }
Exemple #2
0
    // method to read the column values in the database (through the referenced reader) and assign it to the correct properties of the referenced Rental object
    // allows for easier editing of column names if needed, used only for methods with select statments regarding Rental
    private static void readARental(ref Rental rent, ref SqlDataReader reader)
    {
        rent.RentalID           = Convert.ToString(reader["rentalID"]);
        rent.PickUpLocation     = Convert.ToString(reader["pickUpLocation"]);
        rent.PickUpTime         = (TimeSpan)reader["pickUpTime"];
        rent.RentalFee          = Convert.ToDecimal(reader["rentalFee"]);
        rent.Unit               = reader["unit"].ToString();
        rent.Deposit            = Convert.ToDecimal(reader["deposit"]);
        rent.DateCreated        = Convert.ToDateTime(reader["dateCreated"]);
        rent.StartDate          = Convert.ToDateTime(reader["startDate"]);
        rent.EndDate            = Convert.ToDateTime(reader["endDate"]);
        rent.Status             = Convert.ToString(reader["status"]);
        rent.PaymentReleaseCode = Convert.ToString(reader["paymentReleaseCode"]);

        if (reader["depositRetrievalCode"] != DBNull.Value)
        {
            rent.DepositRetrievalCode = Convert.ToString(reader["depositRetrievalCode"]);
        }
        else
        {
            rent.DepositRetrievalCode = null;
        }

        if (reader["returnLocation"] != DBNull.Value)
        {
            rent.ReturnLocation = reader["returnLocation"].ToString();
        }
        else
        {
            rent.ReturnLocation = "";
        }

        if (reader["returnTime"] != DBNull.Value)
        {
            rent.ReturnTime = (TimeSpan)reader["returnTime"];
        }
        else
        {
            rent.ReturnTime = new TimeSpan(0, 0, 0);
        }

        rent.Rentee = MemberDB.getMemberbyID(reader["renteeID"].ToString());

        rent.Item = ItemDB.getItembyID(reader["itemID"].ToString());

        rent.Payment = PaymentDB.getPaymentbyID(reader["paymentID"].ToString());
    }
    protected void btnPay_Click(object sender, EventArgs e)
    {
        // submit payment

        Item itemInfo = ItemDB.getItembyID(Request.QueryString["itemID"]);

        Member mem = MemberDB.getMemberbyEmail(Session["user"].ToString());

        Rental rentInfo = (Rental)Session["rental"];
        var    myCharge = new StripeChargeCreateOptions();

        myCharge.Amount   = Convert.ToInt32(rentInfo.RentalFee) * 100;
        myCharge.Currency = "sgd";

        myCharge.SourceCard = new SourceCard()
        {
            Number          = "4242424242424242",
            ExpirationYear  = 2022,
            ExpirationMonth = 10,
            AddressCountry  = "SG",                      // optional
            AddressLine1    = mem.Address,               // optional
            AddressLine2    = mem.Address,               // optional
            AddressCity     = "Singapore",               // optional
            AddressState    = "NC",                      // optional
            AddressZip      = mem.PostalCode.ToString(), // optional
            Name            = mem.Name,                  // optional
            Cvc             = "1223"                     // optional
        };
        var          chargeService = new StripeChargeService();
        StripeCharge stripeCharge  = chargeService.Create(myCharge);

        PaymentPay pay = new PaymentPay();

        pay.StripeRefNum = Utility.getRandomizedChar(5, 0);

        string n         = Session["rentalPeriod"].ToString();
        string startDate = n.Substring(0, 10);
        string endDate   = n.Substring(n.Length - 10);

        if (Session["itemExtension"].ToString() == "NotExtension")
        {
            rentInfo.DateCreated        = DateTime.Now;
            rentInfo.Deposit            = itemInfo.Deposit;
            rentInfo.PaymentReleaseCode = Utility.getRandomizedChar(6, 0);
            rentInfo.Item = itemInfo;

            rentInfo.StartDate = Convert.ToDateTime(startDate);
            rentInfo.EndDate   = Convert.ToDateTime(endDate);
            rentInfo.Status    = "Scheduled";

            rentInfo.Payment = PaymentDB.getPaymentbyID(Utility.convertIdentitytoPK("PAY", PaymentDB.addPayment(pay)));
            rentInfo.Rentee  = mem;
            rentInfo.Unit    = "Day";

            Response.Redirect("RentalDetails.aspx?rentalID=" + Utility.convertIdentitytoPK("RNT", RentalDB.addRental(rentInfo)));
        }
        else
        {
            Rental rent = RentalDB.getRentalbyID(Request.QueryString["rentalID"]);

            Extension ext = new Extension();

            ext.ExtensionRentalFee = rentInfo.RentalFee;
            ext.NewEndDate         = Convert.ToDateTime(endDate);
            ext.NewReturnLocation  = rent.ReturnLocation;
            int paymentID = PaymentDB.addPayment(pay);

            pay.PaymentID     = Utility.convertIdentitytoPK("PAY", paymentID);
            ext.NewReturnTime = rent.ReturnTime;
            ext.Payment       = pay;

            ext.Rental = rent;
            ext.Status = "Granted";
            ext.Unit   = "Day";

            ExtensionDB.addExtension(ext);

            Response.Redirect("RentalDetails.aspx?rentalID=" + Request.QueryString["rentalID"]);
        }
    }
Exemple #4
0
    protected void btnPay_Click(object sender, EventArgs e)
    {
        Item itemInfo = ItemDB.getItembyID(Request.QueryString["itemID"]);

        Member mem = MemberDB.getMemberbyEmail(Session["user"].ToString());

        var myCharge = new StripeChargeCreateOptions();

        myCharge.Amount   = 50;
        myCharge.Currency = "sgd";

        myCharge.SourceCard = new SourceCard()
        {
            Number          = "4242424242424242",
            ExpirationYear  = 2022,
            ExpirationMonth = 10,
            AddressCountry  = "SG",                      // optional
            AddressLine1    = mem.Address,               // optional
            AddressLine2    = mem.Address,               // optional
            AddressCity     = "Singapore",               // optional
            AddressState    = "NC",                      // optional
            AddressZip      = mem.PostalCode.ToString(), // optional
            Name            = mem.Name,                  // optional
            Cvc             = "1223"                     // optional
        };
        var          chargeService = new StripeChargeService();
        StripeCharge stripeCharge  = chargeService.Create(myCharge);

        Rental rent = new Rental();

        rent.DateCreated          = DateTime.Now;
        rent.Deposit              = itemInfo.Deposit;
        rent.DepositRetrievalCode = Utility.getRandomizedChar(6, 1);
        rent.PaymentReleaseCode   = Utility.getRandomizedChar(6, 1);
        rent.PickUpLocation       = Session["pickUpLocation"].ToString();

        DateTime pickUpTime = DateTime.ParseExact(Session["pickUpTime"].ToString(),
                                                  "hh:mm tt", CultureInfo.InvariantCulture);
        TimeSpan pickUpTimeSpan = pickUpTime.TimeOfDay;

        DateTime returnTime = DateTime.ParseExact(Session["returnTime"].ToString(),
                                                  "hh:mm tt", CultureInfo.InvariantCulture);
        TimeSpan returnTimeSpan = returnTime.TimeOfDay;

        rent.PickUpTime = pickUpTimeSpan;
        rent.ReturnTime = returnTimeSpan;

        rent.ReturnLocation = Session["returnLocation"].ToString();
        rent.Item           = itemInfo;


        string n         = Session["rentalPeriod"].ToString();
        string startDate = n.Substring(0, 10);
        string endDate   = n.Substring(n.Length - 10);

        rent.StartDate = Convert.ToDateTime(startDate);
        rent.EndDate   = Convert.ToDateTime(endDate);
        rent.Status    = "Scheduled";

        PaymentPay pay = new PaymentPay();


        pay.StripeRefNum = Utility.getRandomizedChar(5, 1);

        rent.Payment = PaymentDB.getPaymentbyID(Utility.convertIdentitytoPK("PAY", PaymentDB.addPayment(pay)));

        rent.Rentee = mem;


        rent.Unit = "Day";

        Response.Redirect("RentalDetails.aspx?rentalID=" + Utility.convertIdentitytoPK("RNT", RentalDB.addRental(rent)));
    }