private void button2_Click(object sender, EventArgs e) { int carId; if (!int.TryParse(textBox1.Text, out carId)) { MessageBox.Show($"Please check car id ({textBox1.Text}) is not valid car id.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var db = new Database(); db.AddParameter("@carId", carId); DataTable dt = db.ExecuteDataTable("select * from booking where status=1 and carId=@carId"); if (dt.Rows.Count == 0) { MessageBox.Show($"This car (Car Id:{carId}) is not booking.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } db.AddParameter("@carId", carId); db.ExecuteNonQuery("update booking set status = 0 where status=1 and carId=@carId"); MessageBox.Show("Car has been returned successfully.", "Return", MessageBoxButtons.OK, MessageBoxIcon.Information); var main = new MainOption(); main.Show(); this.Hide(); }
private void button1_Click(object sender, EventArgs e) { var db = new Database(); db.AddParameter("@username", textBox1.Text); db.AddParameter("@password", textBox2.Text); DataTable loginInfo = db.ExecuteDataTable("select * from customer where username=@username and password=@password"); if (loginInfo.Rows.Count <= 0) { MessageBox.Show("Error customer information.", "Error login", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Program.FormData = new FormData { Customer = new Customer { Id = int.Parse(loginInfo.Rows[0]["id"].ToString()), Name = loginInfo.Rows[0]["name"].ToString(), Age = int.Parse(loginInfo.Rows[0]["age"].ToString()), UserName = loginInfo.Rows[0]["username"].ToString(), Gender = loginInfo.Rows[0]["gender"].ToString() } }; var mainOption = new MainOption(); mainOption.Show(); this.Hide(); }
void GetMenuOptionFromControllerXBOX() { if (((Input.GetAxisRaw("X360_LStickY01") < 0)) || ((Input.GetAxisRaw("X360_LStickY02") < 0)) || ((Input.GetAxisRaw("X360_LStickY03") < 0)) || ((Input.GetAxisRaw("X360_LStickY04") < 0))) { MainMenuOption = MainOption.CREDITS; } if (((Input.GetAxisRaw("X360_LStickY01") > 0)) || ((Input.GetAxisRaw("X360_LStickY02") > 0)) || ((Input.GetAxisRaw("X360_LStickY03") > 0)) || ((Input.GetAxisRaw("X360_LStickY04") > 0))) { MainMenuOption = MainOption.PLAY; } switch (MainMenuOption) { case MainOption.PLAY: playText.color = Color.white; creditsText.color = Color.gray; break; case MainOption.CREDITS: playText.color = Color.gray; creditsText.color = Color.white; break; } }