protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { chkPaid.Checked = RestaurantBooking.MarkIsPaid; rptPaymentHistory.DataSource = RestaurantBookingPaymentBLL.PaymentHistoryGetByBookingId(RestaurantBooking.Id); rptPaymentHistory.DataBind(); } }
protected void Page_Unload(object sender, EventArgs e) { if (restaurantBookingPaymentBLL != null) { restaurantBookingPaymentBLL.Dispose(); restaurantBookingPaymentBLL = null; } if (userBLL != null) { userBLL.Dispose(); userBLL = null; } }
protected void btnPayment_Click(object sender, EventArgs e) { var paid = 0.0; try { paid = Double.Parse(txtPaid.Text); } catch { } var paymentHistoryAmount = RestaurantBooking.Receivable; RestaurantBooking.TotalPaid += paid; if (chkPaid.Checked) { RestaurantBooking.TotalPaid += RestaurantBooking.TotalPrice - RestaurantBooking.TotalPaid; RestaurantBooking.Receivable = 0.0; } else { RestaurantBooking.Receivable = RestaurantBooking.TotalPrice - RestaurantBooking.TotalPaid; } RestaurantBooking.MarkIsPaid = chkPaid.Checked; RestaurantBookingPaymentBLL.RestaurantBookingSaveOrUpdate(RestaurantBooking); var paymentHistory = new PaymentHistory() { Time = DateTime.Now, Createdby = CurrentUser, Payby = RestaurantBooking.Agency, RestaurantBooking = RestaurantBooking, }; if (chkPaid.Checked) { paymentHistory.Amount = paymentHistoryAmount; } else { paymentHistory.Amount = paid; } RestaurantBookingPaymentBLL.PaymentHistorySaveOrUpdate(paymentHistory); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ReloadReceiablesPage", "parent.location.href=parent.location.href", true); }