示例#1
0
        private void btnCelculatePayment_Click(object sender, EventArgs e)
        {
            PaymentsTableAdapter paymentsTableAdapter = new PaymentsTableAdapter();

            int compareDate = Convert.ToInt32(paymentsTableAdapter.CompareDatePayAndCheckIn(CheckInID));

            if (compareDate == 0)
            {
                int paymentId = Convert.ToInt32(paymentsTableAdapter.GetMaxIDAsCheckIn(CheckInID));
                if (paymentId > 0)
                {
                    if (0 == Convert.ToDouble(serviceChargesTableAdapter.GetServiceAmount(CheckInID)))
                    {
                        MessageBox.Show("ไม่มีรายการปรับปรุง", "เสร็จสมบูรณ์", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    else
                    {
                        paymentsTableAdapter.UpdateServiceAmount(paymentId, CheckInID);
                        serviceChargesTableAdapter.UpdatePayID(paymentId, CheckInID);
                    }
                }
                else
                {
                    double servicesAmount = Convert.ToDouble(serviceChargesTableAdapter.GetServiceAmount(CheckInID));
                    if (servicesAmount != 0)
                    {
                        paymentsTableAdapter.Insert(
                            CheckInID,
                            null,
                            null,
                            0,
                            servicesAmount,
                            servicesAmount,
                            null,
                            0,
                            null,
                            null);

                        int payId = Convert.ToInt32(paymentsTableAdapter.GetMaxID());
                        serviceChargesTableAdapter.UpdatePayID(payId, CheckInID);
                    }
                }

                MessageBox.Show("คำนวนใบเสร็จรับเงินเสร็จสมบูรณ์", "เสร็จสมบูรณ์", MessageBoxButtons.OK, MessageBoxIcon.Information);

                this.paymentViewTableAdapter.FillByCheckInID(
                    this.apartmentDataSet.PaymentView, CheckInID);
                this.serviceChargesTableAdapter.FillByCheckInID(
                    this.apartmentDataSet.ServiceCharges, CheckInID);
            }
            else
            {
                MessageBox.Show("ไม่มีรายการปรับปรุง", "เสร็จสมบูรณ์", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private void btnPayment_Click(object sender, EventArgs e)
        {
            DataRowView  payDataRow = (DataRowView)paymentViewBindingSource.Current;
            DialogResult result     = MessageBox.Show("คุณต้องการชำระเงิน " + payDataRow.Row["AmountTotal"].ToString() + " บาท หรือไม่", "ยืนยันชำระเงิน", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2);

            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                PaymentsTableAdapter paymentsTableAdapter = new PaymentsTableAdapter();
                paymentsTableAdapter.UpdatePayStatus(MainUI.StaffID, 1, DateTime.Now, PaymentID);
                MessageBox.Show("คุณชำระเงินเสร็จเรียนร้อย");
            }
            loadDataSource();
        }
示例#3
0
        private void btnCheckOut_Click(object sender, EventArgs e)
        {
            if (DialogResult.No.Equals(MessageBox.Show("คุณยืนยันจะเช็คเอ้าออกจริงหรือไม่", "ยืนยันจะเช็คเอ้าออก", MessageBoxButtons.YesNo, MessageBoxIcon.Information)))
            {
                return;
            }

            PaymentsTableAdapter paymentsTableAdapter = new PaymentsTableAdapter();
            int compareDate = Convert.ToInt32(paymentsTableAdapter.CompareDatePayAndCheckIn(CheckInID));

            if (compareDate == 0)
            {
                int paymentId = Convert.ToInt32(paymentsTableAdapter.GetMaxIDAsCheckIn(CheckInID));
                if (paymentId > 0)
                {
                    if (0 == Convert.ToDouble(serviceChargesTableAdapter.GetServiceAmount(CheckInID)))
                    {
                        MessageBox.Show("คุณยังมียอดค้างชำระ กรุณากลับไปจ่ายให้เรียบร้อย", "แจ้งเตือน 0-0", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        //MessageBox.Show("ไม่มีรายการปรับปรุง", "เสร็จสมบูรณ์", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    paymentsTableAdapter.UpdateServiceAmount(paymentId, CheckInID);
                    serviceChargesTableAdapter.UpdatePayID(paymentId, CheckInID);
                }
                else
                {
                    double servicesAmount = Convert.ToDouble(serviceChargesTableAdapter.GetServiceAmount(CheckInID));
                    if (servicesAmount != 0)
                    {
                        paymentsTableAdapter.Insert(
                            CheckInID,
                            null,
                            null,
                            0,
                            servicesAmount,
                            servicesAmount,
                            null,
                            0,
                            null,
                            null);

                        int payId = Convert.ToInt32(paymentsTableAdapter.GetMaxID());
                        serviceChargesTableAdapter.UpdatePayID(payId, CheckInID);
                    }
                }
                this.paymentViewTableAdapter.FillByCheckInID(
                    this.apartmentDataSet.PaymentView, CheckInID);
                this.serviceChargesTableAdapter.FillByCheckInID(
                    this.apartmentDataSet.ServiceCharges, CheckInID);
            }

            if (Convert.ToInt32(paymentsTableAdapter.CheckPayIt(CheckInID)) == 0)
            {
                try
                {
                    CheckInsTableAdapter checkInTableAdapter = new CheckInsTableAdapter();
                    checkInTableAdapter.UpdateCheckOutDate(DateTime.Now, CheckInID);
                    MessageBox.Show("เช็คเอ้าเสร็จสมบูรณ์", "เสร็จสมบูรณ์", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    DialogResult = System.Windows.Forms.DialogResult.Yes;
                }
                catch (Exception)
                {
                    MessageBox.Show("ไม่สามารถเช็คเอ้าได้ กรุณาลองใหม่อีกครั้ง", "ข้อผิดผลาด", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                MessageBox.Show("คุณยังมียอดค้างชำระ กรุณากลับไปจ่ายให้เรียบร้อย", "แจ้งเตือน", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
示例#4
0
        private void btnCheckIn_Click(object sender, EventArgs e)
        {
            if (!this.customerDetailPanel.ValidateChildren())
            {
                tabControl1.SelectedIndex = 0;
                return;
            }
            if (this.roomDetailPanel.cbxRoomNO.SelectedItem == null)
            {
                MessageBox.Show("คุณยังไม่ได้เลือกห้องพัก", "คุณยังไม่ได้เลือกห้องพัก", MessageBoxButtons.OK, MessageBoxIcon.Information);
                tabControl1.SelectedIndex = 1;
                return;
            }

            double amountRoom = 0;
            double roomPrices = Convert.ToDouble(((DataRowView)this.roomDetailPanel.fKRoomTypesCustomerTypesBindingSource.Current).Row["Prices"]);

            if (Convert.ToInt32(this.roomDetailPanel.cbxCustomerType.SelectedValue) == 1)
            {
                int days = this.roomDetailPanel.dtpEndStay.Value.Subtract(this.roomDetailPanel.dtpStarStay.Value).Days;
                if (days < 30)
                {
                    amountRoom = (roomPrices / 30) * days;
                    Console.WriteLine("รายเดือน " + amountRoom + " " + days);
                }
            }
            else if (Convert.ToInt32(this.roomDetailPanel.cbxCustomerType.SelectedValue) == 2)
            {
                int days = this.roomDetailPanel.dtpEndStay.Value.Subtract(this.roomDetailPanel.dtpStarStay.Value).Days;
                amountRoom = roomPrices * days;
                Console.WriteLine("รายวัน " + amountRoom + " " + days);
            }



            try
            {
                CustomersTableAdapter customerTableAdapter = new CustomersTableAdapter();

                customerTableAdapter.Insert(
                    this.customerDetailPanel.tbxPeopleID.Text,
                    this.customerDetailPanel.tbxFirstname.Text,
                    this.customerDetailPanel.tbxLastname.Text,
                    Convert.ToByte(this.customerDetailPanel.cbxSex.SelectedIndex),
                    this.customerDetailPanel.dtpBirthDay.Value,
                    this.customerDetailPanel.tbxAddress.Text,
                    this.customerDetailPanel.tbxSubDistrict.Text,
                    this.customerDetailPanel.tbxDistrict.Text,
                    this.customerDetailPanel.cbxProvince.SelectedItem.ToString(),
                    this.customerDetailPanel.cbxCountry.SelectedItem.ToString(),
                    this.customerDetailPanel.tbxTelephone.Text,
                    this.customerDetailPanel.tbxMobile.Text,
                    this.customerDetailPanel.tbxEmail.Text);



                CustomerTypesTableAdapter customerTypesTableAdapter = new CustomerTypesTableAdapter();
                RoomTypesTableAdapter     roomTypesTableAdapter     = new RoomTypesTableAdapter();
                CheckInsTableAdapter      checkInsTableAdapter      = new CheckInsTableAdapter();
                RoomsTableAdapter         roomsTableAdapter         = new RoomsTableAdapter();
                int customerID = Convert.ToInt32(customerTableAdapter.GetMaxID());

                if (BookingID == 0)
                {
                    checkInsTableAdapter.Insert(
                        customerID,
                        Convert.ToInt32(roomDetailPanel.cbxCustomerType.SelectedValue),
                        customerTypesTableAdapter.GetCustomerTypeName(Convert.ToInt32(roomDetailPanel.cbxCustomerType.SelectedValue)),
                        Convert.ToInt32(roomDetailPanel.cbxRoomType.SelectedValue),
                        roomTypesTableAdapter.GetRoomTypeName(Convert.ToInt32(roomDetailPanel.cbxRoomType.SelectedValue)),
                        Convert.ToInt32(this.roomDetailPanel.roomsTableAdapter.GetRoomID(((DataRowView)roomDetailPanel.fKRoomsRoomTypesBindingSource.Current).Row["NO"].ToString())),
                        ((DataRowView)roomDetailPanel.fKRoomsRoomTypesBindingSource.Current).Row["NO"].ToString(),
                        roomPrices,
                        roomDetailPanel.dtpStarStay.Value,
                        roomDetailPanel.dtpEndStay.Value,
                        roomDetailPanel.tbxDescription.Text,
                        MainUI.StaffID,
                        null,
                        DateTime.Now,
                        null,
                        0);
                }
                else
                {
                    checkInsTableAdapter.Insert(
                        customerID,
                        Convert.ToInt32(roomDetailPanel.cbxCustomerType.SelectedValue),
                        customerTypesTableAdapter.GetCustomerTypeName(Convert.ToInt32(roomDetailPanel.cbxCustomerType.SelectedValue)),
                        Convert.ToInt32(roomDetailPanel.cbxRoomType.SelectedValue),
                        roomTypesTableAdapter.GetRoomTypeName(Convert.ToInt32(roomDetailPanel.cbxRoomType.SelectedValue)),
                        Convert.ToInt32(this.roomDetailPanel.roomsTableAdapter.GetRoomID(((DataRowView)roomDetailPanel.fKRoomsRoomTypesBindingSource.Current).Row["NO"].ToString())),
                        ((DataRowView)roomDetailPanel.fKRoomsRoomTypesBindingSource.Current).Row["NO"].ToString(),
                        roomPrices,
                        roomDetailPanel.dtpStarStay.Value,
                        roomDetailPanel.dtpEndStay.Value,
                        roomDetailPanel.tbxDescription.Text,
                        MainUI.StaffID,
                        BookingID,
                        DateTime.Now,
                        null,
                        0);
                }


                PaymentsTableAdapter paymentsTableAdapter = new PaymentsTableAdapter();
                int checKInID = Convert.ToInt32(checkInsTableAdapter.GetMaxID());
                paymentsTableAdapter.Insert(
                    checKInID,
                    this.roomDetailPanel.dtpStarStay.Value,
                    this.roomDetailPanel.dtpEndStay.Value,
                    (int)amountRoom,
                    0,
                    (int)amountRoom,
                    null,
                    0,
                    null,
                    null);


                MessageBox.Show("เช็คอินเสร็จสมบูรณ์", "เสร็จสมบูรณ์", MessageBoxButtons.OK, MessageBoxIcon.Information);


                //เปิดหน้าชำระเงิน
                PaymentDetailUI payment = new PaymentDetailUI();
                payment.PaymentID = Convert.ToInt32(paymentsTableAdapter.GetMaxID());
                payment.ShowDialog();
                this.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());

                MessageBox.Show("ไม่สามารถเช็คอินได้, กรุณาลองใหม่อีกครั้ง ", "ข้อผิดผลาด", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                DialogResult = System.Windows.Forms.DialogResult.No;
            }
        }
        private void btnChange_Click(object sender, EventArgs e)
        {
            if (dtpEndStay.MinDate.Subtract(dtpEndStay.Value).Days == 0)
            {
                DialogResult result = MessageBox.Show("คุณไม่ได้เปลี่ยนแปลงเวลาออก, คุณต้องเปลี่ยนแปลงอีกครั้งหรือไม่", "คุณไม่ได้เปลี่ยนแปลงเวลาออก", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                if (result.Equals(DialogResult.No))
                {
                    DialogResult = System.Windows.Forms.DialogResult.No;
                    Console.WriteLine("No Change date.");
                }
            }

            checkInsTableAdapter.UpdateCheckInEndStay(dtpEndStay.Value, CheckInID);

            PaymentsTableAdapter paymentsTableAdapter = new PaymentsTableAdapter();
            DateTime             checkInDate          = (DateTime)checkInsTableAdapter.GetMaxEndDate(CheckInID);
            DateTime             paymentDate          = (DateTime)paymentsTableAdapter.GetMaxEndDate(CheckInID);

            if (checkInDate.Subtract(paymentDate).Days > 0)
            {
                double roomAmount = checkInDate.Subtract(paymentDate).Days *Convert.ToDouble(checkInsTableAdapter.GetRoomPrice(CheckInID));


                int paymentId = Convert.ToInt32(paymentsTableAdapter.GetMaxIDAsCheckInFromRoom(CheckInID));
                if (paymentId > 0)
                {
                    try
                    {
                        ServiceChargesTableAdapter serviceChargesTableAdapter = new ServiceChargesTableAdapter();
                        if (0 != Convert.ToDouble(serviceChargesTableAdapter.GetServiceAmount(CheckInID)))
                        {
                            paymentsTableAdapter.UpdateRoomAmount(roomAmount, paymentDate.ToString(), dtpEndStay.Value.ToString(), paymentId);
                            paymentsTableAdapter.UpdateServiceAmount(paymentId, CheckInID);
                            serviceChargesTableAdapter.UpdatePayID(paymentId, CheckInID);
                        }
                        else
                        {
                            paymentsTableAdapter.UpdateRoomAmount(roomAmount, paymentDate.ToString(), dtpEndStay.Value.ToString(), paymentId);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                        throw;
                    }
                }
                else
                {
                    ServiceChargesTableAdapter serviceChargesTableAdapter = new ServiceChargesTableAdapter();
                    double servicesAmount = Convert.ToDouble(serviceChargesTableAdapter.GetServiceAmount(CheckInID));

                    try
                    {
                        paymentsTableAdapter.Insert(
                            CheckInID,
                            paymentDate,
                            dtpEndStay.Value,
                            roomAmount,
                            servicesAmount,
                            servicesAmount + roomAmount,
                            null,
                            0,
                            null,
                            null);

                        int payId = Convert.ToInt32(paymentsTableAdapter.GetMaxID());
                        serviceChargesTableAdapter.UpdatePayID(payId, CheckInID);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                        throw;
                    }
                }
            }
            MessageBox.Show("การเปลี่ยนแปลงเสร็จสมบูรณ์");
            DialogResult = System.Windows.Forms.DialogResult.Yes;
        }