private void btnAddProductAgency_Click(object sender, EventArgs e) { if (txtIDProductDL.Text == "" || txtNameProductDL.Text == "" || cmbIDAgency.Text == "" || txtUnitDL.Text == "" || txtPriceDL.Text == "" || txtAmountDL.Text == "") { MessageBox.Show("Bạn phải điền đầy đủ thông tin !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearDisplay(); return; } SanPhamDL_DTO sanpham = new SanPhamDL_DTO(); sanpham.MaSPDL = txtIDProductDL.Text; sanpham.TenSP = txtNameProductDL.Text; sanpham.MaDL = cmbIDAgency.SelectedValue.ToString(); sanpham.DonVi = txtUnitDL.Text; sanpham.Gia = Double.Parse(txtPriceDL.Text.ToString()); sanpham.SoLuong = Int32.Parse(txtAmountDL.Text.ToString()); if (SanPhamDL_BUS.ThemSPDL(sanpham)) { MessageBox.Show("Thêm Sản phẩm Đại Lí thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadSanPhamDL(); ClearDisplay(); return; } MessageBox.Show("Thêm Sản phẩm Đại Lí thất bại !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void btnAddProductAgency_Click(object sender, EventArgs e) { if (txtIDProductDL.Text == "" || txtNameProductDL.Text == "" || cmbIDAgency.Text == "" || txtUnitDL.Text == "" || txtPriceDL.Text == "" || txtParameter.Text == "") { XtraMessageBox.Show("Bạn phải điền đầy đủ thông tin !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); ClearDisplay(); return; } SanPhamDL_DTO sanpham = new SanPhamDL_DTO(); sanpham.MaSPDL = txtIDProductDL.Text; sanpham.TenSP = txtNameProductDL.Text; sanpham.MaDL = cmbIDAgency.SelectedValue.ToString(); sanpham.DonVi = txtUnitDL.Text; sanpham.Gia = Double.Parse(txtPriceDL.Text.ToString()); sanpham.ThongSo = txtParameter.Text.ToString(); try { if (SanPhamDL_BUS.ThemSPDL(sanpham)) { XtraMessageBox.Show("Thêm Sản phẩm Đại Lí thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadSanPhamDL(); uctSanPhamCH.uctSPCH.LoadSanPhamCH1(); ClearDisplay(); return; } }catch (Exception ex) { XtraMessageBox.Show("Thêm Sản phẩm Đại Lí thất bại !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
public void btnDeleteProductAgency_Click(object sender, EventArgs e) { try { SanPhamDL_DTO sanpham = new SanPhamDL_DTO(); sanpham.MaSPDL = (string)dtgvProductListOfAgency.CurrentRow.Cells["MaSPDL"].Value; if (txtIDProductDL.Text == "" || txtNameProductDL.Text == "" || cmbIDAgency.Text == "" || txtUnitDL.Text == "" || txtPriceDL.Text == "") { XtraMessageBox.Show("Bạn phải chọn Sản phẩm để xóa", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); ClearDisplay(); return; } if (SanPhamDL_BUS.XoaSPDL(sanpham)) { LoadSanPhamDL(); XtraMessageBox.Show("Xóa Sản phẩm Đại lí thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearDisplay(); return; } }catch { XtraMessageBox.Show("Xóa Sản phẩm Đại lí thất bại !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
private void LoadMaSP() { List <SanPhamDL_DTO> sanpham = SanPhamDL_BUS.LoadSanPhamDL(); cmbIDProductDetailStore.DataSource = sanpham; cmbIDProductDetailStore.ValueMember = "MaSPDL"; cmbIDProductDetailStore.DisplayMember = "MaSPDL"; }
private void LoadSanPhamDL() { List <SanPhamDL_DTO> listSP = SanPhamDL_BUS.LoadSanPhamDL(); dtgvProductListOfAgency.DataSource = listSP; }