private void btnShip_Click(object sender, EventArgs e) { frmSelectItemJobFromInventory objSelectItemJobFromInventoryForm; frmSelectItemJob objSelectItemJobForm; frmSelectOrder objSelectOrderForm; frmSelectOrderLine objSelectOrderReleaseForm; frmItemHistory objSelectItemHistoryForm; frmSelectOperation objSelectOperationForm; frmShipItem objShipItemForm; Item objItem; if (mobjItem == null) { MessageBox.Show("No item selected!", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } else { objItem = new Item { ItemID = mobjItem.ItemID, IsSubItem = chkIsSubItem.Checked } }; //Case where Item IS MFG and item IS pulled from Inventory if (objItem.IsSubItem) { //use a select case statement to perform looping so that a user can walk up and down the decision tree; leverage an intcounter to do the walking and set it to negative to cancel out of //the decision tree. objSelectItemJobFromInventoryForm = new frmSelectItemJobFromInventory(objItem); objSelectItemJobFromInventoryForm.ShowDialog(); if (objSelectItemJobFromInventoryForm.FormStatus == FormStatus.Succeeded) { objItem.SelectedItemHistoryJob = objSelectItemJobFromInventoryForm.SelectedItemHistoryJob; objItem.SelectedJob = new Job { JobNumber = objItem.SelectedItemHistoryJob.JobNumber, JobOrderNumber = objItem.SelectedItemHistoryJob.JobOrderNumber }; objSelectOrderForm = new frmSelectOrder(objItem); objSelectOrderForm.ShowDialog(); if (objSelectOrderForm.FormStatus == FormStatus.Succeeded) { objItem.SelectedOrder = objSelectOrderForm.SelectedOrder; objItem.CustomerOrderNumber = objItem.SelectedOrder.CustomerOrderNumber; objSelectOrderReleaseForm = new frmSelectOrderLine(objItem); objSelectOrderReleaseForm.ShowDialog(); if (objSelectOrderReleaseForm.FormStatus == FormStatus.Succeeded) { objItem.SelectedOrderLine = objSelectOrderReleaseForm.SelectedOrderLine; objSelectItemHistoryForm = new frmItemHistory(objItem, true); objSelectItemHistoryForm.ShowDialog(); if (objSelectItemHistoryForm.FormStatus == FormStatus.Succeeded) { objItem.SelectedHistoryTransactions = objSelectItemHistoryForm.SelectedItemHistoryJobs; objSelectOperationForm = new frmSelectOperation(objItem.SelectedJob); objSelectOperationForm.ShowDialog(); if (objSelectOperationForm.FormStatus == FormStatus.Succeeded) { objItem.SelectedJob.SelectedOperation = objSelectOperationForm.SelectedOperation; objItem.IsPulledFromInventory = true; objShipItemForm = new frmShipItem(objItem); objShipItemForm.ShowDialog(); if (objShipItemForm.FormStatus == FormStatus.Succeeded) { MessageBox.Show("The Material Transaction completed Successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } else if (objShipItemForm.FormStatus == FormStatus.Cancelled) { return; } else { MessageBox.Show(objShipItemForm.FormStatus.ToString() + " \r\nThe Material Transaction did NOT completed Successfully!", "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } } } } } } } else { objSelectItemJobForm = new frmSelectItemJob(mobjItem); objSelectItemJobForm.ShowDialog(); if (objSelectItemJobForm.FormStatus == FormStatus.Succeeded) { objItem.SelectedJob = objSelectItemJobForm.SelectedJob; objSelectOrderForm = new frmSelectOrder(objItem); objSelectOrderForm.ShowDialog(); if (objSelectOrderForm.FormStatus == FormStatus.Succeeded) { objItem.SelectedOrder = objSelectOrderForm.SelectedOrder; objItem.CustomerOrderNumber = objItem.SelectedOrder.CustomerOrderNumber; objSelectOrderReleaseForm = new frmSelectOrderLine(objItem); objSelectOrderReleaseForm.ShowDialog(); if (objSelectOrderReleaseForm.FormStatus == FormStatus.Succeeded) { objItem.SelectedOrderLine = objSelectOrderReleaseForm.SelectedOrderLine; objSelectOperationForm = new frmSelectOperation(objItem.SelectedJob); objSelectOperationForm.ShowDialog(); if (objSelectOperationForm.FormStatus == FormStatus.Succeeded) { objItem.SelectedJob.SelectedOperation = objSelectOperationForm.SelectedOperation; objItem.IsPulledFromInventory = false; objShipItemForm = new frmShipItem(objItem); objShipItemForm.ShowDialog(); if (objShipItemForm.FormStatus == FormStatus.Succeeded) { MessageBox.Show("The Material Transaction completed Successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } else if (objShipItemForm.FormStatus == FormStatus.Cancelled) { return; } else { MessageBox.Show(objShipItemForm.FormStatus.ToString() + " \r\nThe Material Transaction did NOT completed Successfully!", "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } } } } } } }
private void btnGetJobs_Click(object sender, EventArgs e) { frmSelectItemJob objSelectItemJobForm; frmSelectOrder objSelectOrderForm; Job objTempJob = mobjItem.SelectedJob; try { //Modified 4-21-2015 - allows user to specify a job so that they can recieve items into history for jobs that have closed. if (chkSpecifyJob.Checked) { using (var objFrmSpecifyJob = new frmSpecifyJob()) if (objFrmSpecifyJob.ShowDialog() == System.Windows.Forms.DialogResult.OK) { mobjItem.SpecifiedJob = objFrmSpecifyJob.objJob; } else { mobjItem.SpecifiedJob = null; } } else { mobjItem.SpecifiedJob = null; } objSelectItemJobForm = new frmSelectItemJob(mobjItem); objSelectItemJobForm.ShowDialog(); if (objSelectItemJobForm.FormStatus != FormStatus.Succeeded) //if user does not select a new job { mobjItem.SelectedJob = objTempJob; //set values back to thier previous state return; //and exit the function } mobjItem.SelectedJob = objSelectItemJobForm.SelectedJob; //else set the values to the new job if (mobjItem.SelectedJob != null) // { objSelectOrderForm = new frmSelectOrder(mobjItem); objSelectOrderForm.ShowDialog(); if (objSelectOrderForm.FormStatus != FormStatus.Succeeded) { mobjItem.SelectedJob = objTempJob; return; } SetJobValues(); mobjItem.SelectedOrder = objSelectOrderForm.SelectedOrder; if (mobjItem.SelectedOrder != null) { SetOrderValues(); //Below I set the joborder number to the selectedorder's customerordernumber when the jobordernumber is null. that way my filtering will work properly when shipping the item and the frmSelectOrder form is used. mobjItem.SelectedJob.JobOrderNumber = string.IsNullOrEmpty(mobjItem.SelectedJob.JobOrderNumber) ? mobjItem.SelectedOrder.CustomerOrderNumber : string.Empty; } else { RemoveOrderValues(); } } } catch (Exception objEx) { MessageBox.Show(objEx.Message); } }