//Readjusts our CreateWorkOrder variables after completing the form (or going back) //Do this by visibility changing event private void CreateWOVisChange(object obj, EventArgs e) { if (cWOPanel.Visible == false) { mainPanel.Visible = true; //Reset our Add Customers panel //Set up our CreateWorkOrders panel _cWorkOrder = new CreateWorkOrder(excel_app, basefilepath); cWOPanel = _cWorkOrder.Create_Work_Order_Panel; _cWorkOrder.excel_app = excel_app; _cWorkOrder._curWOList = _curWOList; _cWorkOrder._accList = _accList; _cWorkOrder.pNameList = pNameList; _cWorkOrder.processList = processList; _cWorkOrder.basefilepath = basefilepath; _cWorkOrder.fuelSystemAcc = fuelSystemAcc; _cWorkOrder.excelWOPath = excelWOPath; _cWorkOrder.This_Year = this_year; cWOPanel.VisibleChanged += new EventHandler(CreateWOVisChange); } }
private List <string> fuelSystemAcc; //A list of all the Accessories that are not considered fuel-related public Form1() { this_year = DateTime.Today.Year.ToString(); #region List Initialization //Initialize and fill up our pNameList variable pNameList = new List <string>() { "Magneto", "Wastegate", "Turbo", "Prop Governor", "Starter Adapter", "Controller", "Fuel Pump", "Manifold Valve", "Control Valve", "Flow Divider", "Fuel Servo", "Relief Valve", "Carburetor", "Pressure Regulator" }; //Initialize and fill up our processList variable processList = new List <string>() { "O/H", "500 Hour", "IRAN", "Repair", "Test" }; //Initialize and fill up our fuelSystemAcc variable fuelSystemAcc = new List <string>() { "Fuel Pump", "Manifold Valve", "Control Valve", "Fuel Servo", "Relief Valve", "Carburetor", "Pressure Regulator" }; #endregion usbStick = USBDrive.GetSticks("WOUSB" + this_year); excel_app = new Excel.Application(); basefilepath = usbStick.ToArray()[0].Name + @"\Users\mike\Desktop"; customerDBfile = basefilepath + @"\Customer Information.xlsx"; excelWOPath = basefilepath + @"\Work Order " + this_year + ".xlsx"; MessageBox.Show(usbStick.ToString() + "\n" + basefilepath); //Set up our lists _accList = new List <Accessory>(); //This list will be used both for editing a Work Order as well as creating a new Work Order _curWOList = new List <WorkOrderFile>(); //This list will contain data from Work Orders <year> //Set up our AddCustomer panel _addPanel = new AddCustomer(); addCustPanel = _addPanel.Add_Customer_Panel; _addPanel.excel_app = excel_app; addCustPanel.VisibleChanged += new EventHandler(AddCustVisChange); //Set up our EditCustomer panel _editPanel = new EditCustomer(); editCustPanel = _editPanel.Edit_Customer_Panel; _editPanel.excel_app = excel_app; editCustPanel.VisibleChanged += new EventHandler(EditCustVisChange); //Set up our EditWorkOrders panel _editWOPanel = new EditWorkOrder(); editWOPanel = _editWOPanel.Edit_Work_Order_Panel; _editWOPanel.excel_app = excel_app; _editWOPanel._curWOList = _curWOList; _editWOPanel._accList = _accList; _editWOPanel.pNameList = pNameList; _editWOPanel.processList = processList; _editWOPanel.fuelSystemAcc = fuelSystemAcc; _editWOPanel.basefilepath = basefilepath; _editWOPanel.excelWOPath = excelWOPath; _editWOPanel.This_Year = this_year; editWOPanel.VisibleChanged += new EventHandler(EditWOVisCHange); //Set up our CreateWorkOrders panel _cWorkOrder = new CreateWorkOrder(excel_app, basefilepath); cWOPanel = _cWorkOrder.Create_Work_Order_Panel; _cWorkOrder.excel_app = excel_app; _cWorkOrder._curWOList = _curWOList; _cWorkOrder._accList = _accList; _cWorkOrder.pNameList = pNameList; _cWorkOrder.processList = processList; _cWorkOrder.basefilepath = basefilepath; _cWorkOrder.fuelSystemAcc = fuelSystemAcc; _cWorkOrder.excelWOPath = excelWOPath; _cWorkOrder.This_Year = this_year; cWOPanel.VisibleChanged += new EventHandler(CreateWOVisChange); mainPanel = CreatePanel(); mainPanel.Controls.Add(new Label() { Location = new Point(70, 20), AutoSize = true, Font = new Font("Verdana", 16.0f, FontStyle.Bold), Text = "This Year:" }); mainPanel.Controls.Add(new Label() { Size = new Size(465, 38), Font = new Font("Verdana", 24.0f, FontStyle.Bold), Location = new Point(168, 54), Text = "What do you need to do?" }); //Add our main label to our mainPanel control TextBox year_box = new TextBox() { Size = new Size(183, 20), Location = new Point(264, 25), Name = "ThisYearBox", Text = this_year }; year_box.KeyUp += (sender2, e2) => YearBoxTextChanged(sender2, e2, year_box.Text); addCust = MainPanelButton("Add Customer", new Point(51, 132)); //Adds our Add Customer button addCust.Click += new EventHandler(Add_Customer); editCust = MainPanelButton("Edit Customer", new Point(335, 132)); //Adds our Edit Customer button editCust.Click += new EventHandler(Edit_Customer); editWO = MainPanelButton("Edit Work Order", new Point(615, 132)); //Adds our Edit Work Order button editWO.Click += new EventHandler(Edit_Work_Order); cWOButton = MainPanelButton("Create Work Order", new Point(51, 225)); //Adds our Create Work Order button cWOButton.Click += new EventHandler(Create_Work_Order); _goBackButton = new Button() { Location = new Point(632, 494), Size = new Size(173, 46), Text = "Back to Main Menu" }; _goBackButton.Click += new EventHandler(ReturnToMainMenu); _exitAppButton = new Button() { Location = new Point(438, 494), Size = new Size(173, 46), Text = "Exit Application" }; _exitAppButton.Click += new EventHandler(ExitApplicationButton); this.Controls.Add(_goBackButton); this.Controls.Add(_exitAppButton); mainPanel.Controls.Add(year_box); mainPanel.Controls.Add(addCust); mainPanel.Controls.Add(editCust); mainPanel.Controls.Add(editWO); mainPanel.Controls.Add(cWOButton); this.Controls.Add(mainPanel); this.FormClosing += Form1_Closing; InitializeComponent(); }