public MachineStockAdjust(Database database, StartUp parent, Machine machine)
 {
     InitializeComponent();
     this.database = database;
     this.parent = parent;
     this.machine = machine;
     this.controller = new Controller(database);
 }
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                // Prebuild Existing Employee ID list for comparison
                List<string> existingIDList = new List<string>();
                foreach (Employee employee in database.SelectAllEmployee())
                {
                    existingIDList.Add(employee.EmployeeID);
                }

                string fName = textBox1.Text;
                string lName = textBox2.Text;
                string position = textBox3.Text;
                string location = textBox4.Text;
                string payRateString = textBox5.Text;
                string employeeID = textBox6.Text;
                string dateTimeString = textBox7.Text;

                if (!existingIDList.Contains(employeeID))
                {
                    if (fName != "" & fName != null &
                        lName != "" & lName != null &
                        position != "" & position != null &
                        location != "" & location != null &
                        employeeID != "" & employeeID != null)
                    {
                        float payRate = float.Parse(payRateString);
                        DateTime dateStarted = DateTime.Parse(dateTimeString);

                        // Create Record
                        Controller controller = new Controller(database);
                        controller.AddEmployee(fName, lName, employeeID, location, position, payRate, dateStarted);
                        this.parent.LoadEmployeesDataGrid();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Please enter all employee information");
                    }
                }
                else
                {
                    MessageBox.Show("That Employee ID already exists. Please select a new ID.");
                }

            }
            catch
            {
                MessageBox.Show("Invalid Entries - Please enter employee information.");
            }
        }
Example #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                // Prebuild Existing Machine ID list for comparison
                List<string> existingIDList = new List<string>();
                foreach (Machine machine in database.SelectAllMachine())
                {
                    existingIDList.Add(machine.MachineID);
                }

                string productType = textBox1.Text;
                string maxCapacityString = textBox2.Text;
                string city = textBox3.Text;
                string location = textBox4.Text;
                string minimumStockString = textBox5.Text;
                string machineID = textBox6.Text;

                if (!existingIDList.Contains(machineID))
                {
                    if (productType != "" & productType != null &
                        maxCapacityString != "" & maxCapacityString != null &
                        city != "" & city != null &
                        location != "" & location != null &
                        minimumStockString != "" & minimumStockString != null &
                        machineID != "" & machineID != null)
                    {
                        int maxCapacity = int.Parse(maxCapacityString);
                        int minimumStock = int.Parse(minimumStockString);

                        // Create Record
                        Controller controller = new Controller(database);
                        controller.AddMachine(machineID, city, location, maxCapacity, minimumStock, productType);
                        this.parent.LoadMachineListAllDataGrid();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Please enter all employee information");
                    }
                }
                else
                {
                    MessageBox.Show("That Employee ID already exists. Please select a new ID.");
                }

            }
            catch
            {
                MessageBox.Show("Invalid Entries - Please enter employee information.");
            }
        }
Example #4
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            try
            {
                string name = textBox8.Text;
                string wholeSalePriceString = textBox7.Text;
                string quantityString = textBox1.Text;

                if (name != "" & name != null &
                    wholeSalePriceString != "" & wholeSalePriceString != null &
                    quantityString != "" & quantityString != null )
                {
                    float wholeSalePrice = float.Parse(wholeSalePriceString);
                    int quantity = int.Parse(quantityString);

                    if (quantity > 0)
                    {
                        DialogResult confirm = MessageBox.Show("You are about to purchase " + quantityString + " " + name + " for a total of $" + Convert.ToString(quantity * wholeSalePrice) + ".\nPlease confirm this is accurate.",
                        "Confirm Delete",
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Exclamation,
                        MessageBoxDefaultButton.Button2);

                        if (confirm == DialogResult.Yes)
                        {
                            // Create Record
                            Controller controller = new Controller(database);
                            controller.AddProduct(name, wholeSalePrice, quantity);
                            this.parent.LoadProductWarehouseDataGrid();
                            this.Close();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please enter quantity larger than 0.");
                    }
                }
                else
                {
                    MessageBox.Show("Please enter a product name and purchase price.");
                }

            }
            catch
            {
                MessageBox.Show("Invalid Entries - Please enter a product name and purchase price.");
            }
        }
Example #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                List<string> existingIDList = new List<string>();
                foreach (City city in database.SelectAllCity())
                {
                    existingIDList.Add(city.ID);
                }

                string cityName = textBox8.Text;
                string state = textBox7.Text;
                string ID = textBox1.Text;
                if (!existingIDList.Contains(ID))
                {
                    if (cityName != "" & cityName != null &
                        state != "" & state != null &
                        ID != "" & ID != null)
                    {
                        // Create Record
                        Controller controller = new Controller(database);
                        controller.AddCity(cityName, state, ID);
                        this.parent.LoadCityMachinesDataGrid();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Please enter a City, State, and a uniquie ID.");
                    }
                }
                else
                {
                    MessageBox.Show("ID already exists. Please enter a uniqueID.");
                }

            }
            catch
            {
                MessageBox.Show("Invalid Entries - Please enter a City, State, and a uniquie ID.");
            }
        }
