private void btnCrearUsuario_Click(object sender, EventArgs e)//ver usuarios, error de nombres { var dt = ConexionBD.ExecuteQuery("SELECT * FROM APPUSER"); dataGridView1.DataSource = dt; MessageBox.Show("Ususarios obtenidos exitosamente"); }
private void buttonPedidos_Click(object sender, EventArgs e)//Ver pedidos { var dt = ConexionBD.ExecuteQuery("SELECT * FROM APPORDER"); dataGridViewOrders.DataSource = dt; MessageBox.Show("Lista de pedidos obtenidos exitosamente"); }
private void btnVerProductos_Click(object sender, EventArgs e)//Ver productos { var dt = ConexionBD.ExecuteQuery("SELECT * FROM PRODUCT"); dataGridViewProducts.DataSource = dt; MessageBox.Show("Lista de productos obtenidos exitosamente"); }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text.Equals("") || textBox2.Text.Equals("")) { MessageBox.Show("No se pueden dejar campos vacios "); } else { try { ConexionBD.ExecuteNonQuery($"INSERT INTO ADDRESS(address) VALUES (" + $"'{textBox2.Text}')"); MessageBox.Show("Se ha registrado la direccion"); comboBox1_Load(); comboBox2_Load(); textBox1.Clear(); textBox2.Clear(); var dt = ConexionBD.ExecuteQuery("SELECT * FROM ADDRESS"); dataGridView1.DataSource = dt; } catch (Exception ex) { MessageBox.Show("ERROR"); } } }
private void btnVerNegocios_Click(object sender, EventArgs e)//Ver negocios { var dt = ConexionBD.ExecuteQuery("SELECT * FROM BUSINESS"); dataGridViewBus.DataSource = dt; MessageBox.Show("Lista de negocios obtenidos exitosamente"); }
private void buttonSeeBusiness_Click(object sender, EventArgs e) { var dt = ConexionBD.ExecuteQuery("SELECT * FROM BUSINESS"); dataGridViewPedido.DataSource = dt; MessageBox.Show("Negocios obtenidos exitosamente"); }
private void btnVerDirecciones_Click(object sender, EventArgs e)//Ver direcciones { var dt = ConexionBD.ExecuteQuery("SELECT ad.idAddress, ad.address FROM ADDRESS ad WHERE idUser = 1"); dataGridViewDirec.DataSource = dt; MessageBox.Show("Direcciones obtenidas exitosamente"); }
private void button3_Click(object sender, EventArgs e) { if (textBox4.Text.Equals("")) { MessageBox.Show("No se pueden dejar campos vacios "); } else { try { var num = $"SELECT idBusiness FROM BUSINESS WHERE" + $" name ='{comboBox3.SelectedItem.ToString()}'"; var dt = ConexionBD.ExecuteQuery(num); var dr = dt.Rows[0]; var myNum = int.Parse(dt.Rows[0][0].ToString()); ConexionBD.ExecuteNonQuery($"INSERT INTO PRODUCT(idBusiness, name) VALUES (" + $"{myNum}, " + $"'{textBox4.Text}')"); MessageBox.Show("Se ha registrado el producto"); textBox1.Clear(); textBox2.Clear(); textBox4.Clear(); comboBox1_Load(); comboBox2_Load(); comboBox3_Load(); } catch (Exception ex) { MessageBox.Show("ERROR"); } } }
private void button1_Click(object sender, EventArgs e) { SiAdmin sia = new SiAdmin(); NoAdmin noa = new NoAdmin(); try { string Uquery = $"SELECT userType FROM APPUSER WHERE" + $" username ='******'AND " + $" password ='******'"; var dt = ConexionBD.ExecuteQuery(Uquery); var dr = dt.Rows[0]; var admin = Convert.ToString(dr[0].ToString()); if (admin.Equals("true", StringComparison.OrdinalIgnoreCase)) { sia.Show(); this.Hide(); } else { this.Hide(); noa.Show(); } } catch (Exception ex) { MessageBox.Show("Usuario no registrado o los datos ingresados incorrectos", "Error de inicio de sesion", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox1.Text != "") { button2.Enabled = true; try { string Uquery = $"SELECT password FROM APPUSER WHERE" + $" username ='******'"; var dt = ConexionBD.ExecuteQuery(Uquery); var dr = dt.Rows[0]; var upass = Convert.ToString(dr[0].ToString()); textBox3.Text = comboBox1.SelectedItem.ToString(); textBox4.Text = upass; } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { textBox3.Text = ""; button2.Enabled = false; } }
private void button2_Click(object sender, EventArgs e) { if (textBox3.Text.Equals("")) { MessageBox.Show("No se pueden dejar campos vacios "); } else { try { ConexionBD.ExecuteNonQuery("UPDATE APPUSER SET " + $"username= '******', " + $"password= '******' " + $"WHERE username= '******'"); MessageBox.Show("Se han actualizado los datos del usuario"); ComboBox1_Load(); textBox3.Clear(); textBox4.Clear(); var dt = ConexionBD.ExecuteQuery("SELECT * FROM APPUSER"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text.Equals("") || textBox2.Text.Equals("")) { MessageBox.Show("No se pueden dejar campos vacios "); } else { try { ConexionBD.ExecuteNonQuery($"INSERT INTO BUSINESS( name, description) VALUES (" + $"'{textBox1.Text}'," + $"'{textBox2.Text}')"); MessageBox.Show("Se ha registrado la empresa"); var dt = ConexionBD.ExecuteQuery("SELECT * FROM PRODUCT"); textBox1.Clear(); textBox2.Clear(); textBox4.Clear(); comboBox1_Load(); comboBox2_Load(); comboBox3_Load(); } catch (Exception ex) { MessageBox.Show("ERROR"); } } }
private void PoblarControles() { // Actualizar ComboBox comboBox1.DataSource = null; comboBox1.ValueMember = "contrasena"; comboBox1.DisplayMember = "usuario"; //combo contraseñas var contra = ConexionBD.ExecuteQuery("SELECT fullname FROM APPUSER"); var contraCombo = new List <string>(); foreach (DataRow dr in contra.Rows) { contraCombo.Add(dr[0].ToString()); } comboBoxLista.DataSource = contraCombo; var comparar = ConexionBD.ExecuteQuery("SELECT password FROM APPUSER WHERE fullname = '{comboBoxlista}'"); var compararCombo = new List <string>(); foreach (DataRow dr in comparar.Rows) { compararCombo.Add(dr[0].ToString()); } comboBox1.DataSource = compararCombo; }
private void buttonSeeProduct_Click(object sender, EventArgs e) { var dt = ConexionBD.ExecuteQuery("SELECT * FROM PRODUCT"); dataGridViewPedido.DataSource = dt; MessageBox.Show("Productos obtenidos exitosamente"); }
public static void actualizarContra(string usuario, string nuevaContra) { string sql = String.Format( "update appuser set contrasena='{0}' where idUser='******';", nuevaContra, usuario); ConexionBD.ExecuteQuery(sql); }
private void btnVerProductos_Click(object sender, EventArgs e) { var dt = ConexionBD.ExecuteQuery($"SELECT ao.idOrder, ao.createDate, pr.name, au.fullname, " + $" ad.address FROM APPORDER ao, ADDRESS ad, PRODUCT pr, " + $"APPUSER au WHERE ao.idProduct = pr.idProduct " + $"AND ao.idAddress = ad.idAddress AND ad.idUser = au.idUser"); dataGridViewProducts.DataSource = dt; MessageBox.Show("Negocios obtenidos exitosamente"); }
private void Administrador_Load(object sender, EventArgs e) { MessageBox.Show("¡Bienvenido!", "Inicio de sesión exitoso", MessageBoxButtons.OK, MessageBoxIcon.Information); //combo usuario var comparar = ConexionBD.ExecuteQuery("SELECT fullname FROM APPUSER"); var compararCombo = new List <string>(); foreach (DataRow dr in comparar.Rows) { compararCombo.Add(dr[0].ToString()); } comboEliminarUser.DataSource = compararCombo; //combo ordenes var orden = ConexionBD.ExecuteQuery("SELECT * FROM APPORDER"); var ordenCombo = new List <string>(); foreach (DataRow dr in orden.Rows) { ordenCombo.Add(dr[0].ToString()); } //comboUsuarios.DataSource = ordenCombo; //combo negocios var negocio = ConexionBD.ExecuteQuery("SELECT name FROM BUSINESS"); var negocioCombo = new List <string>(); foreach (DataRow dr in negocio.Rows) { negocioCombo.Add(dr[0].ToString()); } comboEliminarBus.DataSource = negocioCombo; //combo producto var producto = ConexionBD.ExecuteQuery("SELECT name FROM PRODUCT"); var productoCombo = new List <string>(); foreach (DataRow dr in producto.Rows) { productoCombo.Add(dr[0].ToString()); } comboBoxProductos.DataSource = productoCombo; //combo id business var product = ConexionBD.ExecuteQuery("SELECT idBusiness FROM BUSINESS"); var productCombo = new List <string>(); foreach (DataRow dr in product.Rows) { productCombo.Add(dr[0].ToString()); } comboProductoBus.DataSource = productCombo; }
private void Form1_Load(object sender, EventArgs e) { try { var dt = ConexionBD.ExecuteQuery("SELECT * FROM APPUSER"); ComboBox1_Load(); } catch (Exception ex) { MessageBox.Show("Ha ocurrido un problema"); } }
private void Usuarios_Load(object sender, EventArgs e) { MessageBox.Show("¡Bienvenido!", "Inicio de sesión exitoso", MessageBoxButtons.OK, MessageBoxIcon.Information); //combo direcciones usuario var direccion = ConexionBD.ExecuteQuery("SELECT address FROM ADDRESS ad WHERE idUser = 1"); var direccionCombo = new List <string>(); foreach (DataRow dr in direccion.Rows) { direccionCombo.Add(dr[0].ToString()); } comboEliminarDireccion.DataSource = direccionCombo; //combo direccion Id var negocio = ConexionBD.ExecuteQuery("SELECT ad.idAddress, ad.address FROM ADDRESS ad WHERE idUser = 1") ; var negocioCombo = new List <string>(); foreach (DataRow dr in negocio.Rows) { negocioCombo.Add(dr[0].ToString()); } comboIdDireccion.DataSource = negocioCombo; //combo producto var producto = ConexionBD.ExecuteQuery("SELECT p.idProduct, p.name FROM PRODUCT p WHERE idBusiness = 1"); var productCombo = new List <string>(); foreach (DataRow dr in producto.Rows) { productCombo.Add(dr[0].ToString()); } comboIdProducto.DataSource = productCombo; //combo pedidos var pedidos = ConexionBD.ExecuteQuery("SELECT ao.idOrder, ao.createDate, pr.name, au.fullname, " + "ad.address FROM APPORDER ao, ADDRESS ad, PRODUCT pr, APPUSER au " + "WHERE ao.idProduct = pr.idProduct AND ao.idAddress = ad.idAddress " + "AND ad.idUser = au.idUser"); var pedidosCombo = new List <string>(); foreach (DataRow dr in pedidos.Rows) { pedidosCombo.Add(dr[0].ToString()); } comboBoxPedidos.DataSource = pedidosCombo; }
private void Address_Load(object sender, EventArgs e) { try { var dt = ConexionBD.ExecuteQuery("SELECT * FROM ADDRESS"); dataGridView1.DataSource = dt; comboBox1_Load(); comboBox2_Load(); } catch (Exception ex) { MessageBox.Show("ERROR"); } }
private void UsersMantenance_Load(object sender, EventArgs e) { radioButton1.Checked = false; radioButton2.Checked = true; try { var dt = ConexionBD.ExecuteQuery("SELECT * FROM APPUSER"); dataGridView1.DataSource = dt; comboBox1_Load(); } catch (Exception ex) { MessageBox.Show("Ha ocurrido un problema"); } }
private void button2_Click(object sender, EventArgs e) { DialogResult deleteconfirm; if (textBox4.Text == "") { MessageBox.Show("No se pueden dejar el campo vacio "); } else { button2.Enabled = true; deleteconfirm = MessageBox.Show("Se borrara el usuario", "Confirmar", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation); if (deleteconfirm == DialogResult.OK) { try { ConexionBD.ExecuteNonQuery("DELETE FROM public.APPUSER WHERE username ="******"'{textBox4.Text}'"); var dt = ConexionBD.ExecuteQuery("SELECT * FROM APPUSER"); dataGridView1.DataSource = dt; textBox4.Clear(); textBox1.Clear(); textBox2.Clear(); textBox3.Clear(); MessageBox.Show("Usuario eliminado", "Eliminar usuario", MessageBoxButtons.OK, MessageBoxIcon.Information); comboBox1_Load(); } catch (Exception exception) { MessageBox.Show(exception.Message); throw; } } else { textBox4.Text = ""; } } }
private void Empresas_Load(object sender, EventArgs e) { try { var dt = ConexionBD.ExecuteQuery("SELECT * FROM BUSINESS"); textBox1.Clear(); textBox2.Clear(); textBox4.Clear(); comboBox1_Load(); comboBox2_Load(); comboBox3_Load(); } catch (Exception ex) { MessageBox.Show("ERROR"); } }
private void comboBox2_Load() { try { var users = ConexionBD.ExecuteQuery("SELECT name FROM ADDRESS"); var usersCombo = new List <string>(); usersCombo.Add(""); foreach (DataRow dr in users.Rows) { usersCombo.Add(dr[0].ToString()); } comboBox2.DataSource = usersCombo; } catch (Exception e) { MessageBox.Show(e.Message); } }
private void button1_Click(object sender, EventArgs e) { if (radioButton1.Checked == true) { admintype = true; } else if (radioButton2.Checked == true) { admintype = false; } if (textBox1.Text.Equals("") || textBox2.Text.Equals("") || textBox3.Text.Equals("")) { MessageBox.Show("No se pueden dejar campos vacios "); } else { try { ConexionBD.ExecuteNonQuery($"INSERT INTO APPUSER(fullname, username, password, userType) VALUES (" + $"'{textBox1.Text}'," + $"'{textBox2.Text}'," + $"'{textBox3.Text}'," + $"'{admintype}')"); MessageBox.Show("Se ha registrado el usuario"); comboBox1_Load(); textBox1.Clear(); textBox2.Clear(); textBox3.Clear(); radioButton2.Checked = true; var dt = ConexionBD.ExecuteQuery("SELECT * FROM APPUSER"); dataGridView1.DataSource = dt; } catch (Exception ex) { MessageBox.Show("Ha ocurrido un error"); var dt = ConexionBD.ExecuteQuery("SELECT * FROM APPUSER"); dataGridView1.DataSource = dt; } } }
public static List <Usuario> getLista() { string sql = "select * from APPUSER"; DataTable dt = ConexionBD.ExecuteQuery(sql); List <Usuario> lista = new List <Usuario>(); foreach (DataRow fila in dt.Rows) { Usuario u = new Usuario(); u.fullname = fila[0].ToString(); u.username = fila[1].ToString(); u.password = fila[2].ToString(); u.userType = Convert.ToBoolean(fila[3].ToString()); lista.Add(u); } return(lista); }