private void dtThongKe_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex > -1) { if (check == 3) { Form_Report report = new Form_Report(dtThongKe.Rows[e.RowIndex].Cells[0].Value.ToString(), dtThongKe.Rows[e.RowIndex].Cells[3].Value.ToString(), dtThongKe.Rows[e.RowIndex].Cells[2].Value.ToString()); report.Show(); } } }
private void btnThanhToan_Click(object sender, EventArgs e) { if (lvSanPhamBan.Items.Count > 0) { DTO_HoaDon hoaDon = new DTO_HoaDon(); hoaDon.MaHD = BUS_HoaDon.Intance.LoadMaDHMoi(); hoaDon.MaKH = khachHang.MaKH; DateTime oDate = DateTime.Now; hoaDon.NgayTao = oDate; hoaDon.TenDangNhap = Form1.tk; hoaDon.TongTien = tongTien; if (BUS_HoaDon.Intance.LuuDonHang(hoaDon)) { Form_Report rp = new Form_Report(hoaDon.MaHD, BUS_ConvertMoney.Instance.chuyenDoi(tongTien), txtTenKH.Text); foreach (ListViewItem item in lvSanPhamBan.Items) { BUS_ChiTietHD.Intance.LuuDonHang(hoaDon.MaHD, item.SubItems[0].Text, Int32.Parse(item.SubItems[2].Text), Int32.Parse(item.SubItems[3].Text) / Int32.Parse(item.SubItems[2].Text)); string query = "update hanghoa set SoLuong = SoLuong - " + Int32.Parse(item.SubItems[2].Text) + "where MaHang ='" + item.SubItems[0].Text + "'"; DataProvider.Instance.ExecuteNonQuery(query); } lvSanPhamBan.Items.Clear(); lbTienBangSo.Text = "0 VNĐ"; lbTienBangChu.Text = "Không đồng"; txtInPutNumberPhone.Text = ""; khachHang.MaKH = null; txtTenKH.Text = "UNKNOW NAME"; tongTien = 0; rp.ShowDialog(); } } else { MessageBox.Show("Bạn chưa chọn sản phẩm nào!", "Thông báo"); } }