Пример #1
0
        private void btnPay_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are you sure you want to pay?", "Pay Notification", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                myButton btn = sender as myButton;
                if (orderBLL.SetPaid(TabID) == true)
                {
                    if (tableBLL.ChangeTableStatus(TabID, false, true, false) == true)
                    {
                        MessageBox.Show("You have paid sucessfully !");
                        mainform.loadUCTable();
                    }
                    else
                    {
                        MessageBox.Show("Cannot process. Please try again");
                    }
                }
                else
                {
                    MessageBox.Show("Cannot process. Please try again");
                }
            }
        }
Пример #2
0
        private void btnCancel_Click(object sender, EventArgs e)
        {
            DialogResult dialog = MessageBox.Show("Are you sure you want to cancel?", "Cancel Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);

            if (dialog == DialogResult.OK)  //click ok thì chuyển lại form đầu.
            {
                mainform.loadUCTable();
            }
        }
Пример #3
0
        private void btnSave_Click_1(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are you sure you want to save?", "Save Notification", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                //yes...
                bool Check = false;
                OrdID = (orderBLL.AddOrder(orDer, lsOrderDetail));
                if (OrdID != -1)
                {
                    if (tableBLL.ChangeTableStatus(TabID, true, false, false) == true)
                    {
                        Table table = tableBLL.FindTableById(TabID);
                        if (table.Status == 1)
                        {
                            // Bàn này đang được order và khách đến và order
                            CustomerBLL customerBLL = new CustomerBLL();
                            if (customerBLL.DeleteCustomer(CusID) == true)
                            {
                                Check = true;
                            }
                        }
                        else
                        {
                            Check = true;
                        }
                    }
                }
                if (Check == true)
                {
                    MessageBox.Show("Saved sucessfully");
                    orDer.OrderID = OrdID;
                    mainform.loadUCTable();
                }
                else
                {
                    MessageBox.Show("Cannot save. Please try again!");
                }
            }
        }
Пример #4
0
        private void btnBook_Click_1(object sender, EventArgs e)
        {
            if (chbMember.Checked == true)
            {
                // Đã đến trước đó rồi => Đã có trong cơ sở dữ liệu
                if (String.IsNullOrEmpty(txtName.Text) || String.IsNullOrEmpty(dtpTime.Text))
                {
                    MessageBox.Show("Please insert fully information");
                }
                else
                {
                    // Add Booking Tables
                    // Sau khi Add xong thì getCustomerID
                    Customer customer = customerBLL.SearchCustomerByName(txtName.Text);
                    if (customer != null)
                    {
                        int CustomerID = customerBLL.GetCustomerID(customer);
                        if (CustomerID != -1)
                        {
                            // Tính ExpireTime
                            DateTime ExpireTime = dtpTime.Value.AddHours(1);
                            // Tạo BookingTable
                            BookingTable bookingTable = new BookingTable();
                            bookingTable.BookingDate = dtpTime.Value;
                            bookingTable.CustomerID  = CustomerID;
                            bookingTable.ExpiredTime = ExpireTime;
                            bookingTable.TableID     = TabID;

                            // Add xuống DB
                            if (bookingTableBLL.AddBookingTable(bookingTable) == true)
                            {
                                if (tableBLL.ChangeTableStatus(TabID, false, false, true) == true)
                                {
                                    MessageBox.Show("Booked sucessfully");
                                    this.Hide();
                                    mainform.loadUCTable();
                                }
                            }
                            else
                            {
                                MessageBox.Show("Cannot book. Please try again ><");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Cannot book. Please try again ><");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Cannot book. Please try again ><");
                    }
                }
            }
            else
            {
                // Chưa đến lần nào => Phải tạo Customer mới
                if (String.IsNullOrEmpty(txtName.Text) || String.IsNullOrEmpty(txtPhone.Text) ||
                    String.IsNullOrEmpty(dtpTime.Text) || String.IsNullOrEmpty(txtCMND.Text) ||
                    String.IsNullOrEmpty(cbGender.Text))
                {
                    MessageBox.Show("Please insert fully information");
                }
                else
                {
                    // Add new Customer
                    Customer customer = new Customer();
                    customer.Name        = txtName.Text;
                    customer.PhoneNumber = txtPhone.Text;
                    customer.IsFemale    = (cbGender.Text == "Female") ? true : false;
                    customer.CMND        = txtCMND.Text;

                    // Dùng hàm Add
                    if (customerBLL.AddCustomer(customer) == true)
                    {
                        // Sau khi Add xong thì getCustomerID
                        int CustomerID = customerBLL.GetCustomerID(customer);
                        if (CustomerID != -1)
                        {
                            // Tính ExpireTime
                            DateTime ExpireTime = dtpTime.Value.AddHours(1);
                            // Tạo BookingTable
                            BookingTable bookingTable = new BookingTable();
                            bookingTable.BookingDate = dtpTime.Value;
                            bookingTable.CustomerID  = CustomerID;
                            bookingTable.ExpiredTime = ExpireTime;
                            bookingTable.TableID     = TabID;

                            // Add xuống DB
                            if (bookingTableBLL.AddBookingTable(bookingTable) == true)
                            {
                                if (tableBLL.ChangeTableStatus(TabID, false, false, true) == true)
                                {
                                    MessageBox.Show("Booking thành công");
                                    this.Hide();
                                }
                                else
                                {
                                    MessageBox.Show("Không thành công. Vui lòng thử lại");
                                }
                            }
                            else
                            {
                                MessageBox.Show("Không thành công. Vui lòng thử lại");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Không thành công. Vui lòng thử lại");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Không thành công. Vui lòng thử lại");
                    }
                }
            }
        }