private void btXoa_Click_1(object sender, EventArgs e) { if (dgvDSHoaDon.SelectedRows.Count > 0) { DataRow cn = ((DataRowView)dgvDSHoaDon.SelectedRows[0].DataBoundItem).Row; DialogResult dr = MessageBox.Show("Anh/Chị có muốn xóa món " + cn["TenMonAn"] + " khong?", "Thong bao", MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { cn.Delete(); //XuLyDuLieu.ghiBang("Rong", ThongTinHoaDon); } float thanhtien = 0; float tongtien = 0; for (int i = 0; i < dgvDSHoaDon.Rows.Count; i++) { thanhtien = float.Parse(dgvDSHoaDon.Rows[i].Cells["Gia"].Value.ToString()) * int.Parse(dgvDSHoaDon.Rows[i].Cells["SoLuong"].Value.ToString()); tongtien += thanhtien; } tbTongTien.Text = tongtien.ToString(); giamgia = tongtien; tien = tongtien; tien = tien + (tien * 10 / 100); tbThanhTien.Text = tien.ToString(); XuLyDuLieu.ghiBang("Rong", ThongTinHoaDon); } else { MessageBox.Show("Anh/Chị chưa chọn tên món ăn.", "Thong bao", MessageBoxButtons.OK); } }
private void bttthemonan_Click(object sender, EventArgs e) { DataRow cn = dsMonAn.NewRow(); //cn["Mama"] = tbMaCN.Text; //cn["CNTen"] = tbTenChiNhanh.Text; //cn["CNDienThoai"] = tbDienThoaiChiNhanh.Text; //cn["CNDiaChi"] = tbDiaChiChiNhanh.Text; //dsChiNhanh.Rows.Add(cn); XuLyDuLieu.ghiBang("ChiNhanh", dsChiNhanh); }
private void button3_Click_1(object sender, EventArgs e) { DataRow kh = dsKhachHang.NewRow(); kh["MaKH"] = tbidkhachhang.Text; kh["TenKH"] = tbtenkhachhang.Text; kh["SdtKH"] = tbsdtkhachhang.Text; kh["DiaChiKH"] = tbdiachikhachhang.Text; dsKhachHang.Rows.Add(kh); XuLyDuLieu.ghiBang("KhachHang", dsKhachHang); }
private void btBot_Click(object sender, EventArgs e) { int i; int chiso; if (dgvDSHoaDon.SelectedRows.Count > 0) { for (i = 0; i < dgvDSHoaDon.SelectedRows.Count; i++) { DataRow ma = ThongTinHoaDon.Rows[dgvDSHoaDon.SelectedRows[i].Index]; chiso = TimMATrongDSDHMA(((string)ma["TenMonAn"])); if (chiso != -1) { int t = (int)ThongTinHoaDon.Rows[chiso]["SoLuong"]; if (t > 1) { ThongTinHoaDon.Rows[chiso]["SoLuong"] = (int)ThongTinHoaDon.Rows[chiso]["SoLuong"] - 1; } else { //ThongTinHoaDon.Rows.RemoveAt(chiso); ma.Delete(); } } } } else { MessageBox.Show("Không Còn Món Để Bớt.", "Thong bao", MessageBoxButtons.OK); } float thanhtien = 0; float tongtien = 0; for (i = 0; i < dgvDSHoaDon.Rows.Count; i++) { thanhtien = float.Parse(dgvDSHoaDon.Rows[i].Cells["Gia"].Value.ToString()) * int.Parse(dgvDSHoaDon.Rows[i].Cells["SoLuong"].Value.ToString()); tongtien += thanhtien; } tbTongTien.Text = tongtien.ToString(); giamgia = tongtien; tien = tongtien; tien = tien + (tien * 10 / 100); tbThanhTien.Text = tien.ToString(); XuLyDuLieu.ghiBang("Rong", ThongTinHoaDon); }
private void btThem_Click_1(object sender, EventArgs e) { int i; if (dgvDSMonAn.SelectedRows.Count > 0) { for (i = 0; i < dgvDSMonAn.SelectedRows.Count; i++) { DataRow ma = ThongTinMonAn.Rows[dgvDSMonAn.SelectedRows[i].Index]; int chiso = TimMATrongDSDHMA(((string)ma["TenMA"])); if (chiso == -1) { DataRow dhma = ThongTinHoaDon.NewRow(); dhma["MaMonAn"] = ma["MaMA"]; dhma["TenMonAn"] = ma["TenMA"]; dhma["LoaiMonAn"] = ma["TenLoaiMA"]; dhma["SoLuong"] = 1; dhma["Gia"] = ma["DonGia"]; ThongTinHoaDon.Rows.Add(dhma); } else { ThongTinHoaDon.Rows[chiso]["SoLuong"] = (int)ThongTinHoaDon.Rows[chiso]["SoLuong"] + 1; } float thanhtien = 0; float tongtien = 0; for (i = 0; i < dgvDSHoaDon.Rows.Count; i++) { thanhtien = float.Parse(dgvDSHoaDon.Rows[i].Cells["Gia"].Value.ToString()) * int.Parse(dgvDSHoaDon.Rows[i].Cells["SoLuong"].Value.ToString()); tongtien += thanhtien; } tbTongTien.Text = tongtien.ToString(); giamgia = tongtien; tien = tongtien; tien = tien + (tien * 10 / 100); tbThanhTien.Text = tien.ToString(); } } else { MessageBox.Show("Anh/Chị chưa chọn món ăn", "Thong bao"); } XuLyDuLieu.ghiBang("Rong", ThongTinHoaDon); }
private void btXacNhanHD_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(tbKhachHang.Text) || string.IsNullOrEmpty(tbSDT.Text)) { MessageBox.Show("Anh/Chị chưa nhập đủ thông tin"); } else { DataRow cn = ((DataRowView)dgvChiNhanh.SelectedRows[0].DataBoundItem).Row; DataRow dhma = LichSu.NewRow(); dhma["TenCN"] = cn["TenCN"]; dhma["TenKH"] = tbKhachHang.Text; dhma["DiaChi"] = tbbDiaChi.Text; dhma["SDT"] = tbSDT.Text; dhma["ThoiGian"] = dtpNgayTao.Text; dhma["TongTien"] = tbThanhTien.Text; LichSu.Rows.Add(dhma); XuLyDuLieu.ghiBang("LichSuMua", LichSu); MessageBox.Show("Giao dịch thành công"); } }