public AddClient(UserForm parent, String connection) { this.parent1 = parent; this.connection = connection; InitializeComponent(); }
private void button1_Click(object sender, EventArgs e) { if (this.comboBox1.Text.ToString() == "Pavlo") this.connection = "SERVER=PAULIG\\SQLEXPRESS;Database=Cinema;Trusted_Connection=true"; else if (this.comboBox1.Text.ToString() == "Doorota") this.connection = "SERVER=ZWIERZYNIEC;Database=Cinema;Trusted_Connection=true"; else if (this.comboBox1.Text.ToString() == "Klaudia") this.connection = "SERVER=KLAUDIA\\SQLEXPRESS;Database=Cinema;Trusted_Connection=true"; if (this.comboBox1.Text.ToString() != "") { SqlConnection selectConnection = new SqlConnection(this.connection); selectConnection.Open(); SqlDataAdapter sqlDataAdapter = new SqlDataAdapter("SELECT IS_ADMIN FROM LOG_IN WHERE USERNAME='******' AND PASSWORD='******'", selectConnection); DataTable dataTable = new DataTable(); sqlDataAdapter.Fill(dataTable); if (dataTable.Rows.Count == 1) { if (dataTable.Rows[0][0].ToString() == "True") { sqlDataAdapter = new SqlDataAdapter("SELECT ID_LOGIN FROM LOG_IN WHERE USERNAME='******'", selectConnection); dataTable = new DataTable(); sqlDataAdapter.Fill(dataTable); sqlDataAdapter = new SqlDataAdapter("SELECT ID_CINEMA FROM EMPLOYEES e JOIN LOG_IN l ON l.ID_EMPLOYEE=e.ID_EMPLOYEE WHERE ID_LOGIN="******"False")) return; sqlDataAdapter = new SqlDataAdapter("SELECT ID_LOGIN FROM LOG_IN WHERE USERNAME='******'", selectConnection); dataTable = new DataTable(); sqlDataAdapter.Fill(dataTable); sqlDataAdapter = new SqlDataAdapter("SELECT e.ID_EMPLOYEE FROM EMPLOYEES e JOIN LOG_IN l ON l.ID_EMPLOYEE=e.ID_EMPLOYEE WHERE ID_LOGIN="******"Username or password is incorrect", "authentication failed", MessageBoxButtons.OK, MessageBoxIcon.Hand); } } else { int num1 = (int)MessageBox.Show("Choose server first", "Server failed", MessageBoxButtons.OK, MessageBoxIcon.Hand); } }