private void btnThanhToan_Click(object sender, EventArgs e) { try { using (var k = new AppCode.QuanCafe()) { var timhd = k.TimHoaDon(AppCode.STHoaDon.idHoaDon); timhd.TrangThai = true; timhd.GiamGia = TinhTien.giamgia; //MessageBox.Show(timhd.GiamGia.ToString()); k.SuaHD(timhd); var timban = k.TimBan(AppCode.STBan.idBan); //cap nhat timban.TrangThai = "Trống"; k.CapNhatBan(timban); txtGiamGia.Text = string.Empty; txtTamTinh.Text = string.Empty; txtTongTien.Text = string.Empty; flpDSBan.Controls.Clear(); LoadDSBan(); grvCTBanTest.DataSource = null; fThanhToan f = new fThanhToan(); f.ShowDialog(); } } catch { } }
private void btnSuaBan_Click(object sender, EventArgs e) { try { var ban = new Ban() { IDBan = Convert.ToInt32(txtMaBan.Text), TrangThai = cbbTrangThai.Text, TenBan = txtTenBan.Text, }; using (var k = new AppCode.QuanCafe()) { var kq = k.CapNhatBan(ban); if (kq == true) { LoadDSBan(); MessageBox.Show("Cập nhật thành công", "Thông báo"); } else { MessageBox.Show("Cập nhật thất bại", "Thông báo "); } } } catch { } }
//Phim tat private void fManager_KeyDown(object sender, KeyEventArgs e) { if (e.Control && e.KeyCode == Keys.F) { TimKiem(); } if (e.Control && e.KeyCode == Keys.E) { this.Close(); } if (e.Control && e.KeyCode == Keys.R) { hóaĐơnToolStripMenuItem_Click(sender, e); } if (e.Control && e.KeyCode == Keys.T) { try { using (var k = new AppCode.QuanCafe()) { var timhd = k.TimHoaDon(AppCode.STHoaDon.idHoaDon); timhd.TrangThai = true; timhd.GiamGia = TinhTien.giamgia; //MessageBox.Show(timhd.GiamGia.ToString()); k.SuaHD(timhd); var timban = k.TimBan(AppCode.STBan.idBan); timban.TrangThai = "Trống"; k.CapNhatBan(timban); flpDSBan.Controls.Clear(); LoadDSBan(); grvCTBanTest.DataSource = null; fThanhToan f = new fThanhToan(); f.ShowDialog(); } } catch { } } }
private void btnHuyBan_Click(object sender, EventArgs e) { if (MessageBox.Show("Bạn muốn hủy bàn này?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) != System.Windows.Forms.DialogResult.Cancel) { var kqtimban = XuLyDuLieu.DocDuLieu("EXEC SP_TimBan '" + AppCode.STBan.idBan + "' "); var tenban = kqtimban.Rows[0]["TenBan"].ToString(); int idban = AppCode.STBan.idBan; XuLyDuLieu.ThucThiThemXoaSua("SP_UPDATE_BAN '" + idban + "','" + tenban + "',Trống"); try { using (var k = new AppCode.QuanCafe()) { var timhd = k.TimHoaDon(AppCode.STHoaDon.idHoaDon); timhd.TrangThai = true; timhd.GiamGia = TinhTien.giamgia; //MessageBox.Show(timhd.GiamGia.ToString()); k.SuaHD(timhd); var timban = k.TimBan(AppCode.STBan.idBan); //cap nhat timban.TrangThai = "Trống"; k.CapNhatBan(timban); txtGiamGia.Text = "0"; txtTamTinh.Text = "0"; txtTongTien.Text = "0"; lblTenBan.Text = ""; grvCTBanTest.DataSource = null; } } catch { } flpDSBan.Controls.Clear(); LoadDSBan(); } }
private void btnBan_Click(object sender, EventArgs e) { int idban = ((sender as Button).Tag as Ban).IDBan; //MessageBox.Show(System.IO.Directory.GetCurrentDirectory() + @"\Image\icons8 -coffee-to-go-80.png"); AppCode.STBan.idBan = idban; try { using (var k = new AppCode.QuanCafe()) { var ban = k.TimBan(idban); //Hien thi ten ban lblTenBan.Text = ban.TenBan; if (ban.TrangThai == "Trống") { if (MessageBox.Show("Bạn muốn mỡ bàn này?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK) { (sender as Button).BackColor = Color.Red; var o = new Ban() { IDBan = idban, TenBan = ban.TenBan, TrangThai = "Có người" }; k.CapNhatBan(o); } } LoadHD(idban); LoadTongTien(); } // (sender as Button).BackColor = Color.Red; //MessageBox.Show("idban=" + ((sender as Button).Tag as Ban).IDBan.ToString()); } catch { } }
private void btnThemMon_Click_1(object sender, EventArgs e) { try { using (var k = new AppCode.QuanCafe()) { //Kiem tra trang thai ban var kqtimban = k.TimBan(AppCode.STBan.idBan); if (kqtimban.TrangThai == "Trống") { if (MessageBox.Show("Bạn muốn mỡ bàn này?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK) { var o = new Ban() { IDBan = kqtimban.IDBan, TenBan = kqtimban.TenBan, TrangThai = "Có người" }; //cap nhat trang thai ban k.CapNhatBan(o); flpDSBan.Controls.Clear(); LoadDSBan(); } else { return; } } int rowSelected = grvDSDoUongF.CurrentRow.Index; // dataGridView.Rows[rowSelected].Cells[i].Value; var hd = k.TimHoaDonTheoIDBan(AppCode.STBan.idBan); //Ban chua co hoa don if (hd == null) { MessageBox.Show("dat tao hd"); hd = new HoaDon() { TrangThai = false, NgayLap = DateTime.Now, IDNhanVienLap = AppCode.STNhanVien.idNhanVien, IDBan = AppCode.STBan.idBan, }; //var hd = new HoaDonADO( // 0, // AppCode.STBan.idBan, // DateTime.Now, // AppCode.STNhanVien.idNhanVien, // false //); var kq1 = k.ThemHoaDon(hd); AppCode.STHoaDon.idHoaDon = hd.IDHoaDon; } if (hd != null) { var cthd = new CTHoaDonADO() { IDHoaDon = hd.IDHoaDon, IDDoUong = k.TimDoUongTheoTen(grvDSDoUongF.Rows[rowSelected].Cells[0].Value.ToString()).IDDoUong, SoLuong = int.Parse(nudSoLuong.Value.ToString()), GiaGoc = k.TimDoUongTheoTen(grvDSDoUongF.Rows[rowSelected].Cells[0].Value.ToString()).GiaGoc, GiaBan = double.Parse(grvDSDoUongF.Rows[rowSelected].Cells[3].Value.ToString()) }; string sql = @"SP_GOIMON '" + cthd.IDHoaDon + "', '" + cthd.IDDoUong + "','" + cthd.SoLuong + "','" + cthd.GiaGoc + "','" + cthd.GiaBan + "' "; var gt = XuLyDuLieu.ThucThiThemXoaSua(sql); MessageBox.Show(gt.ToString()); LoadDSCTHD(hd.IDHoaDon); LoadTongTien(); LoadDSDoUong(); } } } catch { return; } }