private void back_button_Click(object sender, EventArgs e) { if (cust_name_input.Text == string.Empty && total_text.Text == string.Empty) { Sales_Page g = new Sales_Page(); g.Show(); this.Hide(); } else { switch (MessageBox.Show("Are you sure you want to leave? \nChanges you have made will not be saved.", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Information)) { case DialogResult.Yes: Homepage g = new Homepage(); g.Show(); this.Hide(); break; case DialogResult.No: break; } } }
private void login_button_Click(object sender, EventArgs e) { // get employees with admin privilege String username = text_user.Text; String password = text_password.Text; string query = "SELECT * FROM employee e, employee_type et WHERE e.emp_type_id_fk=et.emp_type_id and et.emp_type='Admin' and emp_username='******' and emp_password='******';"; DataTable dt = new DataTable(); dt = main.SELECT_Statement(query); // if found if (dt.Rows.Count == 1) { int sid = int.Parse(dt.Rows[0]["emp_id"].ToString()); firstname = dt.Rows[0]["emp_fname"].ToString(); lastname = dt.Rows[0]["emp_lname"].ToString(); Login.name = firstname + " " + lastname; //assign firstname and lastname to the global variable to be used on other forms Login.id = sid; MessageBox.Show("Welcome " + Login.name); // get inventory quantity and prompts if it reaches limit List <string> list2 = new List <string>(); foreach (DataGridViewRow row in inventory_view.Rows) { for (int a = 0; a < inventory_view.Rows.Count - 1; a++) { if (Convert.ToInt32(inventory_view.Rows[a].Cells[5].Value) <= 10) { list2.Add(Convert.ToString(inventory_view.Rows[a].Cells[1].Value)); } } } // get current date and compare to requested check out date to check past deadline job orders List <string> list = new List <string>(); foreach (DataGridViewRow row in job_order_view.Rows) { for (int a = 0; a < job_order_view.Rows.Count - 1; a++) { if (DateTime.Now >= Convert.ToDateTime(job_order_view.Rows[a].Cells[3].Value)) { if (Convert.ToString(job_order_view.Rows[a].Cells[5].Value) == "Finished") { } else { list.Add(Convert.ToString(job_order_view.Rows[a].Cells[0].Value)); Conn.Open(); string query2 = "select * from job_order where status_type_id_fk='1' and job_order_id='" + job_order_view.Rows[a].Cells[0].Value + "';"; DataTable dt2 = new DataTable(); dt2 = main.SELECT_Statement(query2); // if found if (dt2.Rows.Count == 1) { } else { MySqlCommand cmd3 = Conn.CreateCommand(); cmd3.CommandType = CommandType.Text; cmd3.CommandText = "Update job_order set status_type_id_fk='1' where job_order_id ='" + job_order_view.Rows[a].Cells[0].Value + "';"; cmd3.ExecuteNonQuery(); } Conn.Close(); } } } } string i = String.Join(", ", list2.Distinct().ToArray()); // display messagebox showing list of items with 0 inventory quantity MessageBox.Show("Items with 10 or less quantity in the Inventory: \n" + i, "PRIORITY", MessageBoxButtons.OK, MessageBoxIcon.Information); string s = String.Join(", ", list.Distinct().ToArray()); // display messagebox showing list of past deadline job order MessageBox.Show("Job orders past the requested check-out dates: \n Job Orders # " + s, "PRIORITY", MessageBoxButtons.OK, MessageBoxIcon.Information); Homepage g = new Homepage(); g.Show(); this.Hide(); } else if (username is null && password is null) { MessageBox.Show("Enter Username and Password", "Login", MessageBoxButtons.OK, MessageBoxIcon.Warning); }