private void bt_sale_add_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("Xác nhận thêm vào hóa đơn", "Thông báo", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { int Dongia = Int32.Parse(tb_dongia.Text); int Amount = Int32.Parse(nud_amount.Value.ToString()); int Total = Dongia * Amount; //tb_billID.Text = pBUS.ExecuteQr("SELECT ID_HD FROM BILL_TEMP ORDER BY ID_HD DESC").ToString(); pBUS.UpdateData("UPDATE KHOVATTU SET Soluong = Soluong - " + Amount + " WHERE ID_vatTu = '" + cbb_idmate.SelectedItem.ToString() + "'"); pBUS.InsertData("INSERT INTO CT_BILL_TEMP VALUES ('" + tb_cthd_idbill.Text + "','" + cbb_idmate.SelectedItem.ToString() + "','" + Amount + "','" + Dongia + "','" + Total + "')"); tb_total.Text = pBUS.ExecuteQr("SELECT SUM(ThanhTien) FROM CT_BILL_TEMP WHERE ID_HD = '" + tb_billID.Text + "'").ToString(); tb_namemate.Text = pBUS.ExecuteQr("SELECT TenSanPham FROM VATTU WHERE ID_vatTu = '" + cbb_idmate.SelectedItem.ToString() + "'").ToString(); tb_inven.Text = pBUS.ExecuteQr("SELECT SoLuong FROM KHOVATTU WHERE ID_vatTu = '" + cbb_idmate.SelectedItem.ToString() + "'").ToString(); tb_unit.Text = pBUS.ExecuteQr("SELECT DonViTinh FROM VATTU WHERE ID_vatTu = '" + cbb_idmate.SelectedItem.ToString() + "'").ToString(); tb_dongia.Text = pBUS.ExecuteQr("SELECT GiaBan FROM VATTU WHERE ID_vatTu = '" + cbb_idmate.SelectedItem.ToString() + "'").ToString(); dgv_cthd.DataSource = dgv_listbill.DataSource = pBUS.LoadDataS("SELECT * FROM CT_BILL_TEMP WHERE ID_HD = '" + tb_cthd_idbill.Text + "'").Tables[0]; dgv_cthd.Columns[0].Width = 200; dgv_cthd.Columns[1].Width = 200; dgv_cthd.Columns[2].Width = 100; dgv_cthd.Columns[3].Width = 350; dgv_cthd.Columns[4].Width = 200; } else if (result == DialogResult.No) { // khong co lam gi o day het :( } }