private void buttonDelete_Click(object sender, EventArgs e) { Button categoryButtonTagged = buttonDelete.Tag as Button; if (categoryButtonTagged == buttonCategoryProduct) { ProductDTO productSelected = rowSelectedObj as ProductDTO; if (productSelected != null) { FormDeleteProduct formDelete = new FormDeleteProduct(); formDelete.productSelected = productSelected; formDelete.ShowDialog(); LoadDtgvProduct(); } else { MessageBox.Show("Bạn chưa chọn sản phẩm"); } } if (categoryButtonTagged == buttonCategorySupplier) { Supplier supplierSelected = rowSelectedObj as Supplier; if (supplierSelected != null) { FormDeleteSupplier fDel = new FormDeleteSupplier(); fDel.supplierSelectedFromDtgv = supplierSelected; fDel.ShowDialog(); LoadDtgvSupplier(); } else { MessageBox.Show("Bạn chưa chọn nhà cung cấp"); } } if (categoryButtonTagged == buttonCategoryCustomer) { Customer customerSelected = rowSelectedObj as Customer; if (customerSelected != null) { FormDeleteCustomer fDel = new FormDeleteCustomer(); fDel.customerSelectedFromListView = customerSelected; fDel.ShowDialog(); LoadDtgvCustomer(); } else { MessageBox.Show("Bạn chưa chọn khách hàng"); } } if (categoryButtonTagged == buttonCategoryReceiveVoucher) { ReceiveVoucherDTO voucherInfoSelected = rowSelectedObj as ReceiveVoucherDTO; if (voucherInfoSelected != null) { if (ReceiveVoucherDAO.Instance.HaveTheProductBeenSold(voucherInfoSelected.ReceiveVoucherID)) { MessageBox.Show("Phiếu nhập hàng này đã có sản phẩm được xuất kho. Bạn không thể xóa"); } else { ReceiveVoucher voucher = ReceiveVoucherDAO.Instance.GetByID(voucherInfoSelected.ReceiveVoucherID); FormDeleteReceiveVoucher f = new FormDeleteReceiveVoucher(); f.voucherSelected = voucher; this.Hide(); f.ShowDialog(); LoadDtgvReceiveVoucher(); this.Show(); } } else { MessageBox.Show("Hãy chọn dòng thông tin bạn muốn xóa"); } } if (categoryButtonTagged == buttonCategoryDeliveryVoucher) { var voucher = rowSelectedObj as DeliveryVoucherView; if (voucher != null) { string deliveryVoucherID = voucher.VoucherID.ToString(); FormDeleteDeliveryVoucher f = new FormDeleteDeliveryVoucher(); f.DeliveryVoucherID = deliveryVoucherID; f.ShowDialog(); LoadDtgvDeliveryVoucher(); } else { MessageBox.Show("Hãy chọn phiếu xuất bạn muốn xóa"); } } }
private void buttonUpdate_Click(object sender, EventArgs e) { Button categoryButtonClicked = buttonUpdate.Tag as Button; if (categoryButtonClicked == buttonCategoryProduct) { FormUpdateProduct formUpdate = new FormUpdateProduct(); ProductDTO selectedProduct = rowSelectedObj as ProductDTO; if (selectedProduct != null) { formUpdate.selectedProductFromDtgv = selectedProduct; formUpdate.ShowDialog(); //reload dtgv LoadDtgvProduct(); } else { MessageBox.Show("Bạn chưa chọn sản phẩm"); } } if (categoryButtonClicked == buttonCategorySupplier) { Supplier supplierSelected = rowSelectedObj as Supplier; if (supplierSelected != null) { FormUpdateSupplier fUpSupp = new FormUpdateSupplier(); fUpSupp.supplierSelectedFromDtgv = supplierSelected; fUpSupp.ShowDialog(); LoadDtgvSupplier(); } else { MessageBox.Show("Hãy click vào nhà cung cấp bạn muốn"); } } if (categoryButtonClicked == buttonCategoryCustomer) { Customer customerSelected = rowSelectedObj as Customer; if (customerSelected != null) { FormUpdateCustomer f = new FormUpdateCustomer(); f.customerSelectedFromListView = customerSelected; f.ShowDialog(); LoadDtgvCustomer(); } else { MessageBox.Show("Hãy click vào khách hàng bạn muốn"); } } if (categoryButtonClicked == buttonCategoryReceiveVoucher) { ReceiveVoucherDTO voucherInfoSelected = rowSelectedObj as ReceiveVoucherDTO; if (voucherInfoSelected != null) { string idVoucher = voucherInfoSelected.ReceiveVoucherID; ReceiveVoucher voucher = ReceiveVoucherDAO.Instance.GetByID(idVoucher); FormUpdateReceiveVoucher fUpdate = new FormUpdateReceiveVoucher(voucher); this.Hide(); fUpdate.ShowDialog(); this.Show(); LoadDtgvReceiveVoucher(); } else { MessageBox.Show("Hãy click vào hóa đơn bạn muốn sửa."); } } if (categoryButtonClicked == buttonCategoryDeliveryVoucher) { } }