Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool flat = true;

            if (cb_select.SelectedIndex == 1)
            {
                if (DateTime.Compare(dpt_date_end.Value, this.end_date) > 0 && DateTime.Compare(dpt_date_end.Value, DateTime.Now) < 0)
                {
                    flat = false;
                    MessageBox.Show("Date time not Invalid!");
                    return;
                }
            }
            if (cb_select.SelectedIndex == 2)
            {
                if (DateTime.Compare(dpt_date_end.Value, this.end_date) < 0 || DateTime.Compare(dpt_date_end.Value, DateTime.Now) < 0)
                {
                    flat = false;
                    MessageBox.Show("Date time not Invalid!");
                    return;
                }
            }
            if (flat)
            {
                if (cb_select.SelectedIndex == 0)
                {
                    if (Calendar_BUS.Instance.ChangeCalendar(this.id_reservation, DateTime.Now))
                    {
                        int id_bill            = Bill_BUS.Instance.InsertBill(this.id_reservation, DTO.Session.username);
                        GUI.Bill.fCheckOut frm = new GUI.Bill.fCheckOut();
                        frm.Id_bill = id_bill;
                        this.Hide();
                        frm.ShowDialog();
                        this.Close();
                    }
                }
                else
                {
                    if (cb_select.SelectedIndex == 1)
                    {
                        if (Calendar_BUS.Instance.ChangeCalendar(this.id_reservation, dpt_date_end.Value))
                        {
                            MessageBox.Show("Change calendar is success!");
                            this.Close();
                        }
                    }
                    else
                    {
                        if (Calendar_BUS.Instance.ChangeCalendar(this.id_reservation, dpt_date_end.Value) && cb_select.SelectedIndex == 2)
                        {
                            GUI.Reservation.fDeposit frm = new fDeposit();
                            frm.Id_reservation = this.id_reservation;
                            this.Hide();
                            frm.ShowDialog();
                            this.Close();
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void btn_ok_Click(object sender, EventArgs e)
        {
            bool flat = true;

            if (int.Parse(lb_number_total_people.Text) < nud_people.Value)
            {
                MessageBox.Show("Error people in room");
                flat = false;
                return;
            }

            if (dtp_endate.Value <= DateTime.Now)
            {
                MessageBox.Show("Error End date");
                flat = false;
                return;
            }

            //if (cb_customer.SelectedIndex == -1)
            //{
            //    MessageBox.Show("You must select customer");
            //    flat = false;
            //    return;
            //}

            //if (cb_group.SelectedIndex == -1)
            //{
            //    MessageBox.Show("You must select Group");
            //    flat = false;
            //    return;
            //}

            if (flat == true)
            {
                Reservation_DTO reservation = new Reservation_DTO();
                ComboboxItem    item        = (ComboboxItem)cb_customer.SelectedItem;
                reservation.Customer.Id_customer = (int)item.Value;
                reservation.Is_group             = false;
                reservation.People         = (int)nud_people.Value;
                reservation.Staff.Username = DTO.Session.username;
                int x = Reservation_BUS.Instance.Insert_Reservation(reservation, dtp_endate.Value, this.list_room);
                if (x != 0)
                {
                    fDeposit frm = new fDeposit();
                    frm.Id_reservation = x;
                    this.Close();
                    frm.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Not insert success!");
                }
            }
            else
            {
                MessageBox.Show("Error!");
            }
        }