private void paymentEvent(Object sender, EventArgs e, string billId, string tableId) { billDTO dto = new billDTO(); dto.billId = billId; billBO bo = new billBO(); int result = bo.paymentForBill(dto); if (result != -1) { tableDTO tabledto = new tableDTO(); tabledto.tableID = tableId; tabledto.status = "FREE"; tableBO tablebo = new tableBO(); int result2 = -1; result2 = tablebo.setTableStatus(tabledto); if (result2 != -1) { MessageBox.Show("Thanh toán thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); Table_Form form = new Table_Form(); form.userlogin = userlogin; this.Hide(); form.ShowDialog(); this.Close(); } else { MessageBox.Show("Lỗi khi thay đổi trạng thái bàn", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Thanh toán thất bại, vui lòng kiểm tra lại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void loadingBillByTableId() { billDTO dto = new billDTO(); dto.tableId = tableId; dto.status = "USING"; billBO bo = new billBO(); DataSet result = bo.getBillInfoByTableId(dto); txt_NumberBill.Text = result.Tables[0].Rows[0][0].ToString().Trim(); ordinal = int.Parse(result.Tables[0].Rows[result.Tables[0].Rows.Count - 1][1].ToString()); // ordinal = loadingGridView(); }
private void btn_CancelBill_Click(object sender, EventArgs e) { if (dgv_BillDetails.Rows.Count == 0) { MessageBox.Show("Không có món nào trong hóa đơn, vui lòng thử lại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (userlogin.POSITION == "QUANLY" || userlogin.POSITION == "THUNGAN") { DialogResult dialog = MessageBox.Show("Bạn có muốn cancel Bill này chứ ?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialog == DialogResult.Yes) { billDTO dto = new billDTO(); dto.billId = txt_NumberBill.Text; billBO bo = new billBO(); int result = bo.cancelBill(dto); if (result != -1) { tableDTO tabledto = new tableDTO(); tabledto.tableID = tableId; tabledto.status = "FREE"; tableBO tablebo = new tableBO(); int result1 = tablebo.setTableStatus(tabledto); if (result1 != -1) { MessageBox.Show("Đã cancel Bill !!!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); Table_Form form = new Table_Form(); form.userlogin = userlogin; this.Hide(); form.ShowDialog(); this.Close(); } else { MessageBox.Show("Lỗi khi thay đổi trạng thái bàn", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Đã có lỗi xảy ra, vui lòng kiểm tra lại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MessageBox.Show("Bạn không có quyền này", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public int paymentForBill(billDTO dto) { int result = -1; string query = @"UPDATE Bill SET Status = 'Done' WHERE BillId = @BillId"; SqlParameter[] para = new SqlParameter[] { new SqlParameter("@BillId", dto.billId) }; DataAccess data = new DataAccess(); result = data.Execute(query, para); return(result); }
public DataSet getFoodByFoodId(billDTO dto) { DataSet result = new DataSet(); string query = @"SELECT FoodName, FoodPrice FROM Food WHERE FoodId = @FoodId"; SqlParameter[] para = new SqlParameter[] { new SqlParameter("@FoodId", dto.foodId) }; DataAccess data = new DataAccess(); result = data.GetDataSet(query, para); return(result); }
public DataSet getBillInfoByTableId(billDTO dto) { DataSet result = new DataSet(); string query = @"SELECT * FROM Bill WHERE TableId = @TableId AND Status = @Status"; SqlParameter[] para = new SqlParameter[] { new SqlParameter("@TableId", dto.tableId), new SqlParameter("@Status", dto.status), }; DataAccess data = new DataAccess(); result = data.GetDataSet(query, para); return(result); }
public DataSet getBillInfoByBillId(billDTO dto) { DataSet result = new DataSet(); string query = @"SELECT * FROM Bill WHERE BillId = @BillId"; SqlParameter[] para = new SqlParameter[] { new SqlParameter("@BillId", dto.billId), }; DataAccess data = new DataAccess(); result = data.GetDataSet(query, para); return(result); }
public int deleteSingleFoodByBillIdAndOrdinalNumber(billDTO dto) { int result = -1; string query = @"DELETE FROM Bill WHERE BillId = @BillId AND OrdinalNumber = @OrdinalNumber"; SqlParameter[] para = new SqlParameter[] { new SqlParameter("@BillId", dto.billId), new SqlParameter("@OrdinalNumber", dto.ordinalNumber), }; DataAccess data = new DataAccess(); result = data.Execute(query, para); return(result); }
private void loadingGridView() { total = 0; billDTO dto = new billDTO(); dto.billId = txt_NumberBill.Text; DataSet result = new DataSet(); billBO billbo = new billBO(); result = billbo.getBillInfoByBillId(dto); dgv_BillDetails.DataSource = result.Tables[0]; for (int i = 0; i < result.Tables[0].Rows.Count; i++) { total = total + (int.Parse(result.Tables[0].Rows[i][4].ToString()) * int.Parse(result.Tables[0].Rows[i][5].ToString())); } txt_Total.Text = String.Format("{0:n0}", total); }
private void addFood(Object sender, EventArgs e, string foodId, int foodPrice) { billDTO dto = new billDTO(); //create tempcartid dto.billId = txt_NumberBill.Text; dto.tableId = tableId; dto.username = userlogin.USERNAME; //update ordinal number ordinal = ordinal + 1; dto.ordinalNumber = ordinal; dto.foodId = foodId; dto.cost = foodPrice; dto.quantity = quantity; dto.date = DateTime.Now; dto.status = "USING"; //set table status tableDTO table = new tableDTO(); table.status = "USING"; table.tableID = tableId; tableBO tablebo = new tableBO(); tablebo.setTableStatus(table); // billBO billbo = new billBO(); int result = billbo.addFood(dto); quantity = 1; if (result != -1) { loadingGridView(); } else { MessageBox.Show("Đã có lỗi xảy ra, vui lòng kiểm tra lại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public int addFood(billDTO dto) { int result = -1; string query = @"INSERT INTO Bill VALUES(@BillId, @OrdinalNumber, @FoodId,@Username, @Quantity, @Cost, @TableId, @Date, @Status)"; SqlParameter[] para = new SqlParameter[] { new SqlParameter("@BillId", dto.billId), new SqlParameter("@OrdinalNumber", dto.ordinalNumber), new SqlParameter("@FoodId", dto.foodId), new SqlParameter("@Username", dto.username), new SqlParameter("@Quantity", dto.quantity), new SqlParameter("@Cost", dto.cost), new SqlParameter("@TableId", dto.tableId), new SqlParameter("@Date", dto.date), new SqlParameter("@Status", dto.status), }; DataAccess data = new DataAccess(); result = data.Execute(query, para); return(result); }
private void bnt_DeleteFoodDetail_Click(object sender, EventArgs e) { if (dgv_BillDetails.Rows.Count == 0) { MessageBox.Show("Hiện không còn món nào", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (dgv_BillDetails.Rows.Count == 1) { tableDTO tabledto = new tableDTO(); tabledto.tableID = tableId; tabledto.status = "FREE"; tableBO tablebo = new tableBO(); int result1 = tablebo.setTableStatus(tabledto); if (result1 != -1) { } else { MessageBox.Show("Lỗi khi thay đổi trạng thái bàn", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } billDTO dto = new billDTO(); dto.billId = txt_NumberBill.Text; dto.ordinalNumber = int.Parse(dgv_BillDetails.CurrentRow.Cells["OrdinalNumber"].Value.ToString()); billBO bo = new billBO(); int result = bo.deleteSingleFoodByBillIdAndOrdinalNumber(dto); if (result != -1) { loadingGridView(); } else { MessageBox.Show("Có lỗi xảy ra ,Vui lòng thử lại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void loadingBillDetails() { lb_NAME.Text = userlogin.NAME; lb_BillId.Text = billid; billDTO dto = new billDTO(); dto.billId = billid; billBO bo = new billBO(); DataSet result = new DataSet(); result = bo.getBillInfoByBillId(dto); string tableId = ""; // Point initPoint = new Point(0, 0); if (result.Tables.Count > 0 && result.Tables[0].Rows.Count > 0) { for (int i = 0; i < result.Tables[0].Rows.Count; i++) { foodDTO fooddto = new foodDTO(); fooddto.foodId = result.Tables[0].Rows[i][2].ToString(); foodBO foodbo = new foodBO(); DataSet foodTable = new DataSet(); foodTable = foodbo.getFoodByFoodId(fooddto); BillInfo info = new BillInfo(); info.FOODNAME = foodTable.Tables[0].Rows[0][0].ToString(); info.FOODPRICE = int.Parse(result.Tables[0].Rows[i][5].ToString()); info.QUANTITY = int.Parse(result.Tables[0].Rows[i][4].ToString()); int y = 50 * i; info.Location = new Point(0, y); this.pl_BillDetals.Controls.Add(info); } tableId = result.Tables[0].Rows[0][6].ToString().Trim(); Label lb_characters = new Label(); Label lb_TotalText = new Label(); Label lb_Total = new Label(); lb_characters.Text = "--------------------------------------------------------------------------"; lb_characters.Font = new Font("Times New Roman", 11.0f, FontStyle.Bold); lb_characters.Location = new Point(32, pl_BillDetals.Location.Y + pl_BillDetals.Size.Height + 20); lb_characters.AutoSize = true; this.Controls.Add(lb_characters); lb_TotalText.Text = "Tổng cộng:"; lb_TotalText.Font = new Font("Times New Roman", 15.0f, FontStyle.Bold); lb_TotalText.Location = new Point(210, lb_characters.Location.Y + 20); lb_TotalText.AutoSize = true; this.Controls.Add(lb_TotalText); lb_Total.Text = String.Format("{0:n0}", total); lb_Total.Font = new Font("Times New Roman", 15.0f, FontStyle.Bold); lb_Total.Location = new Point(310, lb_TotalText.Location.Y); lb_Total.AutoSize = true; this.Controls.Add(lb_Total); //Payment Button Button btn_Payment = new Button(); btn_Payment.Text = "Thanh toán"; btn_Payment.Font = new Font("Times New Roman", 15.0f, FontStyle.Bold); btn_Payment.Location = new Point(32, lb_TotalText.Location.Y - 10); btn_Payment.Size = new Size(150, 50); //btn_Payment.AutoSize = true; btn_Payment.BackColor = Color.Blue; this.Controls.Add(btn_Payment); //Handle Button Payment click btn_Payment.Click += (sender, e) => { if (userlogin.POSITION == "QUANLY" || userlogin.POSITION == "THUNGAN") { paymentEvent(sender, e, billid, tableId); } else { MessageBox.Show("Bạn không có quyền này", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }; } }