private void btnADO_Click(object sender, EventArgs e) { //try //{ if (Driver == null) { Driver = new ClassADO(); } opcion = 1; if (frm == null) { frm = new Usuarios(); } frm.Show(); //this.Close(); this.Hide(); //} //catch (Exception ex) //{ // MessageBox.Show("Se ha producido un error: " + ex.Message); //} //finally //{ //} }
/** * Coger el usuario seleccionado y almacenarlo en usuario * Para cuando este en el otro formulario **/ private void butSelecionar_Click(object sender, EventArgs e) { try { if (dataGridView1.RowCount < 1) { MessageBox.Show("No puedes seleccionar un usuario el grid esta vacio"); } else { id = int.Parse(dataGridView1.CurrentRow.Cells[0].Value.ToString()); this.Close(); if (frm == null) { frm = new Usuarios(); } frm.Show(); this.Close(); } } catch (Exception ex) { MessageBox.Show("Se ha producido un error: " + ex.Message); } finally { } }
private void lblLogin_Click(object sender, EventArgs e) { if (txtUsername.ForeColor == Color.Black && txtUsername.Text != "" && txtPassword.ForeColor == Color.Black && txtPassword.Text != "") { cn = new OleDbConnection(); cn.ConnectionString = "Provider='Microsoft.ACE.OLEDB.12.0';Data Source='Usuarios.accdb'"; cn.Open(); string sql = "Select * from Usuario where Username = '******' and Clave = '{1}'"; sql = String.Format(sql, txtUsername.Text.ToLower(), txtPassword.Text.ToLower()); cmd = new OleDbCommand(sql, cn); da = new OleDbDataAdapter(cmd); ds = new DataSet(); da.Fill(ds, "DatosLog"); if (ds.Tables["DatosLog"].Rows.Count != 0) { Var.user = txtUsername.Text.ToLower(); Var.UserRoom = Convert.ToInt32(ds.Tables["DatosLog"].Rows[0].ItemArray[2]); home = true; this.Close(); Usuarios usuarios; usuarios = new Usuarios(); usuarios.Show(); } else MessageBox.Show("That's not a valid Username/Password"); cn.Close(); } else MessageBox.Show("Fill in every field", "Error"); }
private void lblUser_Click(object sender, EventArgs e) { this.Visible = false; if (Var.user == null) { Login login; login = new Login(); login.Show(); } else { Usuarios usuario = new Usuarios(); usuario.Show(); } }