Example #6
0
        private void button5_Click(object sender, EventArgs e)
        {
            List<string> employeeIdToRemove = new List<string>();
            if (EmployeesDataGrid.SelectedRows.Count > 0)
            {
                foreach (DataGridViewRow row in EmployeesDataGrid.SelectedRows)
                {
                    //MessageBox.Show( row.Cells["EmployeeID"].Value.ToString());
                    if (!employeeIdToRemove.Contains(row.Cells["EmployeeID"].Value.ToString()))
                    {
                        employeeIdToRemove.Add(row.Cells["EmployeeID"].Value.ToString());
                    }
                }

            }
            else if (EmployeesDataGrid.SelectedCells.Count > 0)
            {
                foreach (DataGridViewCell cell in EmployeesDataGrid.SelectedCells)
                {
                    DataGridViewRow row = EmployeesDataGrid.Rows[cell.RowIndex];
                    //MessageBox.Show(row.Cells["EmployeeID"].Value.ToString());
                    if (!employeeIdToRemove.Contains(row.Cells["EmployeeID"].Value.ToString()))
                    {
                        employeeIdToRemove.Add(row.Cells["EmployeeID"].Value.ToString());
                    }
                }
            }

            foreach (string ID in employeeIdToRemove)
            {
                DialogResult confirm = MessageBox.Show("Are you sure you want to Delete employee ID# " + ID,
                    "Confirm Delete",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Exclamation,
                    MessageBoxDefaultButton.Button2);

                if (confirm == DialogResult.Yes)
                {
                    Controller controller = new Controller(database);
                    controller.RemoveEmployee(ID);

                    EmployeesDataGrid.DataSource = null;
                    EmployeesDataGrid.Update();
                    EmployeesDataGrid.Refresh();

                    List<Employee> data;
                    data = this.database.SelectAllEmployee();
                    EmployeesDataGrid.DataSource = data;
                    EmployeesDataGrid.Update();
                    EmployeesDataGrid.Refresh();

                }

            }
        }
Example #7
0
        // Remove City Button
        private void button9_Click(object sender, EventArgs e)
        {
            List<string> CityIdToRemove = new List<string>();
            if (CityMachinesDataGrid.SelectedRows.Count > 0)
            {
                foreach (DataGridViewRow row in CityMachinesDataGrid.SelectedRows)
                {
                    if (!CityIdToRemove.Contains(row.Cells["Name"].Value.ToString()))
                    {
                        CityIdToRemove.Add(row.Cells["Name"].Value.ToString());
                    }
                }

            }
            else if (CityMachinesDataGrid.SelectedCells.Count > 0)
            {
                foreach (DataGridViewCell cell in CityMachinesDataGrid.SelectedCells)
                {
                    DataGridViewRow row = CityMachinesDataGrid.Rows[cell.RowIndex];
                    if (!CityIdToRemove.Contains(row.Cells["Name"].Value.ToString()))
                    {
                        CityIdToRemove.Add(row.Cells["Name"].Value.ToString());
                    }
                }
            }

            foreach (string ID in CityIdToRemove)
            {
                DialogResult confirm = MessageBox.Show("Are you sure you want to Delete City ID# " + ID,
                    "Confirm Delete",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Exclamation,
                    MessageBoxDefaultButton.Button2);

                if (confirm == DialogResult.Yes)
                {
                    Controller controller = new Controller(database);
                    controller.RemoveCity(ID);
                    this.LoadCityMachinesDataGrid();
                }
            }
        }
Example #8
0
        //
        // Remove Button Control Methods
        //
        // Product Remove Button
        private void button3_Click_1(object sender, EventArgs e)
        {
            List<string> ProductIdToRemove = new List<string>();
            List<int> rowsProcessedAlready = new List<int>();
            if (ProductWarehouseDataGrid.SelectedRows.Count > 0)
            {
                foreach (DataGridViewRow row in ProductWarehouseDataGrid.SelectedRows)
                {
                    if (!rowsProcessedAlready.Contains(row.Index))
                    {
                        ProductIdToRemove.Add(row.Cells["Product Type"].Value.ToString());
                        rowsProcessedAlready.Add(row.Index);
                    }
                }

            }
            else if (ProductWarehouseDataGrid.SelectedCells.Count > 0)
            {
                foreach (DataGridViewCell cell in ProductWarehouseDataGrid.SelectedCells)
                {
                    DataGridViewRow row = ProductWarehouseDataGrid.Rows[cell.RowIndex];
                    if (!rowsProcessedAlready.Contains(row.Index))
                    {
                        ProductIdToRemove.Add(row.Cells["Product Type"].Value.ToString());
                        rowsProcessedAlready.Add(row.Index);
                    }
                }
            }

            foreach (string ID in ProductIdToRemove)
            {
                //DialogResult confirm = MessageBox.Show("Are you sure you want to Delete product ID " + ID,
                //    "Confirm Delete",
                //    MessageBoxButtons.YesNo,
                //    MessageBoxIcon.Exclamation,
                //    MessageBoxDefaultButton.Button2);

                //if (confirm == DialogResult.Yes)
                if (true)
                {
                    Controller controller = new Controller(database);
                    controller.RemoveProduct(ID);
                    this.LoadProductWarehouseDataGrid();
                }
            }
        }