private bool SaveReservationPayment(SqlInt32 reservationId, Ferry ferry, int ferryAdultOrChild) { Reservation_Payments pay = new Reservation_Payments(); pay.Reservation_ID = reservationId; pay.PaymentPersonnel = 0;//Utility.GetUserIdFromUserName(HttpContext.Current.User.Identity.Name); pay.CreatedDate = Utility.GetSqlDateTimeFromDateTime(DateTime.Today); pay.Discount_ID = SqlInt32.Parse(this.hidDiscountId.Value); pay.AvailedService_Type = ferryAdultOrChild; //1=Reservation;2=Bills & Services;3=Amenities pay.Discount_Offered = new SqlMoney(0.00); pay.Rate_ID = (SqlInt32)ferry.Ferry_ID; pay.PaymentStatus = PaymentStatus.NOT_PAID; /* * if (ferryAdultOrChild == PAYMENT_AVAILED_SERVICETYPES.FERRY_ADULTS) * { * pay.UnitsConsumed = SqlInt32.Parse(this.drpNumberOfAdults.SelectedValue); * pay.TotalCost_Before_Discount = (ferry.Cost_For_Adults * pay.UnitsConsumed); * SqlMoney costAfterDiscount = (pay.TotalCost_Before_Discount - pay.Discount_Offered); * pay.Cost_After_Discount = costAfterDiscount; * } * else if (ferryAdultOrChild == PAYMENT_AVAILED_SERVICETYPES.FERRY_KIDS) * { * pay.UnitsConsumed = SqlInt32.Parse(this.drpNumberOfChildren.SelectedValue); * pay.TotalCost_Before_Discount = (ferry.Cost_For_Kids * pay.UnitsConsumed); * SqlMoney costAfterDiscount = (pay.TotalCost_Before_Discount - pay.Discount_Offered); * pay.Cost_After_Discount = costAfterDiscount; * } */ pay.AmountReceived = 0; return(pay.Insert()); }
private void SaveBooking(SqlInt32 guestId, out SqlInt32 paymentId, out SqlInt32 reservationId) { paymentId = -1; reservationId = -1; Reservations r = new Reservations(); r.ReservationDate = Utility.GetSqlDateTimeFromDateTime(DateTime.Today); r.FromDate = Utility.GetSqlDateTimeFromDateTime(DateTime.Parse(this.hidFromDate.Value)); r.ToDate = Utility.GetSqlDateTimeFromDateTime(DateTime.Parse(this.hidToDate.Value)); r.ReservationPersonnel = 0; //Utility.GetUserIdFromUserName(HttpContext.Current.User.Identity.Name); r.RateType = SqlInt32.Parse(this.hidRateType.Value); SqlInt32 rateId = SqlInt32.Parse(this.hidRateId.Value); r.Rate_ID = rateId; r.RoomType_ID = SqlInt32.Parse(this.hidRoomTypeId.Value); r.Room_ID = SqlInt32.Parse(this.hidRoomId.Value); r.Parent_Reservation_ID = 0; r.Connected_Room_ID = 0; r.Guest_ID = guestId; r.BookingStatus = BookingStatus.CONFIRMED; r.Remarks = string.Empty; Reservation_Payments pay = new Reservation_Payments(); pay.PaymentPersonnel = 0;//Utility.GetUserIdFromUserName(HttpContext.Current.User.Identity.Name); pay.CreatedDate = Utility.GetSqlDateTimeFromDateTime(DateTime.Today); pay.Discount_ID = SqlInt32.Parse(this.hidDiscountId.Value); pay.AvailedService_Type = PAYMENT_AVAILED_SERVICETYPES.RESERVATION; //1=Reservation;2=Bills & Services;3=Amenities pay.Rate_ID = rateId; pay.UnitsConsumed = SqlInt32.Parse(this.hidBookingDays.Value); pay.Discount_Offered = SqlMoney.Parse(this.hidDiscountOffered.Value); pay.TotalCost_Before_Discount = SqlMoney.Parse(this.hidTotalCost.Value); SqlMoney costAfterDiscount = SqlMoney.Parse(this.hidCostAfterDiscount.Value);; pay.Cost_After_Discount = costAfterDiscount; pay.AmountReceived = 0; if (pay.AmountReceived == 0) { r.PaymentStatus = PaymentStatus.NOT_PAID; r.PendingAmount = pay.Cost_After_Discount - pay.AmountReceived; } else { this.pnlStatus.Visible = true; this.pnlStatus.CssClass = "alert alert-danger"; lblMsg.Text = "Booking Must be Less than or Equal to Cost after Discount"; return; } if (pay.AmountReceived != 0) { pay.PaymentMode = SqlInt32.Parse(this.hidSelectedCardType.Value); } pay.Remarks = r.Remarks; pay.PaymentStatus = 1;//Active if (r.Insert()) { pay.Reservation_ID = r.Reservation_ID; reservationId = r.Reservation_ID; Session.Add("ReservationID", reservationId); Session.Add("Reservation", r); if (pay.Insert()) { this.pnlStatus.Visible = true; this.pnlStatus.CssClass = "alert alert-danger"; lblMsg.Text = "Reservation & Payment was successfully saved."; paymentId = pay.Payment_ID; Session.Add("PaymentID", paymentId); Session.Add("Reservation_Payments", pay); /* * //Insert Ferry Payment as well * //Ferry * Ferry ferry = new Ferry(); * Session.Add("WantFerry", false); * if (this.chkWantFerry.Checked) * { * Session.Add("WantFerry", true); * DataTable toReturn = ferry.SelectAll(); * ferry.Ferry_ID = (Int32)toReturn.Rows[0]["Ferry_ID"]; * ferry.SelectOne(); * ferry.NumberOfAdults = SqlInt32.Parse(this.drpNumberOfAdults.SelectedValue); * ferry.NumberOfKids = SqlInt32.Parse(this.drpNumberOfChildren.SelectedValue); * Session.Add("Ferry", ferry); * bool saveFerry = false; * if(Int32.Parse(drpNumberOfAdults.SelectedValue) > 0) * saveFerry=SaveReservationPayment(r.Reservation_ID, ferry, PAYMENT_AVAILED_SERVICETYPES.FERRY_ADULTS); * if (Int32.Parse(drpNumberOfChildren.SelectedValue) > 0) * saveFerry=SaveReservationPayment(r.Reservation_ID, ferry, PAYMENT_AVAILED_SERVICETYPES.FERRY_KIDS); * if (!saveFerry) * { * this.pnlStatus.Visible = true; * this.pnlStatus.CssClass = "alert alert-danger"; * lblMsg.Text = "There was a problem in saving the Ferry"; * lblMsg.ForeColor = Color.Red; * return; * } * } */ return; } else { this.pnlStatus.Visible = true; this.pnlStatus.CssClass = "alert alert-danger"; lblMsg.Text = "Reservation was saved. However, there was a problem in saving the Payment"; lblMsg.ForeColor = Color.Red; return; } } else { this.pnlStatus.Visible = true; this.pnlStatus.CssClass = "alert alert-danger"; lblMsg.Text = "There was a problem. Could not save Reservation"; lblMsg.ForeColor = Color.Red; return; } }
protected void btnSaveBooking_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtFromDate.Text) || string.IsNullOrEmpty(txtToDate.Text) || drpRoomTypes.SelectedValue.Equals("-1") || drpRateTypes.SelectedValue.Equals("-1") || drpRatesAvailable.SelectedValue.Equals("-1") || drpAvailableRooms.SelectedValue.Equals("-1") ) { lblMsg.Text = "Please select all the Booking fields"; lblMsg.ForeColor = Color.Red; return; } if (string.IsNullOrEmpty(txtBookingAmount.Text)) { lblMsg.Text = "Please calculate your booking amount"; lblMsg.ForeColor = Color.Red; return; } if (string.IsNullOrEmpty(hidNewGuestId.Value)) { lblMsg.Text = "Please select a Guest"; lblMsg.ForeColor = Color.Red; return; } lblMsg.Text = string.Empty; Reservations r = new Reservations(); r.ReservationDate = Utility.GetSqlDateTimeFromDateTime(DateTime.Today); r.FromDate = Utility.GetSqlDateTimeFromDateTime(DateTime.Parse(txtFromDate.Text)); r.ToDate = Utility.GetSqlDateTimeFromDateTime(DateTime.Parse(txtToDate.Text)); r.ReservationPersonnel = Utility.GetUserIdFromUserName(HttpContext.Current.User.Identity.Name); r.RateType = SqlInt32.Parse(drpRateTypes.SelectedValue); SqlInt32 rateId = SqlInt32.Parse(drpRatesAvailable.SelectedValue); r.Rate_ID = rateId; r.RoomType_ID = SqlInt32.Parse(drpRoomTypes.SelectedValue); r.Room_ID = SqlInt32.Parse(drpAvailableRooms.SelectedValue); r.Parent_Reservation_ID = 0; r.Connected_Room_ID = 0; r.Guest_ID = SqlInt32.Parse(hidNewGuestId.Value); r.BookingStatus = BookingStatus.CONFIRMED; r.Remarks = string.Empty; Reservation_Payments pay = new Reservation_Payments(); pay.PaymentPersonnel = Utility.GetUserIdFromUserName(HttpContext.Current.User.Identity.Name); pay.CreatedDate = Utility.GetSqlDateTimeFromDateTime(DateTime.Today); pay.Discount_ID = SqlInt32.Parse(hidDiscountId.Value); pay.AvailedService_Type = 1; //1=Reservation;2=Bills & Services;3=Amenities pay.Rate_ID = rateId; pay.UnitsConsumed = SqlInt32.Parse(hidBookingDays.Value); pay.Discount_Offered = SqlMoney.Parse(hidDiscountOffered.Value); pay.TotalCost_Before_Discount = SqlMoney.Parse(hidTotalCost.Value); pay.Cost_After_Discount = SqlMoney.Parse(hidCostAfterDiscount.Value); pay.AmountReceived = SqlMoney.Parse(txtBookingAmount.Text); if (pay.AmountReceived < pay.Cost_After_Discount) { r.PaymentStatus = PaymentStatus.PARTIAL_PAID; r.PendingAmount = pay.Cost_After_Discount - pay.AmountReceived; } else if (pay.AmountReceived == pay.Cost_After_Discount) { r.PaymentStatus = PaymentStatus.FULLY_PAID; } else { lblMsg.Text = "Booking Must be Less than or Equal to Cost after Discount"; lblMsg.ForeColor = Color.Red; return; } if (pay.AmountReceived != 0) { if (drpPaymentModes.SelectedValue == "-1") { lblMsg.Text = "Please select a Payment Mode"; lblMsg.ForeColor = Color.Red; return; } else { pay.PaymentMode = SqlInt32.Parse(drpPaymentModes.SelectedValue); } } pay.Remarks = r.Remarks; pay.PaymentStatus = 1; //Active if (r.Insert()) { pay.Reservation_ID = r.Reservation_ID; if (pay.Insert()) { // DataTable resevePay = pay.GetReservationPayment(); //Session["resevePay"] = resevePay; //string popupScript = "<script language='javascript'>" + // "window.open('ReservConfirm.aspx','ThisPopUp', " + // "'left = 300, top=150, " + // "menubar=no, scrollbars=yes, resizable=yes')" + // "</script>"; //Page.ClientScript.RegisterStartupScript(GetType(), "PopupScript", popupScript); Response.Redirect("Reservation.aspx?Reservation_ID=" + r.Reservation_ID.ToString(), true); } else { lblMsg.Text = "Reservation was saved. However, there was a problem in saving the Payment"; lblMsg.ForeColor = Color.Red; return; } } }
protected void btnSavePayment_Click(object sender, EventArgs e) { if (drpServiceType.SelectedValue == "-1") { lblPaymentMsg.Text = "Please select a Service Type"; lblPaymentMsg.ForeColor = Color.Red; return; } if (drpService.SelectedValue == "-1") { lblPaymentMsg.Text = "Please select a Service Type"; lblPaymentMsg.ForeColor = Color.Red; return; } Reservation_Payments rp = new Reservation_Payments(); rp.Reservation_ID = SqlInt32.Parse(hidReservationId.Value); rp.CreatedDate = Utility.GetSqlDateTimeFromDateTime(DateTime.Today); rp.PaymentPersonnel = Utility.GetUserIdFromUserName(HttpContext.Current.User.Identity.Name); rp.AvailedService_Type = SqlInt32.Parse(drpServiceType.SelectedValue); Reservations r = new Reservations(); r.Reservation_ID = SqlInt32.Parse(hidReservationId.Value); r.SelectOne(); if (drpServiceType.SelectedValue.Equals("1"))//If type reservation { if (r.PendingAmount <= 0) { lblPaymentMsg.Text = "There are no more Pending amounts to be paid for the reservation"; lblPaymentMsg.ForeColor = Color.Red; return; } if (string.IsNullOrEmpty(lblCost.Text) || SqlMoney.Parse(lblCost.Text) == 0) { lblPaymentMsg.Text = "There are no more Pending amounts to be paid for the reservation"; lblPaymentMsg.ForeColor = Color.Red; return; } if (SqlMoney.Parse(lblCost.Text) != 0) { SqlMoney toPay = SqlMoney.Parse(lblCost.Text); SqlMoney amountReceived = SqlMoney.Parse(txtAmountReceived.Text); if (amountReceived < toPay || amountReceived > toPay) { lblPaymentMsg.Text = "Please pay only the Pending Reservation Amount to confirm reservation"; lblPaymentMsg.ForeColor = Color.Red; return; } r.PendingAmount = new SqlMoney(0.00);//SqlMoney.Parse(lblCost.Text); r.BookingStatus = BookingStatus.CONFIRMED; r.PaymentStatus = PaymentStatus.FULLY_PAID; r.Update(); } rp.Rate_ID = r.Rate_ID; rp.UnitsConsumed = 0; rp.TotalCost_Before_Discount = r.PendingAmount; } else { if (r.BookingStatus != BookingStatus.CHECKED_IN) { lblPaymentMsg.Text = "Cannot Save Payment. Not yet Checked In"; lblPaymentMsg.ForeColor = Color.Red; return; } if (String.IsNullOrEmpty(txtUnits.Text)) { lblPaymentMsg.Text = "Please enter Units consumed"; lblPaymentMsg.ForeColor = Color.Red; return; } rp.Rate_ID = SqlInt32.Parse(drpService.SelectedValue); rp.UnitsConsumed = SqlInt32.Parse(txtUnits.Text); rp.TotalCost_Before_Discount = SqlMoney.Parse(lblCost.Text); } if (drpPaymentModes.SelectedValue == "-1") { lblPaymentMsg.Text = "Please select a Payment Mode"; lblPaymentMsg.ForeColor = Color.Red; return; } rp.Invoice = txtInvoice.Text == string.Empty ? string.Empty : txtInvoice.Text; rp.PaymentStatus = 1;//Active; rp.Discount_Offered = txtDiscount.Text == string.Empty ? 0 : SqlMoney.Parse(txtDiscount.Text); rp.Cost_After_Discount = rp.Discount_Offered == 0? rp.TotalCost_Before_Discount: SqlMoney.Parse(lblAfterDiscount.Text); rp.AmountReceived = txtAmountReceived.Text == string.Empty ? 0 : SqlMoney.Parse(txtAmountReceived.Text); rp.PaymentMode = SqlInt32.Parse(drpPaymentModes.SelectedValue); if (rp.Insert()) { Response.Redirect("Reservation.aspx?Reservation_ID=" + hidReservationId.Value, true); } else { lblPaymentMsg.Text = rp.ErrorDesc.ToString() + " Error Playment Not saved !!!"; lblPaymentMsg.ForeColor = Color.Green; return; } }
protected void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(hidCheckInID.Value) || hidCheckInID.Value == "0") { lblStatus.Text = "The Reservation is invalid. Not Checked In"; return; } if (drpBillServices.SelectedValue == "-1") { lblStatus.Text = "Please choose a Bill Service"; return; } if (drpCheckIn.SelectedValue == "-1") { lblStatus.Text = "Please Bill Service"; return; } Reservation_Payments rp = new Reservation_Payments(); rp.Reservation_ID = SqlInt32.Parse(drpCheckIn.SelectedValue); rp.CreatedDate = Utility.GetSqlDateTimeFromDateTime(DateTime.Today); rp.PaymentPersonnel = Utility.GetUserIdFromUserName(HttpContext.Current.User.Identity.Name); rp.AvailedService_Type = PAYMENT_AVAILED_SERVICETYPES.BILLS_SERVICES; rp.Rate_ID = SqlInt32.Parse(drpBillServices.SelectedValue); rp.UnitsConsumed = SqlInt32.Parse(txtQuantity.Text); rp.TotalCost_Before_Discount = SqlMoney.Parse(txtPrice.Text); rp.Invoice = txtInvoice.Text == string.Empty ? string.Empty : txtInvoice.Text; rp.PaymentStatus = 1;//Active; rp.Discount_Offered = txtDiscount.Text == string.Empty ? 0 : SqlMoney.Parse(txtDiscount.Text); rp.Cost_After_Discount = rp.Discount_Offered == 0 ? rp.TotalCost_Before_Discount : SqlMoney.Parse(lblAfterDiscount.Text); rp.AmountReceived = txtAmountReceived.Text == string.Empty ? 0 : SqlMoney.Parse(txtAmountReceived.Text); if (rp.AmountReceived > 0) { if (drpPaymentModes.SelectedValue == "-1") { lblStatus.Text = "Please select a Payment Mode"; lblStatus.ForeColor = Color.Red; return; } else { rp.PaymentMode = SqlInt32.Parse(drpPaymentModes.SelectedValue); } } if (rp.Insert()) { rp.InsertServiceInvoice(); lblStatus.Text = "Payment Saved"; lblStatus.ForeColor = Color.Green; // return; //---------------for Printing the Amenity invoice---------------------------------------- DataTable amenitytbl = new DataTable(); DataColumn Id = new DataColumn("ID", typeof(int)); DataColumn ReservationID = new DataColumn("ReservationID", typeof(int)); DataColumn RoomId = new DataColumn("RoomID", typeof(string)); DataColumn ServiceName = new DataColumn("ServiceName", typeof(string)); DataColumn Invoice = new DataColumn("Invoice", typeof(string)); DataColumn Cost = new DataColumn("Cost", typeof(double)); DataColumn Qty = new DataColumn("Quantity", typeof(int)); DataColumn TotCost = new DataColumn("TotCost", typeof(double)); DataColumn Discount = new DataColumn("Discount", typeof(double)); DataColumn AfterDiscount = new DataColumn("AfterDiscount", typeof(double)); DataColumn AmountReceived = new DataColumn("AmountRecevied", typeof(double)); DataColumn PaymentMode = new DataColumn("PaymentMode", typeof(string)); DataColumn CreatedBy = new DataColumn("CreatedBy", typeof(string)); DataColumn InvoiceNo = new DataColumn("InvoiceNo", typeof(string)); amenitytbl.Columns.Add(Id); amenitytbl.Columns.Add(ReservationID); amenitytbl.Columns.Add(RoomId); amenitytbl.Columns.Add(ServiceName); amenitytbl.Columns.Add(Invoice); amenitytbl.Columns.Add(Cost); amenitytbl.Columns.Add(Qty); amenitytbl.Columns.Add(TotCost); amenitytbl.Columns.Add(Discount); amenitytbl.Columns.Add(AfterDiscount); amenitytbl.Columns.Add(AmountReceived); amenitytbl.Columns.Add(PaymentMode); amenitytbl.Columns.Add(CreatedBy); amenitytbl.Columns.Add(InvoiceNo); DataRow row = amenitytbl.NewRow(); row["Id"] = 1; row["ReservationID"] = Int32.Parse(rp.Reservation_ID.ToString()); row["ServiceName"] = drpBillServices.SelectedItem.Text; row["Invoice"] = txtInvoice.Text; row["Cost"] = double.Parse(lblPrice.Text); row["Quantity"] = int.Parse(rp.UnitsConsumed.ToString()); row["TotCost"] = double.Parse(rp.TotalCost_Before_Discount.ToString()); row["Discount"] = double.Parse(rp.Discount_Offered.ToString()); row["AfterDiscount"] = double.Parse(rp.Cost_After_Discount.ToString()); row["AmountRecevied"] = double.Parse(rp.AmountReceived.ToString()); row["PaymentMode"] = drpPaymentModes.SelectedItem.Text; row["CreatedBy"] = HttpContext.Current.User.Identity.Name; row["InvoiceNo"] = rp.ServiceNo.ToString(); amenitytbl.Rows.Add(row); Session["Inv"] = amenitytbl; string popupScript = "<script language='javascript'>" + "window.open('AmenityInvView.aspx','ThisPopUp1', " + "'left = 300, top=150, " + "menubar=no, scrollbars=yes, resizable=yes')" + "</script>"; Page.ClientScript.RegisterStartupScript(GetType(), "PopupScript", popupScript); //---------------------------------------------------------------------------------- } else { lblStatus.Text = rp.ErrorDesc.ToString() + " Error Playment Not saved !!!"; lblStatus.ForeColor = Color.Red; return; } }