private bool validateRequest(string matType, int qty)
        {
            MaterialUpdate mtup = new Aklan_International.MaterialUpdate(empID);

            int[] matArray = mtup.retrieveMaterial();

            if (matType == "sheet" && matArray[0] > qty)
            {
                return(true);
            }
            else if (matType == "cut strip" && matArray[1] > qty)
            {
                return(true);
            }
            else if (matType == "clip cut" && matArray[2] > qty)
            {
                return(true);
            }
            else if (matType == "folded 12" && matArray[3] > qty)
            {
                return(true);
            }
            else if (matType == "folded single" && matArray[4] > qty)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private void btnMark_Click(object sender, EventArgs e)
        {
            Job            selectedJob = (Job)jobList[lbxCurrentJobs.SelectedIndex];
            MaterialUpdate mtup        = new Aklan_International.MaterialUpdate(selectedJob.getEmpID());

            conn = new MySqlConnection("Server=localhost;Database=dbcore;Uid=root;Pwd=1234");
            selectedJob.setFinished(true);
            cmd = new MySqlCommand("UPDATE `dbcore`.`dt" + selectedJob.getEmpID() + "` SET `finished`='yes' WHERE `index`='" + selectedJob.getIndex() + "' ", conn);
            conn.Open();
            if (cmd.ExecuteNonQuery() >= 0)
            {
                int outMatqty;
                SalaryCalc.updateSalary(selectedJob.getEmpID(), selectedJob.getQty() * SalaryCalc.getRate(selectedJob.getJob()));
                while (true)
                {
                    try
                    {
                        outMatqty = int.Parse(Microsoft.VisualBasic.Interaction.InputBox("Enter output qty", "Get Info", "0", -1, -1));
                        break;
                    }
                    catch
                    {
                        MessageBox.Show("Enter a valid integer!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        continue;
                    }
                }
                mtup.updateMaterial(selectedJob.getOutputMaterialType(), outMatqty, empID, false);
                MessageBox.Show("Success!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            conn.Close();
            refreshJobs();
        }
        private void btnMarkOrders_Click(object sender, EventArgs e)
        {
            Order          selectedOrder = (Order)orderList[lbxCurrentOrders.SelectedIndex];
            MaterialUpdate mtup          = new Aklan_International.MaterialUpdate(empID);

            conn = new MySqlConnection("Server=localhost;Database=dbcore;Uid=root;Pwd=1234");
            selectedOrder.setFinished();
            cmd = new MySqlCommand("UPDATE `dbcore`.`dtcustomer_orders` SET `finished`='yes' WHERE `OrderId`='" + selectedOrder.getOrderID() + "' ", conn);
            conn.Open();
            if (cmd.ExecuteNonQuery() >= 0)
            {
                mtup.updateMaterial("folded single", selectedOrder.getSingleQty(), empID, true);
                mtup.updateMaterial("folded 12", selectedOrder.getDozenQty(), empID, true);
                MessageBox.Show("Success!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            conn.Close();
            refreshOrders();
        }
        private void btnRequest_Click(object sender, EventArgs e)
        {
            int index = retrieveIndex();

            Dictionary <String, String> mydic = new Dictionary <string, string>();

            mydic.Add("Cutting", "sheet");
            mydic.Add("Clip Cutting", "cut strip");
            mydic.Add("Folding 12", "clip cut");
            mydic.Add("Folding Single", "clip cut");
            mydic.Add("Rimming 12", "folded 12");
            mydic.Add("Rimming Single", "folded single");
            string matType;

            mydic.TryGetValue(cmbJob.Text.Trim(), out matType);

            MaterialUpdate mtup = new Aklan_International.MaterialUpdate(empID);

            if (validateRequest(matType, (int)spnQty.Value))
            {
                try
                {
                    cmd = new MySqlCommand("INSERT INTO `dbcore`.`dt" + empID.ToString() + "` (`index`, `date`, `matType`,`job`, `Qty`, `finished`) VALUES ('" + index + "', '" + DateTime.Today.Date.ToShortDateString() + "', '" + matType + "', '" + cmbJob.Text.Trim() + "', '" + spnQty.Value.ToString() + "', 'no')", conn);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    conn.Close();
                    mtup.updateMaterial(matType, (int)spnQty.Value, empID, true);
                    MessageBox.Show("Success!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch
                {
                    MessageBox.Show("Sorry. Operation failed.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //throw;
                }
            }
            else
            {
                MessageBox.Show("Request can't obtained. Please try another material or fewer Qty!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }