Beispiel #1
0
        private void dgv_bill_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                int id_bill = (int)dgv_bill.Rows[e.RowIndex].Cells["id"].Value;
                this.id_bill = id_bill;

                Bill_DTO        bill        = Bill_BUS.Instance.GetInfoBill(id_bill);
                Reservation_DTO reservation = Reservation_BUS.Instance.GetInfoReservation(bill.Reservation.Id_reservation);

                lb_reservation.Text = bill.Reservation.Id_reservation.ToString();
                lb_customer.Text    = reservation.Customer.Name.ToString();
                lb_staff.Text       = reservation.Staff.Username.ToString();
                if (bill.Confirm == false)
                {
                    lb_confirm.Text = "Not paid";
                }
                else
                {
                    lb_confirm.Text = "Have Pay";
                }
                lb_created.Text = bill.Created.ToString();
            }
            catch
            {
                MessageBox.Show("Selected Error!");
            }
        }
Beispiel #2
0
        public static List <Bill_DTO> LayMonAn()
        {
            string QueryString = "Select * From MonAn";

            conn = DataProvider.OpenConnection();
            DataTable dt = DataProvider.LayDataTable(QueryString, conn);

            if (dt.Rows.Count == 0)
            {
                return(null);
            }

            List <Bill_DTO> lstMonAn = new List <Bill_DTO>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                Bill_DTO monAn = new Bill_DTO();

                monAn.Ma      = int.Parse(dt.Rows[i]["Ma"].ToString());
                monAn.TenMon  = dt.Rows[i]["TenMon"].ToString();
                monAn.SoLuong = int.Parse(dt.Rows[i]["SoLuong"].ToString());

                lstMonAn.Add(monAn);
            }
            DataProvider.CloseConnection(conn);
            return(lstMonAn);
        }
        public int GetUncheckBillIdByTableID(int iD)
        {
            DataTable data = DataProvider.Instace.ExcuteQuey("select * from dbo.HoaDon where id = " + iD + "and TrangThai = 1");

            if (data.Rows.Count > 0)
            {
                Bill_DTO bill = new Bill_DTO(data.Rows[0]);
                return(bill.MaHD);
            }
            return(-1);
        }
Beispiel #4
0
        void LoadDate(int id)
        {
            Bill_DTO bill = Bill_DAO.Instance.GetUncheckBillIdByDate(id);

            if (bill == null)
            {
                dtpNgayVao.Text = DateTime.Now.ToString();
                return;
            }
            dtpNgayVao.Text = bill.NgayNHD.ToString();
        }
Beispiel #5
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (billInfo.Rows.Count > 0)
     {
         Bill_DTO newBill = new Bill_DTO(Int32.Parse(gridColumn6.SummaryItem.SummaryValue.ToString()), 0, DateTime.Now);
         //Bill_DTO newBill = new Bill_DTO(Int32.Parse(tbTotal.Text), 0, DateTime.Now);
         Bill_BUS.InsertBill(newBill);
         currentIdBill = Bill_BUS.GetLastIdBill();
         //xu ly bill info
         for (int i = 0; i < billInfo.Rows.Count; i++)
         {
             int idFood = Int32.Parse(billInfo.Rows[i]["IdFood"].ToString());
             int number = Int32.Parse(billInfo.Rows[i]["Number"].ToString());
             BillDetails_BUS.InsertBillDetail(new BillDetails_DTO(currentIdBill, idFood, number));
         }
         //billInfo.Rows.Clear();
         //xu ly table of bill
         nameBill.Text = "Hóa Đơn - Bàn ";
         for (int i = 0; i < tableofbill.Rows.Count; i++)
         {
             //int status = Int32.Parse(foundRows[0]["Status"].ToString());
             int       idTable   = Int32.Parse(tableofbill.Rows[i]["IdTable"].ToString());
             DataRow[] foundRows = tablelist.Select("IdTable = " + idTable);
             foundRows[0]["Status"] = 1;
             Table_BUS.EditStatusOfTable(idTable, 1);
             BillTable_BUS.AddTableIntoBill(new BillTable_DTO(currentIdBill, idTable));
             ((Button)flowLayoutPanel1.Controls[tableofbill.Rows[i]["IdTable"].ToString()]).Image = (Image)(Properties.Resources.occupy);
             flowLayoutPanel1.Controls[tableofbill.Rows[i]["IdTable"].ToString()].BackColor       = Color.FromArgb(249, 64, 64);
             nameBill.Text += " " + flowLayoutPanel1.Controls[tableofbill.Rows[i]["IdTable"].ToString()].Text.Trim();
         }
         if (tableofbill.Rows.Count < 1)
         {
             gcBillTakeAway.DataSource = Bill_BUS.LoadBillTakeAway();
             nameBill.Text             = "Hóa Đơn - " + currentIdBill + " (Mang về)";
         }
         //tableofbill.Rows.Clear();
         btnCreateBill.Visible = true;
         //btnAddInfo.Enabled = false;
         btnCancel.Visible = false;
         //btnReduce.Enabled = false;
         btnSave.Visible      = false;
         btnPay.Enabled       = true;
         btnPrint.Enabled     = true;
         btnTeminate.Enabled  = true;
         btnMove.Enabled      = true;
         creatingBill         = false;
         refreshTable.Enabled = true;
         //tbTotal.Text = "0";
     }
     else
     {
         MessageBox.Show("Không thể lập hóa đơn trống");
     }
 }
Beispiel #6
0
        private void Load_Room_Using()
        {
            Bill_DTO bill = Bill_BUS.Instance.GetInfoBill(this.id_bill);
            List <Reservation_room_DTO> list_room = Reservation_room_BUS.Instance.Get_ListReservation_Using(bill.Reservation.Id_reservation);

            foreach (Reservation_room_DTO reservation_room in list_room)
            {
                ListViewItem item = new ListViewItem(((reservation_room.Room.Num_floor * 100) + reservation_room.Room.Num_order).ToString());
                item.SubItems.Add(((double)reservation_room.Room.Kind_of_room.Price * xmod_room).ToString());
                item.SubItems.Add("Using");
                lv_room.Items.Add(item);
            }

            List <Log_swap_room_DTO> list_room_cancel = Log_swap_room_BUS.Instance.ListRoomCancel(bill.Reservation.Id_reservation);

            foreach (Log_swap_room_DTO reservation_room in list_room_cancel)
            {
                Calendar_DTO calendar = Calendar_BUS.Instance.GetCalendarReservationUsing(bill.Reservation.Id_reservation);
                Room_DTO     room     = Room_BUS.Instance.Get_Info_Room(reservation_room.Reservation_room.Room.Id_room);

                double xmod_room_cancel = 0;

                TimeSpan interval = calendar.Start_date.Subtract(reservation_room.Created);
                if (interval.Days < 1)
                {
                    if (interval.Hours < 2)
                    {
                        xmod_room_cancel = 0.25;
                    }
                    else if (interval.Hours < 6)
                    {
                        xmod_room_cancel = 0.5;
                    }
                    else
                    {
                        xmod_room_cancel = 1;
                    }
                }
                else
                {
                    if (interval.Hours > 6)
                    {
                        xmod_room_cancel = interval.Days + 0.5;
                    }
                }

                ListViewItem item = new ListViewItem(((room.Num_floor * 100) + room.Num_order).ToString());
                item.SubItems.Add(((double)room.Kind_of_room.Price * xmod_room_cancel).ToString());
                item.SubItems.Add("Cancel");
                lv_room.Items.Add(item);
            }
        }
Beispiel #7
0
        void ShowDateBill()
        {
            HoaDonKhachHang_DTO HoaDon = lsvHoaDon.Tag as HoaDonKhachHang_DTO;

            if (HoaDon != null)
            {
                Bill_DTO bill = Bill_DAO.Instance.GetUncheckBillIdByDate(HoaDon.ID);
                dtpNgayVao.Text = bill.NgayNHD.ToString();
            }
            else
            {
                return;
            }
        }
Beispiel #8
0
        private void LoadData()
        {
            Bill_DTO                    bill                  = Bill_BUS.Instance.GetInfoBill(this.id_bill);
            Reservation_DTO             reservation           = Reservation_BUS.Instance.GetInfoReservation(bill.Reservation.Id_reservation);
            Calendar_DTO                calendar              = Calendar_BUS.Instance.GetCalendarReservationUsing(bill.Reservation.Id_reservation);
            Deposit_DTO                 deposit               = Deposit_BUS.Instance.GetInfoDepositUsing(bill.Reservation.Id_reservation);
            List <Reservation_room_DTO> list_reservation_room = Reservation_room_BUS.Instance.Get_ListReservation_Using(bill.Reservation.Id_reservation);
            List <Service_ticket_DTO>   list_service_ticket   = Service_ticket_BUS.Instance.Get_ListServiceReservation(bill.Reservation.Id_reservation);

            lb_reservation.Text = bill.Reservation.Id_reservation.ToString();
            lb_customer.Text    = reservation.Customer.Name.ToString();
            lb_group.Text       = reservation.Is_group.ToString();
            lb_peopel.Text      = reservation.People.ToString();
            lb_start_date.Text  = calendar.Start_date.ToString();
            lb_end_date.Text    = calendar.End_date.ToString();

            System.Globalization.CultureInfo cul = new System.Globalization.CultureInfo("vi-VN");
            double total_room = Get_Money_Room(list_reservation_room, calendar) + this.Get_Money_Cancel_Room(bill.Reservation.Id_reservation);

            lb_total_room.Text = total_room.ToString("c", cul);

            double total_service = Get_Money_Service(list_service_ticket);

            lb_total_service.Text = total_service.ToString("c", cul);

            this.total_money    = total_room + total_service;
            lb_total_money.Text = this.total_money.ToString("c", cul);


            lb_deposit.Text = deposit.Deposit.ToString("c", cul);
            this.deposit    = deposit.Deposit;

            lb_staff.Text = bill.Staff.Username.ToString();

            lb_rest.Text = (this.total_money - this.deposit).ToString("c", cul);

            Load_Room_Using();
            Load_Service_Using();

            if (Bill_BUS.Instance.CheckConfirmBill(this.id_bill) == true)
            {
                cb_confirm.SelectedIndex = 1;
            }
            else
            {
                cb_confirm.SelectedIndex = 0;
            }
        }
