Example #1
0
        private void loadDatasource()
        {
            DateTime dDate = DateTime.Now;

            if (dDate.Hour < 12)
            {
                dDate.AddDays(-1);
            }

            this.checkInsTableAdapter.FillCheckIng(this.apartmentDataSet.CheckIns);
            this.customerTypesTableAdapter.Fill(this.apartmentDataSet.CustomerTypes);



            RoomsTableAdapter roomsTableAdapter = new RoomsTableAdapter();
            int roomCount     = Convert.ToInt32(roomsTableAdapter.GetRoomCount());
            int roomUserCount = Convert.ToInt32(checkInsTableAdapter.GetCheckInRoomCount(dDate));
            int roomType1     = Convert.ToInt32(checkInsTableAdapter.GetCkeckInRoomTypeCount(1, dDate));
            int roomType2     = Convert.ToInt32(checkInsTableAdapter.GetCkeckInRoomTypeCount(2, dDate));

            lblTotalRoom.Text = roomCount + "";
            lblUseRoom.Text   = roomUserCount + "";
            lblRoomEmtry.Text = roomCount - roomUserCount + "";

            lblUse1.Text = roomType1 + "";
            lblUse2.Text = roomType2 + "";
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (RoomID == 0)
            {
                try
                {
                    this.Validate();
                    this.ValidateChildren();

                    RoomsTableAdapter roomsTableAdapter = new RoomsTableAdapter();
                    roomsTableAdapter.Insert(
                        Convert.ToInt32(cbxRoomType.SelectedValue),
                        Convert.ToByte(cbxRoomStatus.SelectedValue),
                        tbxRoomNO.Text.Trim(),
                        tbxFlow.Text.Trim(),
                        tbxBuilding.Text.Trim());

                    MessageBox.Show("บันทึกเสร็จสมบูรณ์");
                    DialogResult = System.Windows.Forms.DialogResult.Yes;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());

                    MessageBox.Show("ไม่สามารถบันทึกได้");
                    DialogResult = System.Windows.Forms.DialogResult.No;
                    throw;
                }
            }
            else
            {
                try
                {
                    this.Validate();
                    this.ValidateChildren();
                    this.roomsBindingSource.EndEdit();
                    this.roomsTableAdapter.Update(this.apartmentDataSet.Rooms);
                    MessageBox.Show("บันทึกเสร็จสมบูรณ์");
                    DialogResult = System.Windows.Forms.DialogResult.Yes;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());

                    MessageBox.Show("ไม่สามารถบันทึกได้");
                    DialogResult = System.Windows.Forms.DialogResult.No;
                    throw;
                }
            }
        }
Example #3
0
        public UtilityUI(int pYear, int pMonth)
        {
            InitializeComponent();
            this.Year  = pYear;
            this.Month = pMonth;


            RoomsTableAdapter roomsTableAdapter = new RoomsTableAdapter();

            ApartmentDataSet.RoomsDataTable roomIDs = roomsTableAdapter.CheckRoomForUtilities(new DateTime(Year, Month, 1));

            Console.WriteLine(roomIDs.Count);
            foreach (ApartmentDataSet.RoomsRow row in roomIDs)
            {
                int y = utilitiesTableAdapter.Insert(row.RoomID, row.No, 0, 0, new DateTime(Year, Month, 1), null);
                Console.WriteLine(y);
            }
        }
Example #4
0
 public DataTable getRoom_ForDDL(int sid)
 {
     objRoom = new RoomsTableAdapter();
     return(objRoom.GetRoom_ForDDL(sid));
 }
Example #5
0
 public DataTable getBillByRoom(int room)
 {
     objRoom = new RoomsTableAdapter();
     return(objRoom.GetBillByRoom(room));
 }
Example #6
0
 public bool removeRoom(int id)
 {
     objRoom = new RoomsTableAdapter();
     return(objRoom.RemoveRoom(id) > 0);
 }
Example #7
0
 public DataTable getRoom()
 {
     objRoom = new RoomsTableAdapter();
     return(objRoom.GetRoom());
 }
Example #8
0
 public bool insertRoom(int a, DateTime b, DateTime c, int d)
 {
     objRoom = new RoomsTableAdapter();
     return(objRoom.InsertRoom(a, b, c, d) > 0);
 }
Example #9
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;
            }
        }