public bool DeleteCustomer(int customerid, Session DXSession) { SPG.CustomersDataTable customers = Adapter.GetCustomerByID(customerid); int rowsAffected = 0; if (customers.Count() == 1) { if ((new ItemsBLL()).GetItemsByCustomerID(customerid).Count != 0 || (new ProductionBLL()).GetProductionByCustomerID(customerid).Count != 0 || (new InventoryBLL()).GetInventoryView(null, null, customerid, null, null).Count != 0) { if (MessageBox.Show("You can't delete this customer because there are items or production/inventory assigned to him. Do you want ot mark him as inactive?", "Delete Customer", MessageBoxButtons.YesNo, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { Adapter.InactivateCustomer(customerid); return(true); } else { return(true); } } RelatedCustomerBLL.DeleteRelatedCustomers(GetCustomer(customerid, DXSession)); rowsAffected = Adapter.Delete(customerid, customers[0].ts); } return(Convert.ToBoolean(rowsAffected)); }
private void addBothWaysSimpleButton_Click(System.Object sender, EventArgs e) { if (RelatedCustomerBLL.AddRelatedCustomer(CustomersBLL.GetCustomer(m_CurrentCustomer.Value, m_CustomersSession), CustomersBLL.GetCustomer(Convert.ToInt32(relatedCustomerLookUpEdit.EditValue), m_CustomersSession), true) == false) { MessageBox.Show("There was a problem while adding the related customer"); } relatedCustomerXpCollection.Reload(); }
private void deleteRepositoryItemButtonEdit_Click(object sender, EventArgs e) { if (MessageBox.Show("Are you sure you want to delete this relationshiP?", "Delete Related Customer", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } if (RelatedCustomerBLL.DeleteRelatedCustomer(m_CustomersSession.GetObjectByKey <RelatedCustomer>(relatedCustomersGridView.GetFocusedRowCellValue(idGridColumn)))) { MessageBox.Show("The customer relationship was successfully deleted."); } else { MessageBox.Show("There was a problem while deleting the related customer"); } }
private void deleteBarButtonItem_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (MessageBox.Show("Are you sure you want to delete this customer.", "Delete Customer", MessageBoxButtons.YesNo, MessageBoxIcon.Hand) == DialogResult.No) { return; } try { if (m_Customer.DeleteCustomer(m_CurrentCustomer.Value, m_CustomersSession) == true) { RelatedCustomerBLL.DeleteRelatedCustomers(CustomersBLL.GetCustomer(m_CurrentCustomer.Value, m_CustomersSession)); BindCustomerSearch(); } else { MessageBox.Show("The customer was not deleted."); } } catch (ApplicationException ex) { MessageBox.Show(ex.Message, "Error Encountered", MessageBoxButtons.OK, MessageBoxIcon.Error); } }