private void frmVatTuPhuTung_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'quanlygaraoto1.CT_PHIEUSUACHUA' table. You can move, or remove it, as needed. this.cT_PHIEUSUACHUATableAdapter.Fill(this.quanlygaraoto1.CT_PHIEUSUACHUA); // TODO: This line of code loads data into the 'quanlygaraoto1.sp_VatTuPhuTung_GetAll' table. You can move, or remove it, as needed. this.sp_VatTuPhuTung_GetAllTableAdapter.Fill(this.quanlygaraoto1.sp_VatTuPhuTung_GetAll); // TODO: This line of code loads data into the 'quanlygaraoto1.CT_PHIEUSUACHUA' table. You can move, or remove it, as needed. this.cT_PHIEUSUACHUATableAdapter.Fill(this.quanlygaraoto1.CT_PHIEUSUACHUA); // TODO: This line of code loads data into the 'quanlygaraoto1.sp_VatTuPhuTung_GetAll' table. You can move, or remove it, as needed. this.sp_VatTuPhuTung_GetAllTableAdapter.Fill(this.quanlygaraoto1.sp_VatTuPhuTung_GetAll); tableDSVTPT.DataSource = PhieuNhapVatTuPhuTungBUS.PhieuNhapVatTuPhuTung_GetAll(dateNgayNhap.Text); cbMaVTPT.DataSource = VatTuPhuTungBUS.VatTuPhuTung_GetAll(); cbMaVTPT.DisplayMember = "mavattuphutung"; cbMaVTPT.ValueMember = "DonGia"; cbMaVTPT.Text = ""; txtTenVTPT.Text = ""; txtDonGia.Text = ""; }
private void btnXoa_Click(object sender, EventArgs e) { try { CT_PhieuNhapVatTuPhuTungBUS.CT_PhieuNhapVatTuPhuTung_Delete(txtMaPhieu.Text, cbMaVTPT.Text); tableDSVTPT.DataSource = PhieuNhapVatTuPhuTungBUS.PhieuNhapVatTuPhuTung_GetAll(dateNgayNhap.Text); MessageBox.Show("Đã Xóa "); } catch (Exception ex) { MessageBox.Show(ex.Message); } txtMaPhieu.Text = ""; cbMaVTPT.Text = ""; txtTenVTPT.Clear(); txtDonGia.Clear(); txtSoLuong.Clear(); txtThanhTien.Clear(); btnXoa.Enabled = false; }
private void btnThemMoi_Click(object sender, EventArgs e) { try { if (PhieuNhapVatTuPhuTungBUS.PhieuNhapVatTuPhuTung_KiemTra(txtMaPhieu.Text) == 0) { VatTuPhuTung vtpt = new VatTuPhuTung(); PhieuNhapVatTuPhuTung pnvt = new PhieuNhapVatTuPhuTung(); CT_PhieuNhapVatTuPhuTung ctpn = new CT_PhieuNhapVatTuPhuTung(); pnvt.SoPhieuNhap = txtMaPhieu.Text; pnvt.NgayNhap = dateNgayNhap.Text; vtpt.MaVatTuPhuTung = cbMaVTPT.Text; vtpt.TenVatTuPhuTung = txtTenVTPT.Text; ctpn.SoPhieuNhap = txtMaPhieu.Text; ctpn.MaVatTuPhuTung = cbMaVTPT.Text; ctpn.DonGia = double.Parse(txtDonGia.Text); ctpn.SoLuong = int.Parse(txtSoLuong.Text); ctpn.ThanhTien = double.Parse(txtThanhTien.Text); ctpn.TenVatTuPhuTung = txtTenVTPT.Text; VatTuPhuTungBUS.VatTuPhuTung_Insert(vtpt); PhieuNhapVatTuPhuTungBUS.PhieuNhapVatTuPhuTung_Insert(pnvt); CT_PhieuNhapVatTuPhuTungBUS.CT_PhieuNhapVatTuPhuTung_Insert(ctpn); MessageBox.Show("Thêm mới phiếu nhập vật tư thành công!"); tableDSVTPT.DataSource = PhieuNhapVatTuPhuTungBUS.PhieuNhapVatTuPhuTung_GetAll(dateNgayNhap.Text); for (int i = 0; i < tableDSVTPT.Rows.Count; i++) { tableDSVTPT.Rows[i].HeaderCell.Value = (i + 1).ToString(); } } else { MessageBox.Show("Phiếu nhập vật tư đã có. Xin nhập phiếu khác !!!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception ex) { MessageBox.Show(ex.Message); } btnXoa.Enabled = false; tableDSVTPT.Enabled = true; }