// Field validation is run before creating a new work order. If their are
        // invalid fields, state New is returned. If validation passes, create the work
        // order and return state Active.
        // Expected state return value: New, Active, Error
        private Control.State ProcessAddNewWorkOrder(Control.State processState)
        {
            Control.State result = Control.State.Error;

            if (processState == Control.State.New)
            {
                if (cboItemCode.SelectedItem == null)
                {
                    erpItemCode.SetError(cboItemCode, "An Item must be selected");
                    result = Control.State.New;
                }
                else
                {
                    erpItemCode.Clear();

                    DataProcess newOrder = new DataProcess(ActiveSession.CompanyODBC);

                    string won = txtWorkOrderNo.Text;
                    string prt = cboProductType.SelectedItem.ToString();
                    string prl = cboProductionLine.SelectedItem.ToString();

                    string whs = cboWarehouse.SelectedItem.ToString();
                    string itc = cboItemCode.SelectedItem.ToString();
                    string itd = txtItemDescription.Text;

                    string plu = txtPlannedUOM.Text;
                    string plq = txtPlannedQuantity.Text;
                    string pld = dtpPlannedDate.Text;
                    string pls = txtPlannedShift.Text;

                    string plc = txtProductionLineCapacity.Text;
                    string mil = txtReOrderPoint.Text;
                    string bas = txtBatchSize.Text;
                    string nob = txtBatchNo.Text;

                    string cun = (cboCustomerOrderNo.SelectedIndex == -1) ? "" : cboCustomerOrderNo.SelectedItem.ToString();
                    string fgo = (cboFGWorkOrderNo.SelectedIndex == -1) ? "" : cboFGWorkOrderNo.SelectedItem.ToString();
                    string sta = nameof(Control.Status.Okay);//txtStatus.Text;
                    string amq = txtActualManufacturedQty.Text;
                    string acs = txtActualShift.Text;
                    string acd = dtpActualDate.Text;

                    string com = txtComments.Text;
                    string crd = txtCreatedDate.Text;
                    string cru = txtCreatedUser.Text;
                    string lmd = txtLastModifiedDate.Text;
                    string lmu = txtLastModifiedUser.Text;

                    List <string> validateErrors = newOrder.Validate(
                        won, prt, prl,
                        whs, itc, itd,
                        plu, plq, pld, pls,
                        plc, mil, nob, bas,
                        cun, fgo, sta, amq, acs, acd,
                        com, crd, cru, lmd, lmu
                        );

                    if (validateErrors.Count > 0)
                    {
                        string errors = "The following fields did not pass data validation:\n";
                        foreach (string s in validateErrors)
                        {
                            errors = string.Format("{0}\n{1}", errors, s);
                        }
                        Utilities.ShowError(errors, "Data Validation Error");
                        result = Control.State.New;
                    }
                    else
                    {
                        newOrder.AddOrder();
                        ProcessRecordLogHistory(newOrder, Log);
                        Utilities.ShowMessage(string.Format("Work Order {0} Added.", won), "Add");
                        result = Control.State.Active;
                    }
                }
            }
            else
            {
                result = Control.State.Error;
            }

            return(result);
        }