private void CustomersXtraForm_Load(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; m_Customer = new CustomersBLL(); m_CustomersItems = new ItemsBLL(); m_Receiving = new ReceivingsBLL(); m_ReceivingDetails = new ReceivingDetailsBLL(); m_Production = new ProductionBLL(); m_Shippings = new ShippingsBLL(); m_UserPermissions = new UserPermissionsBLL(); m_CustomersSession = new Session(MyDataLayers.SPGDataLayer); m_CustomersSession.TrackPropertiesModifications = true; m_CustomersSession.OptimisticLockingReadBehavior = OptimisticLockingReadBehavior.MergeCollisionThrowException; CheckPermissions(); for (int i = 0; i < components.Components.Count; i++) { if ((components.Components[i]) is XPView) { ((XPView)components.Components[i]).Session = m_CustomersSession; } else if ((components.Components[i]) is XPCollection) { ((XPCollection)components.Components[i]).Session = m_CustomersSession; } } BindCustomerSearch(); customerShiftsXpCollection.Criteria = new BinaryOperator(CustomerShifts.Fields.Customer, null, BinaryOperatorType.Equal); customerPlantsXpCollection.Criteria = new BinaryOperator(CustomerPlants.Fields.Customer, null, BinaryOperatorType.Equal); Utilities.MakeFormReadOnly(generalXtraTabPage, true); addRelatedCustomerGroupControl.Enabled = false; customerPlantsGridView.OptionsBehavior.Editable = false; customerShiftsGridView.OptionsBehavior.Editable = false; deleteGridColumn.Visible = false; deleteCustomerPlantGridColumn.Visible = false; deleteCustomerShiftGridColumn.Visible = false; customerSearchGridControl.Enabled = true; Cursor = Cursors.Default; }
public bool DeleteIem(int itemID) { SPG.ItemsDataTable items = Adapter.GetItemByID(itemID); int rowsAffected = 0; if (items.Count() == 1) { if ((new ProductionBLL()).GetProductionByItemID(itemID).Count != 0 || (new InventoryBLL()).GetInventoryView(null, null, null, itemID, null).Count != 0 || ReceivingDetailsBLL.GetReceivingDetailsByItemID(itemID).Count != 0 || SuperiorPackGroup.ShippingDetailsBLL.GetShippingDetailsByItemID(itemID).Count != 0 || ReturnDetailsBLL.GetReceivingReturnDetailsByItemID(itemID).Count != 0 || (new ShippingReturnDetailsBLL()).GetShippingReturnDetailsByItemID(itemID).Count != 0) { if (MessageBox.Show("You can't delete this item because there are production, inventory, Receiving's, or Shipping's assigned to it. Do you want ot mark it as inactive?", "Delete Item", MessageBoxButtons.YesNo, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { Adapter.InactivateItem(itemID); return(true); } else { return(true); } } rowsAffected = Convert.ToInt32((new BOMBLL()).DeleteBOMByFGItemID(itemID)); rowsAffected = Adapter.Delete(itemID, items[0].ts); } return(Convert.ToBoolean(rowsAffected)); }