private void btnLogin_Click(object sender, EventArgs e) { MySqlCommand cmd = new MySqlCommand(); cmd.Connection = Clase_ConeccionDB.obtenerConeccion(); try { cmd.CommandText = "select count(*) from usuario where nombre ='" + txtUsuario.Text + "'and pass = '******'and administrador ='1';"; int valor = int.Parse(cmd.ExecuteScalar().ToString()); if (valor == 1) { Formulario_Principal f = new Formulario_Principal(); f.Show(); f.finanzasToolStripMenuItem.Enabled = true; this.Hide(); } cmd.CommandText = "select count(*) from usuario where nombre ='" + txtUsuario.Text + "'and pass = '******'and administrador ='0';"; valor = int.Parse(cmd.ExecuteScalar().ToString()); if (valor == 1) { MessageBox.Show("Ud No es administrador pero puede acceder"); } cmd.CommandText = "select count(*) from usuario where nombre ='" + txtUsuario.Text + "'and pass = '******';"; valor = int.Parse(cmd.ExecuteScalar().ToString()); if (valor == 0) { MessageBox.Show("NO puede acceder"); } } catch (Exception ex) { MessageBox.Show("Error en " + ex); } Clase_ConeccionDB.obtenerConeccion().Close(); }
public List <CatProducto> seleccionarCatProducto() { List <CatProducto> listaCtProducto = new List <CatProducto>(); MySqlCommand Comando = new MySqlCommand(); Comando.Connection = Clase_ConeccionDB.obtenerConeccion(); Comando.CommandType = CommandType.StoredProcedure; Comando.CommandText = "selectCatProduto"; try { IDataReader lector = Comando.ExecuteReader(); while (lector.Read()) { CatProducto _catProduto = new CatProducto(); _catProduto.Id = int.Parse(lector[0].ToString()); _catProduto.Categoria = lector[1].ToString(); listaCtProducto.Add(_catProduto); } } catch (Exception ex) { string m = ex.Message; Comando.Dispose(); } finally { } return(listaCtProducto); }
public string[] seleccionarStatusMesa() { string[] arraymesas = new string[12]; MySqlCommand Comando = new MySqlCommand(); Comando.Connection = Clase_ConeccionDB.obtenerConeccion(); Comando.CommandType = System.Data.CommandType.StoredProcedure; Comando.CommandText = "selectMesa"; try { int i = 0; IDataReader lector = Comando.ExecuteReader(); while (lector.Read()) { mesa _municipi = new mesa(); arraymesas[i] = lector[2].ToString(); i++; } arraymesas[i + 1] = "fin"; } catch (Exception ex) { string m = ex.Message; Comando.Dispose(); } finally { } return(arraymesas); }
private void button1_Click(object sender, EventArgs e) { if ((txtNit.Text != "") && (txtNombre.Text != "") && (txtDireccion.Text != "")) { int resultado = 0; MySqlCommand comando = new MySqlCommand(string.Format("call nuevoCliente('" + txtNit.Text + "','" + txtNombre.Text + "','" + txtDireccion.Text + "')"), Clase_ConeccionDB.obtenerConeccion()); resultado = comando.ExecuteNonQuery(); if (resultado > 0) { MessageBox.Show("¡Bien Hecho! Los datos se han guardado con éxito.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); txtNit.Clear(); txtNombre.Clear(); txtDireccion.Clear(); txtNit.Focus(); } else { MessageBox.Show("¡Cuidado! A ocurrido un error al ingresar los datos.", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("¡Cuidado! No pueden permanecer campos Vacios.", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void button3_Click(object sender, EventArgs e) { if ((txtNom.Text != "") && (txtDir.Text != "")) { int resultado = 0; MySqlCommand comando = new MySqlCommand(string.Format("UPDATE clientes SET nombre ='" + txtNom.Text + "', direccion='" + txtDir.Text + "' WHERE nit ='" + txtBusqueda.Text + "';"), Clase_ConeccionDB.obtenerConeccion()); resultado = comando.ExecuteNonQuery(); if (resultado > 0) { MessageBox.Show("¡Bien Hecho! Los datos se han guardado con éxito.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); txtBusqueda.Clear(); txtBusqueda.Enabled = true; panel7.Visible = false; } else { MessageBox.Show("¡Cuidado! A ocurrido un error al ingresar los datos.", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("¡Cuidado! No pueden permanecer campos Vacios.", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void button2_Click(object sender, EventArgs e) { panel7.Visible = true; txtBusqueda.Enabled = false; MySqlCommand comando = new MySqlCommand(string.Format("SELECT nombre, direccion FROM clientes WHERE nit = '" + txtBusqueda.Text + "'"), Clase_ConeccionDB.obtenerConeccion()); MySqlDataReader reader = comando.ExecuteReader(); while (reader.Read()) { txtNom.Text = reader.GetString(0); txtDir.Text = reader.GetString(1); } }