private void btnXoa_Click(object sender, EventArgs e) { if (txtMaSach.Text == "") { return; } if (MessageBox.Show("Bạn có chắc muốn xoá sách này ra khỏi phiếu nhập?", "Thông báo", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK) { CTPhieuNhapBUS.DeleteCTPhieuNhap(txtMaPN.Text, txtMaSach.Text); MessageBox.Show("Xoá thành công!"); UpdateTongTien_Xoa_Sua(); UpdateSoLuongTon_Xoa_Sua(); loadCTPN(); } }
void InsertCT() { if (txtMaPN.Text == "" || txtMaSach.Text == "" || txtDonGia.Text == "" || txtSLnhap.Text == "" || txtTongTien.Text == "") { MessageBox.Show("Vui lòng nhập đầy đủ thông tin"); return; } if (IsNumber(txtSLnhap.Text) == false) { MessageBox.Show("Số lượng phải là số và không được âm", "Thông báo"); return; } if (IsNumber(txtDonGia.Text) == false) { MessageBox.Show("Đơn giá phải là số và không được âm", "Thông báo"); return; } string mapn = txtMaPN.Text; string masach = txtMaSach.Text; int dongia = Int32.Parse(txtDonGia.Text); int soluong = Int32.Parse(txtSLnhap.Text); int tongtien = Int32.Parse(txtTongTien.Text); Sach s = TimSachBUS.getThongTinSach(masach); QuyDinh qd = QuyDinhBUS.GetQD(); if (s.TonCuoi > Int32.Parse(qd.TonNhapToiThieu)) { MessageBox.Show("Chỉ được nhập sách có số lượng tồn ít hơn " + qd.TonNhapToiThieu); return; } if (soluong < Int32.Parse(qd.NhapToiThieu)) { MessageBox.Show("Số lượng nhập tối thiểu là " + qd.NhapToiThieu); return; } if (CTPhieuNhapBUS.checkTrung(txtMaPN.Text, txtMaSach.Text) == false) { MessageBox.Show("Sách này đã có trong phiếu nhập"); return; } CTPhieuNhapBUS.InsertCTPhieuNhap(mapn, masach, soluong, dongia, tongtien); UpdateSoLuongTon(); UpdateTongTien(); MessageBox.Show("Thêm sách vào phiếu nhập thành công!"); }
void loadCTPN() { txtMaPN.Text = GetMaPN.getMaPN; List <CTPhieuNhapDTO> CTPN = CTPhieuNhapBUS.GetCTPN(txtMaPN.Text); dgvCTPN.DataSource = CTPN; for (int i = 0; i < dgvCTPN.Rows.Count; i++) { dgvCTPN.Rows[i].Cells[0].Value = i + 1; } btnLuu.Enabled = false; btnThem.Enabled = true; btnSua.Enabled = true; btnXoa.Enabled = true; }
private void LoadCTPhieuNhap(int maPhieuNhap) { List <CTPhieuNhapDTO> lsCTPhieuNhap = CTPhieuNhapBUS.LayDanhSachCTPhieuNhap(maPhieuNhap); dgvCTPhieuNhap.DataSource = lsCTPhieuNhap; }