Beispiel #9
0
        public static void InsertBill(Bill_DTO Bill)
        {
            SqlConnection cnn = ConnectToSQL.Connect();
            SqlCommand    cmd = new SqlCommand("AddBill", cnn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@Total", SqlDbType.Int);
            cmd.Parameters["@Total"].Value = Bill.Total;
            cmd.Parameters.Add("@Status", SqlDbType.Int);
            cmd.Parameters["@Status"].Value = Bill.Status;
            cmd.Parameters.Add("@Date", SqlDbType.Date);
            cmd.Parameters["@Date"].Value = Bill.Date.ToShortDateString();
            cnn.Open();
            cmd.ExecuteNonQuery();
            cnn.Close();
        }
Beispiel #10
0
        private void Load_Service_Using()
        {
            Bill_DTO bill = Bill_BUS.Instance.GetInfoBill(this.id_bill);
            List <Service_ticket_DTO> list_service_by_reservation = Service_ticket_BUS.Instance.Get_ListServiceReservation(bill.Reservation.Id_reservation);

            foreach (Service_ticket_DTO service_by_reservation in list_service_by_reservation)
            {
                ListViewItem item = new ListViewItem(service_by_reservation.Service.Id_service.ToString());
                item.SubItems.Add(service_by_reservation.Service.Name_service.ToString());
                item.SubItems.Add(service_by_reservation.Service.Price.ToString());
                item.SubItems.Add(service_by_reservation.Number.ToString());
                Room_DTO room = Room_BUS.Instance.Get_Info_Room(service_by_reservation.Reservation_room.Room.Id_room);
                item.SubItems.Add(((room.Num_floor * 100) + room.Num_order).ToString());
                lv_service.Items.Add(item);
            }
        }
Beispiel #11
0

        
Beispiel #12
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (CheckInvalidMonth(Convert.ToInt32(Thang.Text), Convert.ToInt32(Nam.Text)) == false)
            {
                MessageBox.Show("Hiện chưa có dữ liệu của tháng đã chọn hoặc tháng được chọn là không đúng");
            }
            else
            {
                DataTable data = new DataTable();
                first    = "1/" + Thang.Text + "/" + Nam.Text;
                last     = GetLastDayOfMonth(Convert.ToInt32(Thang.Text), Convert.ToInt32(Nam.Text)).ToString() + "/" + Thang.Text + "/" + Nam.Text;
                firstDay = Convert.ToDateTime(first);
                lastDay  = Convert.ToDateTime(last);

                data = Bill_BUS.FindBillByDate(firstDay, lastDay);
                //data = Bill_BUS.LoadAllBill();
                Report report = new Report();

                List <Bill_DTO> billList = new List <Bill_DTO>();
                for (int i = 0; i < data.Rows.Count; i++)
                {
                    Bill_DTO bill = new Bill_DTO();
                    bill.Id    = Convert.ToInt32(data.Rows[i]["IdBill"]);
                    bill.Date  = DateTime.Parse(data.Rows[i]["Date"].ToString());
                    bill.Total = Convert.ToInt32(data.Rows[i]["TotalPrice"]);
                    billList.Add(bill);
                }
                report.lbNgayLap.Text  = current.Day.ToString() + "/" + current.Month.ToString() + "/" + current.Year.ToString();
                report.lbthang.Text    = Thang.Text + "/" + Nam.Text;
                report.lbCountID.Text  = data.Rows.Count.ToString();
                report.lbSumPrice.Text = data.Compute("Sum(TotalPrice)", "").ToString() + " VNĐ";
                report.lbntn.Text      = "ngày " + current.Day.ToString() + " tháng " + current.Month.ToString() + " năm " + current.Year.ToString() + ".";
                try
                {
                    report.DataSource = billList;
                    ReportPrintTool tool = new ReportPrintTool(report);
                    tool.ShowPreview();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Beispiel #13
0

        
Beispiel #14
0
 public static void InsertBill(Bill_DTO bill)
 {
     Bill_DAO.InsertBill(bill);
 }