private void OrderInfo_Load(object sender, EventArgs e) { MySQLConnection db = new MySQLConnection(); db.OpenConn(); String cmmd = "SELECT * FROM `Restaurant`.`order_table`; "; MySqlDataAdapter dataAdapter = new MySqlDataAdapter(cmmd, db.getConnection()); DataSet ds = new DataSet(); dataAdapter.Fill(ds, "order"); db.CloseConn(); dataGridView1.DataSource = ds; dataGridView1.DataMember = "order"; }
private void FloorInfo_Load(object sender, EventArgs e) { MySQLConnection dbFloor = new MySQLConnection(); dbFloor.OpenConn(); String cmmd = "SELECT * FROM reservation"; MySqlDataAdapter dataAdapter = new MySqlDataAdapter(cmmd, dbFloor.getConnection()); DataSet ds = new DataSet(); dataAdapter.Fill(ds, "reservation"); dbFloor.CloseConn(); dataGridView1.DataSource = ds; dataGridView1.DataMember = "reservation"; }
private void button1_Click(object sender, EventArgs e) { String d = monthCalendar1.SelectionRange.Start.ToShortDateString(); //d = (d.Insert(0, d.Remove(0, 6)+ "/")); //d = d.Remove(10); d = d + " " + time + ":00"; d = d.Replace("/", "-"); String numPeople = textBox1.Text; //d=d.Insert(0, "'"); //d = d.Insert(d.Length, "'"); if (d == null) { MessageBox.Show("Please pick a valid date and time"); return; } if (checkRes(d) == false) { MySQLConnection db = new MySQLConnection(); db.OpenConn(); MySqlCommand mySqlCommand = new MySqlCommand("INSERT INTO reservation (date,reservation_people,client_name) VALUES (@d,@num,@name)", db.getConnection()); mySqlCommand.Parameters.Add("@d", MySqlDbType.VarChar).Value = d; mySqlCommand.Parameters.Add("@num", MySqlDbType.Int16).Value = numPeople; mySqlCommand.Parameters.Add("@name", MySqlDbType.VarChar).Value = textBox2.Text; if (mySqlCommand.ExecuteNonQuery() == 1) { MessageBox.Show("Reservation created"); } else { MessageBox.Show("Reservation not created"); } db.CloseConn(); } }
private void pictureBox2_Click(object sender, EventArgs e) { MySQLConnection db = new MySQLConnection(); db.OpenConn(); MySqlCommand command = new MySqlCommand("UPDATE `Restaurant`.`table_info` SET `taken` = @taken,`clean` = @clean WHERE tableID = 2;", db.getConnection()); MySqlCommand command2 = new MySqlCommand("SELECT taken FROM table_info WHERE tableID = 2", db.getConnection()); MySqlDataReader reader = null; int taken = 0; try { reader = command2.ExecuteReader(); while (reader.Read()) { taken = reader.GetInt32(0); } reader.Close(); } catch (Exception r) { MessageBox.Show("! " + e.ToString()); } command2 = new MySqlCommand("SELECT clean FROM table_info WHERE tableID = 2", db.getConnection()); reader = null; int clean = 0; try { reader = command2.ExecuteReader(); while (reader.Read()) { clean = reader.GetInt32(0); } reader.Close(); } catch (Exception r) { MessageBox.Show("! " + e.ToString()); } if (taken == 1) { command.Parameters.Add("@taken", MySqlDbType.Int16).Value = 0; command.Parameters.Add("@clean", MySqlDbType.Int16).Value = 0; } else if (taken == 0 && clean == 0) { command.Parameters.Add("@taken", MySqlDbType.Int16).Value = 0; command.Parameters.Add("@clean", MySqlDbType.Int16).Value = 1; } else { command.Parameters.Add("@taken", MySqlDbType.Int16).Value = 1; command.Parameters.Add("@clean", MySqlDbType.Int16).Value = 0; } command.ExecuteNonQuery(); db.CloseConn(); setTableSeating(); }
public void setTableSeating() { MySQLConnection db = new MySQLConnection(); db.OpenConn(); MySqlCommand command = new MySqlCommand("SELECT taken FROM table_info WHERE tableID = 1", db.getConnection()); MySqlDataReader reader = null; int taken = 0; try { reader = command.ExecuteReader(); while (reader.Read()) { taken = reader.GetInt32(0); } reader.Close(); } catch (Exception e) { MessageBox.Show("! " + e.ToString()); } command = new MySqlCommand("SELECT clean FROM table_info WHERE tableID = 1", db.getConnection()); reader = null; int clean = 0; try { reader = command.ExecuteReader(); while (reader.Read()) { clean = reader.GetInt32(0); } reader.Close(); } catch (Exception e) { MessageBox.Show("! " + e.ToString()); } if (taken == 1) { pictureBox1.BackColor = Color.Red; } else { if (clean == 1) { pictureBox1.BackColor = Color.Green; } else { pictureBox1.BackColor = Color.Orange; } } command = new MySqlCommand("SELECT taken FROM table_info WHERE tableID = 2", db.getConnection()); //command.Parameters.Add("@userID", MySqlDbType.VarChar).Value = userID; reader = null; taken = 0; try { reader = command.ExecuteReader(); while (reader.Read()) { taken = reader.GetInt32(0); } reader.Close(); } catch (Exception e) { MessageBox.Show("! " + e.ToString()); } command = new MySqlCommand("SELECT clean FROM table_info WHERE tableID = 2", db.getConnection()); reader = null; clean = 0; try { reader = command.ExecuteReader(); while (reader.Read()) { clean = reader.GetInt32(0); } reader.Close(); } catch (Exception e) { MessageBox.Show("! " + e.ToString()); } if (taken == 1) { pictureBox2.BackColor = Color.Red; } else { if (clean == 1) { pictureBox2.BackColor = Color.Green; } else { pictureBox2.BackColor = Color.Orange; } } command = new MySqlCommand("SELECT taken FROM table_info WHERE tableID = 3", db.getConnection()); //command.Parameters.Add("@userID", MySqlDbType.VarChar).Value = userID; reader = null; taken = 0; try { reader = command.ExecuteReader(); while (reader.Read()) { taken = reader.GetInt32(0); } reader.Close(); } catch (Exception e) { MessageBox.Show("! " + e.ToString()); } command = new MySqlCommand("SELECT clean FROM table_info WHERE tableID = 3", db.getConnection()); reader = null; clean = 0; try { reader = command.ExecuteReader(); while (reader.Read()) { clean = reader.GetInt32(0); } reader.Close(); } catch (Exception e) { MessageBox.Show("! " + e.ToString()); } if (taken == 1) { pictureBox3.BackColor = Color.Red; } else { if (clean == 1) { pictureBox3.BackColor = Color.Green; } else { pictureBox3.BackColor = Color.Orange; } } db.CloseConn(); }
private void butSignUp_Click(object sender, EventArgs e) { //empty name field if (string.IsNullOrEmpty(txtFullName.Text)) { MessageBox.Show("Please enter your name.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtFullName.Focus(); String name = txtFullName.Text; return; } //empty email if (string.IsNullOrEmpty(txtEmail.Text)) { MessageBox.Show("Please enter your email.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtEmail.Focus(); String email = txtEmail.Text; return; } //empty password if (string.IsNullOrEmpty(txtPass.Text)) { MessageBox.Show("Please enter your password.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtPass.Focus(); String pass = txtPass.Text; return; } //empty password if (string.IsNullOrEmpty(txtConfirmPass.Text)) { MessageBox.Show("Please confirm your password.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtConfirmPass.Focus(); String conPass = txtConfirmPass.Text; return; } if (txtPass.Text != txtConfirmPass.Text) { if (txtPass.Text != txtConfirmPass.Text) { MessageBox.Show("Passwords do not match!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return; } MySQLConnection db = new MySQLConnection(); db.OpenConn(); if (checkUsername()) { MessageBox.Show("This username already exists, please select a different one"); } else { MySqlCommand mySqlCommand = new MySqlCommand("INSERT INTO login (user_name,passwords) VALUES (@un,@pass)", db.getConnection()); mySqlCommand.Parameters.Add("@un", MySqlDbType.VarChar).Value = txtFullName.Text; mySqlCommand.Parameters.Add("@pass", MySqlDbType.VarChar).Value = txtPass.Text; if (mySqlCommand.ExecuteNonQuery() == 1) { MessageBox.Show("Account created"); var nextForm = new MainPage(); nextForm.Show(); this.Close(); } else { MessageBox.Show("Account not created"); } db.CloseConn(); } }
private void butSignUp_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBox_FirstName.Text)) { MessageBox.Show("Please enter a first name.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); textBox_FirstName.Focus(); String name = textBox_FirstName.Text; return; } if (string.IsNullOrEmpty(textBox_LastName.Text)) { MessageBox.Show("Please enter a last name.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); textBox_LastName.Focus(); String name = textBox_LastName.Text; return; } //empty name field if (string.IsNullOrEmpty(txtFullName.Text)) { MessageBox.Show("Please enter a username.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtFullName.Focus(); String name = txtFullName.Text; return; } //empty email if (string.IsNullOrEmpty(txtEmail.Text)) { MessageBox.Show("Please enter your email.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtEmail.Focus(); String email = txtEmail.Text; return; } //empty password if (string.IsNullOrEmpty(txtPass.Text)) { MessageBox.Show("Please enter your password.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtPass.Focus(); String pass = txtPass.Text; return; } //empty password if (string.IsNullOrEmpty(txtConfirmPass.Text)) { MessageBox.Show("Please confirm your password.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtConfirmPass.Focus(); String conPass = txtConfirmPass.Text; return; } if (txtPass.Text != txtConfirmPass.Text) { if (txtPass.Text != txtConfirmPass.Text) { MessageBox.Show("Passwords do not match!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return; } MySQLConnection db = new MySQLConnection(); db.OpenConn(); if (checkUsername()) { MessageBox.Show("This username already exists, please select a different one"); } else { int maxID = getMaxID(); MySqlCommand mySqlCommand = new MySqlCommand("INSERT INTO login (user_name,passwords,id) VALUES (@un,@pass,@id)", db.getConnection()); mySqlCommand.Parameters.Add("@un", MySqlDbType.VarChar).Value = txtFullName.Text; mySqlCommand.Parameters.Add("@pass", MySqlDbType.VarChar).Value = txtPass.Text; mySqlCommand.Parameters.Add("@id", MySqlDbType.Int32).Value = maxID + 1; MySqlCommand mySqlCommand2 = new MySqlCommand("INSERT INTO staff_info (first_name,last_name,id,email,parent_id,address_id,phone) VALUES (@first,@last,@id,@email,@parent,@address,@phone)", db.getConnection()); mySqlCommand2.Parameters.Add("@id", MySqlDbType.Int32).Value = maxID + 1; mySqlCommand2.Parameters.Add("@email", MySqlDbType.VarChar).Value = txtEmail.Text; mySqlCommand2.Parameters.Add("@address", MySqlDbType.VarChar).Value = textBox_Address.Text; mySqlCommand2.Parameters.Add("@phone", MySqlDbType.VarChar).Value = textBox_Phone.Text; mySqlCommand2.Parameters.Add("@first", MySqlDbType.VarChar).Value = textBox_FirstName.Text; mySqlCommand2.Parameters.Add("@last", MySqlDbType.VarChar).Value = textBox_LastName.Text; if (comboBox1.SelectedItem.Equals("Owner")) { mySqlCommand2.Parameters.Add("@parent", MySqlDbType.Int32).Value = 1; } else { mySqlCommand2.Parameters.Add("@parent", MySqlDbType.Int32).Value = 2; } if (mySqlCommand.ExecuteNonQuery() == 1 && mySqlCommand2.ExecuteNonQuery() == 1) { MessageBox.Show("Account created"); user = setUser(maxID + 1); var nextForm = new MainPage(user); nextForm.Show(); this.Close(); } else { MessageBox.Show("Account not created"); } db.CloseConn(); } }