private void btnDelete_Click(object sender, EventArgs e) { int id = 0; int.TryParse(tbId.Text, out id); if (id != 0) { Supplier currentSupplier = BLSupplier.GetSupplierById(APCContext, id); if (currentSupplier != null) { APCContext.DeleteObject(currentSupplier); APCContext.SaveChanges(); MessageBox.Show("Delete Successfully"); ClearContent(); } else { MessageBox.Show("Supplier Id not found"); } } else { MessageBox.Show("Supplier Id not found"); } }
private void btnUpdate_Click(object sender, EventArgs e) { Supplier selectedSupplier = BLSupplier.GetSupplierById(APCContext, int.Parse(cbSupplier.SelectedValue.ToString())); Project selectedProject = BLProject.GetProjectById(APCContext, int.Parse(cbProject.SelectedValue.ToString())); int id = 0; int.TryParse(tbId.Text, out id); if (id != 0) { PO currentPO = BLPO.GetPOById(APCContext, id); if (currentPO != null) { currentPO.Supplier = selectedSupplier; currentPO.Project = selectedProject; APCContext.SaveChanges(); deletePO_Product(currentPO); insertPO_Product(currentPO); MessageBox.Show("PO Details Successfully Updated"); ClearContent(); SetComboToDefault(); } else { MessageBox.Show("PO Id not found"); } } else { MessageBox.Show("PO Id not found"); } }
private void btnUpdate_Click(object sender, EventArgs e) { int id = 0; int.TryParse(tbId.Text, out id); if (id != 0) { Supplier currentSupplier = BLSupplier.GetSupplierById(APCContext, id); if (currentSupplier != null) { currentSupplier.Name = tbName.Text; APCContext.SaveChanges(); MessageBox.Show("Supplier Details Successfully Updated"); ClearContent(); } else { MessageBox.Show("Supplier Id not found"); } } else { MessageBox.Show("Supplier Id not found"); } }
private void btnInsert_Click(object sender, EventArgs e) { Supplier selectedSupplier = BLSupplier.GetSupplierById(APCContext, int.Parse(cbSupplier.SelectedValue.ToString())); Project selectedProject = BLProject.GetProjectById(APCContext, int.Parse(cbProject.SelectedValue.ToString())); PO po = BLPO.insertPO(APCContext, selectedSupplier, selectedProject); insertPO_Product(po); MessageBox.Show("PO Successfully Added"); ClearContent(); SetComboToDefault(); }