Esempio n. 1
0
    protected void btnCheckIn_Click(object sender, EventArgs e)
    {
        Bookings booking = new Bookings();

        booking.Booking_ID = SqlInt32.Parse(drpBookings.SelectedValue);
        booking.SelectOne();
        if (booking.BookingStatus == BookingStatus.CANCELLED ||
            booking.BookingStatus == BookingStatus.CHECKED_IN ||
            booking.BookingStatus == BookingStatus.CHECKED_OUT)
        {
            lblStatus.Text = "Cannot Check In to  Cancelled/Checked In/Checked Out Booking!!!";
            return;
        }
        DateTime checkInDate        = DateTime.Parse(txtCheckInDate.Text);
        int      compareCheckInDate = checkInDate.CompareTo(DateTime.Now.Date);

        if (compareCheckInDate < 0 || compareCheckInDate > 0)
        {
            lblStatus.Text = "Check In Date must be today";
            return;
        }

        CheckIn checkIn = new CheckIn();

        checkIn.Booking_ID           = booking.Booking_ID;
        checkIn.Guest_ID             = booking.Guest_ID;
        checkIn.Room_ID              = SqlInt32.Parse(drpRoomsList.SelectedValue);
        checkIn.CheckIn_Date         = new SqlDateTime(DateTime.Now);
        checkIn.CheckIn_Personnel    = 1;
        checkIn.IsTotalAmountSettled = (chkPaid.Checked) ? 1 : 0;
        SqlMoney settledAmount = ((txtPendingAmount.Text != null || txtPendingAmount.Text != string.Empty) && txtPendingAmount.Text != "") ? SqlMoney.Parse(txtPendingAmount.Text) : 0;

        if ((hidPendingPayment.Value != null || hidPendingPayment.Value != string.Empty) && hidPendingPayment.Value != "")
        {
            SqlMoney pendingAtBooking = SqlMoney.Parse(hidPendingPayment.Value);
            if (pendingAtBooking > 0 && pendingAtBooking == SqlMoney.Parse(txtPendingAmount.Text))
            {
                checkIn.Settled_Amount       = settledAmount;
                checkIn.IsTotalAmountSettled = 1;
                booking.PaymentStatus        = PaymentStatus.FULLY_PAID;
                checkIn.PendingPayment_Mode  = SqlInt32.Parse(drpPendingPaymentMode.SelectedValue);
            }
            else if (pendingAtBooking > 0 && pendingAtBooking < SqlMoney.Parse(txtPendingAmount.Text))
            {
                checkIn.Settled_Amount        = settledAmount;
                checkIn.IsTotalAmountSettled  = 0;
                booking.PaymentStatus         = PaymentStatus.PARTIAL_PAID;
                checkIn.PendingPayment_Mode   = SqlInt32.Parse(drpPendingPaymentMode.SelectedValue);
                booking.Amount_PendingPayment = pendingAtBooking - settledAmount;
            }
        }
        if (checkIn.Insert())
        {
            Rooms room = new Rooms();
            room.Room_ID = checkIn.Room_ID;
            room.SelectOne();
            room.RoomStatus_ID = RoomStatus.OCCUPIED;
            room.Update();
            booking.BookingStatus = BookingStatus.CHECKED_IN;
            booking.Update();
            lblStatus.Text     = "Successfully Checked In.";
            btnCheckIn.Enabled = false;
        }
    }
    protected void btnCheckIn_Click(object sender, EventArgs e)
    {
        DateTime    checkInDate  = DateTime.Parse(txtCheckInDate.Text);
        SqlDateTime sCheckInDate = Utility.GetSqlCheckInTimeFromDate(checkInDate);

        if (checkInDate.Date > DateTime.Today || checkInDate.Date < DateTime.Today)
        {
            lblMsg.Text = "Invalid Date is wrong";
        }

        Reservations r = new Reservations();

        r.Reservation_ID = SqlInt32.Parse(hidReservationId.Value);
        r.SelectOne();
        Reservation_Payments rp = new Reservation_Payments();

        rp.Reservation_ID = r.Reservation_ID;
        rp.SelectAll();

        if (r.BookingStatus == BookingStatus.CHECKED_IN)
        {
            lblMsg.Text      = "Invalid Check In. Already Checked In";
            lblMsg.ForeColor = Color.Red;
            return;
        }
        if (r.PaymentStatus == PaymentStatus.PARTIAL_PAID)
        {
            lblMsg.Text      = "Please pay the pending amount";
            lblMsg.ForeColor = Color.Red;
            return;
        }
        if (sCheckInDate.Value.Date > r.ToDate.Value.Date)
        {
            lblMsg.Text       = "Invalid Check In Date. Booking Period is past";
            lblMsg.ForeColor  = Color.Red;
            btnCancel.Visible = true;
            return;
        }
        if (sCheckInDate.Value.Date < r.FromDate.Value.Date)
        {
            lblMsg.Text      = "Invalid Check In Date. Selected date is earlier than Booked From date";
            lblMsg.ForeColor = Color.Red;
            return;
        }
        CheckIn checkIn = new CheckIn();

        checkIn.Reservation_ID    = r.Reservation_ID;
        checkIn.CheckIn_Date      = sCheckInDate;
        checkIn.Remarks           = txtComments.Text;
        checkIn.CheckIn_Date      = Utility.GetSqlDateTimeFromDateTime(DateTime.Now);
        checkIn.CheckIn_Personnel = Utility.GetUserIdFromUserName(HttpContext.Current.User.Identity.Name);

        if (checkIn.Insert())
        {
            lblMsg.Text      = "Sucessfully Checked In";
            lblMsg.ForeColor = Color.Green;

            return;
        }
        else
        {
            lblMsg.Text      = checkIn.ErrorCode.ToString() + " - " + checkIn.ErrorDesc.ToString();
            lblMsg.ForeColor = Color.Red;
            return;
        }
    }