public fViewRoom(List <BillInfoDTO> ListBillInfo, RoomDTO roominfo, int roomcode) { InitializeComponent(); RoomCode = roomcode; this.label1.Text = "Phòng " + roomcode.ToString(); if (ListBillInfo.Count != 0) { BillInfoDTO item = ListBillInfo.First(); if (item.RoomStatus1 == 1) { this.RentButton.Visible = true; } this.label13.Text = item.CustomerName1; this.label12.Text = item.CustomerType1.ToString(); this.label11.Text = item.IdentityCard1.ToString(); this.label10.Text = item.DayCheckIn1.ToString(); this.label9.Text = item.RoomType1.ToString(); this.label8.Text = item.RoomNote1; } else { if (roominfo.RoomStatus == 1) { this.RentButton.Visible = true; } this.label9.Text = roominfo.RoomStyle.ToString(); if (roominfo.RoomNote != "") { this.label8.Text = roominfo.RoomNote; } } }
public bool insertBillInfo(BillInfoDTO dto) { bool check = false; SqlConnection con = DBUtils.MakeConnection(); try { if (con != null) { string sql = "Insert BillInfo(id, idBill, nameFood, quantity) Values(@ID, @IDBill, @Food, @Quantity)"; SqlCommand cmd = new SqlCommand(sql, con); cmd.Parameters.AddWithValue("@ID", dto.Id); cmd.Parameters.AddWithValue("@IDBill", dto.IdBill); cmd.Parameters.AddWithValue("@Food", dto.NameFood); cmd.Parameters.AddWithValue("@Quantity", dto.Quantity); if (con.State == ConnectionState.Closed) { con.Open(); } check = cmd.ExecuteNonQuery() > 0; } } catch (Exception e) { throw new Exception(e.Message); } finally { con.Close(); } return(check); }
public void DeleteProduct(ProductDTO product) { BillInfoDTO billInfo = new BillInfoDTO(); BillDTO billDTO = new BillDTO(); billInfo.Tivi = product; billInfoBUS.DelNGetBill(billInfo); data.DeleteProduct(product); }
public List <BillInfoDTO> GetListBillInfor(int id) { List <BillInfoDTO> listBillInfo = new List <BillInfoDTO>(); DataTable data = DataProvider.Instance.ExecuteQuery("SELECT * FROM dbo.BillInfo WHERE idBill =" + id); foreach (DataRow item in data.Rows) { BillInfoDTO info = new BillInfoDTO(item); listBillInfo.Add(info); } return(listBillInfo); }
public List <BillInfoDTO> GetListBillInfo(int id) { List <BillInfoDTO> listBillInfo = new List <BillInfoDTO>(); DataTable data = DataProvider.Instance.ExecuteQuery("Select * From BillInfo where idBill = " + id); foreach (DataRow item in data.Rows) { BillInfoDTO info = new BillInfoDTO(item); listBillInfo.Add(info); } return(listBillInfo); }
public List <BillInfoDTO> GetListBillInfo(int roomcode) { List <BillInfoDTO> ListBillInfo = new List <BillInfoDTO>(); DataTable data = DataProvide.Instance.ExecuteQuery(GetlistBillInfoQuery + roomcode.ToString()); foreach (DataRow item in data.Rows) { BillInfoDTO info = new BillInfoDTO(item); ListBillInfo.Add(info); } return(ListBillInfo); }
public List <BillInfoDTO> GetListBillInfo(int id) { List <BillInfoDTO> billInfoDTOs = new List <BillInfoDTO>(); DataTable dataTable = DataProvider.Instance.ExcuteQuery("SELECT * FROM BillInfo WHERE IdBill = " + id); foreach (DataRow item in dataTable.Rows) { BillInfoDTO billInfoDTO = new BillInfoDTO(item); billInfoDTOs.Add(billInfoDTO); } return(billInfoDTOs); }
public int insertBillInfo(TableFoodDTO table, string food, int quantity) { bool check = false; BillBUS busBill = new BillBUS(); int idBill = busBill.getBillUnCheckoutByNameTable(table.Name); if (idBill == 0) { idBill = busBill.getMaxIDBill() + 1; DateTime currentDate = DateTime.Now; string nameTable = table.Name; string status = "Chưa thanh toán"; string staff = null; BillDTO dtoBill = new BillDTO(idBill, currentDate, nameTable, status, staff); check = busBill.insertBill(dtoBill); if (check) { int idBillInfo = dao.getMaxIDBillInfo() + 1; BillInfoDTO dtoBillInfo = new BillInfoDTO(idBillInfo, idBill, food, quantity); check = dao.insertBillInfo(dtoBillInfo); if (check) { string statusTable = "Có người"; TableFoodBUS busTable = new TableFoodBUS(); check = busTable.updateStatusTable(nameTable, statusTable); } } } else { BillInfoDTO dtoBillInfo = dao.checkExistFoodInBill(idBill, food); if (dtoBillInfo != null) { check = dao.updateQuantityBillInfo(dtoBillInfo.Id, quantity + dtoBillInfo.Quantity); } else { int idBillInfo = dao.getMaxIDBillInfo() + 1; dtoBillInfo = new BillInfoDTO(idBillInfo, idBill, food, quantity); check = dao.insertBillInfo(dtoBillInfo); } } if (!check) { idBill = -1; } return(idBill); }
public List <BillInfoDTO> GetListBillInfo(int id) { List <BillInfoDTO> listBillInfo = new List <BillInfoDTO>(); string SQL = "Select * From dbo.BillInfo Where IDBill = " + id; DataTable data = DBUtilities.Instance.ExecuteQuery(SQL); foreach (DataRow item in data.Rows) { BillInfoDTO billInfo = new BillInfoDTO(item); listBillInfo.Add(billInfo); } return(listBillInfo); }
public List <BillInfoDTO> getListBillInfo(string billID) { List <BillInfoDTO> listBillInfo = new List <BillInfoDTO>(); string sql = "SELECT billID AS [Mã đơn], proID AS [Mã sản phẩm], quantity AS [Số lượng], unitPrice AS [Đơn giá] " + "FROM tblBillInfo " + "WHERE billID = " + billID; DataTable data = DataAccess.Instance.ExecuteQuery(sql); foreach (DataRow item in data.Rows) { BillInfoDTO dto = new BillInfoDTO(item); listBillInfo.Add(dto); } return(listBillInfo); }
public void DeleteAndGetBill(BillInfoDTO billInfo) { BillDTO bill = new BillDTO(); bill.ID = billInfo.IDBill; string sql = "SELECT ID_BILL FROM BILL_INFO WHERE ID_TV = " + billInfo.Tivi.ProductId; DataTable result = DataProvider.Instance.ExecuteQuery(sql); for (int i = 0; i < result.Rows.Count; i++) { sql = "DELETE BILL_INFO WHERE ID_BILL = " + Convert.ToInt32(result.Rows[i][0]); DataProvider.Instance.ExecuteNonQuery(sql); bill.ID = Convert.ToInt32(result.Rows[i][0]); sql = "DELETE BILL_OUT WHERE ID = " + bill.ID; DataProvider.Instance.ExecuteNonQuery(sql); } }
public void Reload(List <BillInfoDTO> ListBillInfo, int roomcode) { if (ListBillInfo.Count != 0) { BillInfoDTO item = ListBillInfo.First(); if (item.RoomStatus1 == 1) { this.RentButton.Visible = true; } this.label13.Text = item.CustomerName1; this.label12.Text = item.CustomerType1.ToString(); this.label11.Text = item.IdentityCard1.ToString(); this.label10.Text = item.DayCheckIn1.ToString(); this.label9.Text = item.RoomType1.ToString(); this.label8.Text = item.RoomNote1; this.RentButton.Visible = false; } }
public BillInfoDTO checkExistFoodInBill(int idBillFind, string food) { BillInfoDTO dto = null; SqlConnection con = DBUtils.MakeConnection(); try { if (con != null) { string sql = "Select id, idBill, nameFood, quantity From BillInfo Where idBill = @IDBill and nameFood = @Food"; SqlCommand cmd = new SqlCommand(sql, con); cmd.Parameters.AddWithValue("@IDBill", idBillFind); cmd.Parameters.AddWithValue("@Food", food); if (con.State == ConnectionState.Closed) { con.Open(); } SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { if (dr.Read()) { int id = (int)dr["id"]; int idBill = (int)dr["idBill"]; string nameFood = (string)dr["nameFood"]; int quantity = (int)dr["quantity"]; dto = new BillInfoDTO(id, idBill, nameFood, quantity); } } } } catch (Exception e) { throw new Exception(e.Message); } finally { con.Close(); } return(dto); }
public fViewRoom(List <BillInfoDTO> ListBillInfo, int roomcode /*, MainMenu mainmenu*/) { InitializeComponent(); RoomCode = roomcode; this.label1.Text = "Phòng " + roomcode.ToString(); if (ListBillInfo.Count != 0) { BillInfoDTO item = ListBillInfo.First(); if (item.RoomStatus1 == 1) { this.RentButton.Visible = true; } this.label13.Text = item.CustomerName1; this.label12.Text = item.CustomerType1.ToString(); this.label11.Text = item.IdentityCard1.ToString(); this.label10.Text = item.DayCheckIn1.ToString(); this.label9.Text = item.RoomType1.ToString(); this.label8.Text = item.RoomNote1; } //mainMenu = mainmenu; }
public List <BillInfoDTO> getListBillInfoByIdBill(int idBillLoad) { List <BillInfoDTO> list = new List <BillInfoDTO>(); SqlConnection con = DBUtils.MakeConnection(); try { if (con != null) { string sql = "Select id, idBill, nameFood, quantity " + "From BillInfo Where idBill = @IdBill"; SqlCommand cmd = new SqlCommand(sql, con); cmd.Parameters.AddWithValue("@IdBill", idBillLoad); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dtTable = new DataTable(); da.Fill(dtTable); foreach (DataRow table in dtTable.Rows) { int id = (int)table["id"]; int idBill = (int)table["idBill"]; string nameFood = (string)table["nameFood"]; int quantity = (int)table["quantity"]; BillInfoDTO dto = new BillInfoDTO(id, idBill, nameFood, quantity); list.Add(dto); } } } catch (Exception e) { throw new Exception(e.Message); } finally { con.Close(); } return(list); }
public void DelNGetBill(BillInfoDTO billInfo) { data.DeleteAndGetBill(billInfo); }