private void txtPassword_KeyDown(object sender, KeyEventArgs e) { try { if (e.KeyCode == Keys.Enter) { string query = "select User_Name from users where User_Name=@Name and Password=@Pass and (User_Type=0 or User_Type=1)"; conn.Open(); MySqlCommand comand = new MySqlCommand(query, conn); comand.Parameters.AddWithValue("@Name", txtName.Text); comand.Parameters.AddWithValue("@Pass", txtPassword.Text); var result = comand.ExecuteScalar(); conn.Close(); if (result != null) { CarsMainForm f = new CarsMainForm(); f.Show(); this.Hide(); } else { txtPassword.Focus(); MessageBox.Show("Enter correct password"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public CarExpenses(CarsMainForm carsMainForm) { try { InitializeComponent(); dbconnection = new MySqlConnection(connection.connectionString); this.carsMainForm = carsMainForm; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public CarSpareParts(DataRowView CarRow, Cars cars, XtraTabControl xtraTabControlCarsContent, CarsMainForm carsMainForm) { try { InitializeComponent(); dbconnection = new MySqlConnection(connection.connectionString); this.CarRow = CarRow; labStoreName.Text = CarRow[1].ToString(); CarId = Convert.ToInt16(CarRow[0].ToString()); this.cars = cars; this.xtraTabControlCarsContent = xtraTabControlCarsContent; this.carsMainForm = carsMainForm; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public CarLicenseUpdate(string carId, string carNum, XtraTabControl xtraTabControlCarsContent, CarsMainForm carsMainForm) { try { InitializeComponent(); dbconnection = new MySqlConnection(connection.connectionString); this.xtraTabControlCarsContent = xtraTabControlCarsContent; this.carsMainForm = carsMainForm; txtCarNumber.Text = carNum; CarId = Convert.ToInt16(carId); flag = true; } catch (Exception ex) { MessageBox.Show(ex.Message); } dbconnection.Close(); }
public CarLicenseUpdate(DataRowView CarRow, Cars cars, XtraTabControl xtraTabControlCarsContent, CarsMainForm carsMainForm) { try { InitializeComponent(); dbconnection = new MySqlConnection(connection.connectionString); this.carsMainForm = carsMainForm; this.CarRow = CarRow; this.xtraTabControlCarsContent = xtraTabControlCarsContent; txtCarNumber.Text = CarRow[1].ToString(); CarId = Convert.ToInt16(CarRow[0].ToString()); } catch (Exception ex) { MessageBox.Show(ex.Message); } dbconnection.Close(); }
private void btnLogin_Click(object sender, EventArgs e) { try { string query = "select User_ID,User_Name from users where User_Name=@Name and Password=@Pass and (User_Type=0 or User_Type=1)"; conn.Open(); MySqlCommand comand = new MySqlCommand(query, conn); comand.Parameters.AddWithValue("@Name", txtName.Text); comand.Parameters.AddWithValue("@Pass", txtPassword.Text); MySqlDataReader result = comand.ExecuteReader(); if (result != null) { while (result.Read()) { UserControl.userID = (int)result[0]; UserControl.userName = result[1].ToString(); CarsMainForm f = new CarsMainForm(); f.Show(); } this.Hide(); } else { MessageBox.Show("please try again"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } conn.Close(); }