private void btnElim_Click(object sender, EventArgs e) { var idProd = ""; var idP = ConnectionDB.ExecuteQuery($"SELECT idproduct FROM product " + $"Where name='{comboBox1.Text}'"); foreach (DataRow dr in idP.Rows) { idProd = dr[0].ToString(); } var idAdd = ""; var idA = ConnectionDB.ExecuteQuery($"SELECT idaddress FROM address " + $"WHERE address='{comboBox2.Text}' "); foreach (DataRow dr in idA.Rows) { idAdd = dr[0].ToString(); } try { ConnectionDB.ExecuteNonQuery($"DELETE FROM apporder WHERE idProduct='{idProd}' " + $"AND idAddress='{idAdd}'"); MessageBox.Show("Se ha borrado el pedido"); } catch (Exception ex) { MessageBox.Show("Error, no se encontro el pedido"); throw; } }
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 { var dt = ConnectionDB.ExecuteQuery( $"SELECT userType FROM APPUSER WHERE username='******' AND password='******'"); var dr = dt.Rows[0]; var tipo = Convert.ToBoolean(dr[0].ToString()); if (tipo) { MessageBox.Show("Sesión iniciada como Administrador"); this.Hide(); new Admin(textBox1.Text).Show(); } else { MessageBox.Show("Sesión iniciada como Cliente"); this.Hide(); new Usuario(textBox1.Text).Show(); } } catch (Exception exp) { MessageBox.Show("Usuario y/o contraseña incorrectos"); } } }
private void GestOrder_Load(object sender, EventArgs e) { string Query2 = $"SELECT idUser FROM APPUSER WHERE username ='******'"; var dt2 = ConnectionDB.ExecuteQuery(Query2); var dr3 = dt2.Rows[0]; var idUser = Convert.ToInt32(dr3[0].ToString()); var direccion = ConnectionDB.ExecuteQuery($"SELECT address FROM ADDRESS WHERE idUser='******' "); var comboad = new List <string>(); foreach (DataRow dr in direccion.Rows) { comboad.Add(dr[0].ToString()); } comboBox3.DataSource = comboad; var negocio = ConnectionDB.ExecuteQuery("SELECT name FROM BUSINESS"); var comboneg = new List <string>(); foreach (DataRow dr in negocio.Rows) { comboneg.Add(dr[0].ToString()); } comboBox1.DataSource = comboneg; }
private void btnActua_Click(object sender, EventArgs e) { var dt = ConnectionDB.ExecuteQuery( $"SELECT * FROM appuser "); dataGridView1.DataSource = dt; }
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 { string Query = $"SELECT idUser FROM APPUSER WHERE username = '******'"; var dt = ConnectionDB.ExecuteQuery(Query); var dr = dt.Rows[0]; var idUser = Convert.ToInt32(dr[0].ToString()); ConnectionDB.ExecuteNonQuery($"INSERT INTO ADDRESS(idUser, address)" + $"VALUES('{idUser}', '{textBox2.Text}')"); MessageBox.Show("Se ha registrado el la dirección"); } catch (Exception exp) { MessageBox.Show(exp.Message); } } }
private void button2_Click(object sender, EventArgs e) { if (textBox1.Text.Equals("") || textBox2.Text.Equals("")) { MessageBox.Show("No se pueden dejar campos vacios"); } else { try { string Query = $"SELECT idUser FROM APPUSER WHERE username = '******'"; var dt = ConnectionDB.ExecuteQuery(Query); var dr = dt.Rows[0]; var idUser = Convert.ToInt32(dr[0].ToString()); ConnectionDB.ExecuteNonQuery($"UPDATE ADDRESS SET address = '{textBox2.Text}' WHERE idAddress = '{idUser}'"); MessageBox.Show("Se ha actualizado la dirección"); } catch (Exception exp) { MessageBox.Show(exp.Message); } } }
private void btnCrear_Click(object sender, EventArgs e) { DateTime dt = DateTime.Now; var idProd = ""; var idP = ConnectionDB.ExecuteQuery($"SELECT idproduct FROM product " + $"Where name='{comboBox1.Text}'"); foreach (DataRow dr in idP.Rows) { idProd = dr[0].ToString(); } var idAdd = ""; var idA = ConnectionDB.ExecuteQuery($"SELECT idaddress FROM address " + $"WHERE address='{comboBox2.Text}' "); foreach (DataRow dr in idA.Rows) { idAdd = dr[0].ToString(); } ConnectionDB.ExecuteNonQuery($"INSERT INTO apporder(createDate, idProduct, idAddress)" + $"VALUES ('{dt}', '{idProd}', '{idAdd}')"); MessageBox.Show("Se ha realizado el pedido"); }
private void button1_Click(object sender, EventArgs e) { try { string selectorprod = $"SELECT idProduct FROM PRODUCT WHERE name='{comboBox2.SelectedItem.ToString()}'"; var dataprod = ConnectionDB.ExecuteQuery(selectorprod); var rowprod = dataprod.Rows[0]; var idProduct = Convert.ToInt32(rowprod[0].ToString()); string selectordirec = $"SELECT idAddress FROM ADDRESS WHERE address = '{comboBox3.SelectedItem.ToString()}'"; var datadirec = ConnectionDB.ExecuteQuery(selectordirec); var rowdirec = datadirec.Rows[0]; var idAdress = Convert.ToInt32(rowdirec[0].ToString()); string nonQuery = $"INSERT INTO APPORDER(createDate, idProduct, idAddress) VALUES(" + $"'{dateTimePicker1.Value}'," + $"'{idProduct}','{idAdress}')"; ConnectionDB.ExecuteNonQuery(nonQuery); MessageBox.Show("Se añadio realizo la orden"); } catch (Exception exp) { MessageBox.Show("Ha ocurrido un error"); } }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text.Equals("")) { MessageBox.Show("No se pueden dejar campos vacios"); } else { try { string Query = $"SELECT idBusiness FROM BUSINESS WHERE name = '{comboBox1.SelectedItem.ToString()}'"; var dt = ConnectionDB.ExecuteQuery(Query); var dr = dt.Rows[0]; var idBusiness = Convert.ToInt32(dr[0].ToString()); string nonQuery = $"INSERT INTO PRODUCT(idBusiness, name) VALUES(" + $"{idBusiness}," + $"'{textBox1.Text}')"; ConnectionDB.ExecuteNonQuery(nonQuery); MessageBox.Show("Se añadio el producto"); } catch (Exception exp) { MessageBox.Show("Ha ocurrido un error"); } } }
private void button4_Click(object sender, EventArgs e) { if (textBox5.Text.Equals("") || textBox6.Text.Equals("")) { MessageBox.Show("No se pueden dejar campos vacios "); } else { try { ConnectionDB.ExecuteNonQuery($"INSERT INTO BUSINESS( name, description) VALUES (" + $"'{textBox5.Text}'," + $"'{textBox6.Text}')"); MessageBox.Show("Se ha registrado la empresa"); var dt = ConnectionDB.ExecuteQuery("SELECT * FROM PRODUCT"); textBox5.Clear(); textBox6.Clear(); } catch (Exception ex) { MessageBox.Show("ERROR"); } } }
private void button6_Click(object sender, EventArgs e) { if (textBox7.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 = ConnectionDB.ExecuteQuery(num); var dr = dt.Rows[0]; var myNum = int.Parse(dt.Rows[0][0].ToString()); ConnectionDB.ExecuteNonQuery($"INSERT INTO PRODUCT(idBusiness, name) VALUES (" + $"{myNum}, " + $"'{textBox7.Text}')"); MessageBox.Show("Se ha registrado el producto"); } catch (Exception ex) { MessageBox.Show("ERROR"); } } }
public static void actualizarContra(string idUser, string nuevapassword) { string sql = String.Format( "UPDATE appuser SET password = '******' WHERE idUser = 1;", nuevapassword, idUser); ConnectionDB.ExecuteQuery(sql); }
private void btnAct_Click(object sender, EventArgs e) { var tabla = ConnectionDB.ExecuteQuery($"SELECT ord.idOrder, add.address, " + $"pro.name, aus.fullname FROM apporder ord, " + $"address add, product pro, appuser aus " + $"WHERE ord.idAddress = add.idAddress " + $"AND ord.idProduct = pro.idProduct " + $"AND add.idUser = aus.idUser"); dataGridView1.DataSource = tabla; }
private void GestProducts_Load(object sender, EventArgs e) { var negocios = ConnectionDB.ExecuteQuery("SELECT name FROM BUSINESS"); var combobusiness = new List <string>(); foreach (DataRow dr in negocios.Rows) { combobusiness.Add(dr[0].ToString()); } comboBox1.DataSource = combobusiness; }
private void DireccionModi_Load(object sender, EventArgs e) { var num = ConnectionDB.ExecuteQuery("SELECT address FROM address"); var numList = new List <string>(); foreach (DataRow dr in num.Rows) { numList.Add(dr[0].ToString()); } comboBox1.DataSource = numList; }
private void ProductElim_Load(object sender, EventArgs e) { var listN = new List <string>(); var nom = ConnectionDB.ExecuteQuery($"SELECT name FROM business"); foreach (DataRow dr in nom.Rows) { listN.Add(dr[0].ToString()); } comboBox1.DataSource = listN; }
private void btnElim_Click(object sender, EventArgs e) { var num = ConnectionDB.ExecuteQuery($"SELECT idbusiness FROM product WHERE name = " + $"'{comboBox1.Text}'"); var cosa = ""; foreach (DataRow dr in num.Rows) { cosa = dr[0].ToString(); } ConnectionDB.ExecuteNonQuery($"DELETE FROM product WHERE name='{comboBox2.Text}'"); MessageBox.Show("Se ha borrado el producto"); }
private void btnVer_Click(object sender, EventArgs e) { var idUser = ConnectionDB.ExecuteQuery($"SELECT iduser FROM appuser " + $"WHERE username = '******' "); var id = ""; foreach (DataRow dr in idUser.Rows) { id = dr[0].ToString(); } var data = ConnectionDB.ExecuteQuery($"SELECT address FROM address " + $"WHERE iduser = '******' "); dataGridView1.DataSource = data; }
private void button3_Click(object sender, EventArgs e) { string Query = $"SELECT idBusiness FROM BUSINESS WHERE name = '{comboBox1.SelectedItem.ToString()}'"; var dt = ConnectionDB.ExecuteQuery(Query); var dr2 = dt.Rows[0]; var idBusiness = Convert.ToInt32(dr2[0].ToString()); var product = ConnectionDB.ExecuteQuery($"SELECT name FROM PRODUCT WHERE idBusiness='{idBusiness}' "); var comboprod = new List <string>(); foreach (DataRow dr in product.Rows) { comboprod.Add(dr[0].ToString()); } comboBox2.DataSource = comboprod; }
private void tabPage2_Click(object sender, EventArgs e) { button2.Enabled = false; try { var dt = ConnectionDB.ExecuteQuery("SELECT * FROM BUSINESS"); textBox1.Clear(); textBox2.Clear(); textBox4.Clear(); } catch (Exception ex) { MessageBox.Show("ERROR"); } }
public static Usuario GetUser(String fullname, string password) { string sql = String.Format("SELECT * FROM appuser WHERE fullname = '{0}' AND password = '******';", fullname, password); DataTable dt = ConnectionDB.ExecuteQuery(sql); Usuario u = new Usuario(); foreach (DataRow fila in dt.Rows) { u.usuario = fila[0].ToString(); u.contrasena = fila[1].ToString(); u.tipo = fila[2].ToString(); } return(u); }
private void button1_Click(object sender, EventArgs e) { try { var dt = ConnectionDB.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;"); dataGridView1.DataSource = dt; MessageBox.Show("Datos obtenidos exitosamente"); } catch (Exception ex) { MessageBox.Show("Ha ocurrido un problema"); } }
public static List <Usuario> GetLista() { string sql = "SELECT * FROM appuser"; DataTable dt = ConnectionDB.ExecuteQuery(sql); List <Usuario> lista = new List <Usuario>(); foreach (DataRow fila in dt.Rows) { Usuario u = new Usuario(); u.usuario = fila[0].ToString(); u.contrasena = fila[1].ToString(); u.tipo = fila[2].ToString(); lista.Add(u); } return(lista); }
private void button3_Click(object sender, EventArgs e) { try { string Query = $"SELECT idUser FROM APPUSER WHERE username = '******'"; var dt = ConnectionDB.ExecuteQuery(Query); var dr = dt.Rows[0]; var idUser = Convert.ToInt32(dr[0].ToString()); ConnectionDB.ExecuteNonQuery($"DELETE FROM ADDRESS WHERE idUser = '******'"); MessageBox.Show("Se han eliminado todas las direcciónes asosiadas"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnAgre_Click(object sender, EventArgs e) { if (txtNom.Text.Equals("")) { MessageBox.Show("No pueden haber casos vacios"); } else { var idBu = ""; var listBusi = ConnectionDB.ExecuteQuery($"SELECT idbusiness FROM business " + $"WHERE name='{comboBox1.Text}'"); foreach (DataRow dr in listBusi.Rows) { idBu = dr[0].ToString(); } ConnectionDB.ExecuteNonQuery($"INSERT INTO product(idbusiness, name)" + $"VALUES({idBu}, '{txtNom.Text}')"); MessageBox.Show("Se ha agregado el producto"); } }
private void btnModi_Click(object sender, EventArgs e) { if (txtUser.Text.Equals("")) { MessageBox.Show("No se puede dejar campos vacios"); } else { var user = ConnectionDB.ExecuteQuery($"SELECT iduser FROM appuser WHERE username = "******"'{txtUser.Text}'"); var cosa = ""; foreach (DataRow dr in user.Rows) { cosa = dr[0].ToString(); } ConnectionDB.ExecuteNonQuery($"UPDATE address SET address = '{txtNueva.Text}' " + $"WHERE address = '{comboBox1.SelectedItem.ToString()}' AND iduser ='******'"); } }
private void btnBus_Click(object sender, EventArgs e) { var idU = ""; var id = ConnectionDB.ExecuteQuery($"SELECT iduser FROM appuser Where " + $"username = '******'"); foreach (DataRow dr in id.Rows) { idU = dr[0].ToString(); } var tabla = ConnectionDB.ExecuteQuery($"SELECT ord.idOrder, add.address, " + $"pro.name, aus.fullname FROM apporder ord, " + $"address add, product pro, appuser aus " + $"WHERE ord.idAddress = add.idAddress " + $"AND ord.idProduct = pro.idProduct " + $"AND add.idUser = aus.idUser"); dataGridView1.DataSource = tabla; }
private void btnAgre_Click(object sender, EventArgs e) { if (txtUser.Text.Equals("") || txtDire.Text.Equals("")) { MessageBox.Show("No se puede dejar campos vacios"); } else { var user = ConnectionDB.ExecuteQuery($"SELECT iduser FROM appuser WHERE username = "******"'{txtUser.Text}'"); var cosa = ""; foreach (DataRow dr in user.Rows) { cosa = dr[0].ToString(); } ConnectionDB.ExecuteNonQuery($"INSERT INTO address (iduser, address) VALUES " + $"('{Convert.ToInt32(cosa)}', '{txtDire.Text}')"); MessageBox.Show("Se ha agregado la direccion"); } }
private void GestAddress_Load(object sender, EventArgs e) { try { string Query = $"SELECT idUser FROM APPUSER WHERE username = '******'"; var dt2 = ConnectionDB.ExecuteQuery(Query); var dr = dt2.Rows[0]; var idUser = Convert.ToInt32(dr[0].ToString()); var dt = ConnectionDB.ExecuteQuery( $"SELECT ad.idAddress, ad.address FROM ADDRESS ad WHERE idUser ='******'"); dataGridView1.DataSource = dt; MessageBox.Show("Datos actualizados exitosamente"); } catch (Exception ex) { MessageBox.Show("Ha ocurrido un problema"); } }
private void OrdenCre_Load(object sender, EventArgs e) { var listP = new List <string>(); var prod = ConnectionDB.ExecuteQuery($"SELECT name FROM product"); foreach (DataRow dr in prod.Rows) { listP.Add(dr[0].ToString()); } comboBox1.DataSource = listP; var listA = new List <string>(); var addr = ConnectionDB.ExecuteQuery($"SELECT address FROM address"); foreach (DataRow dr in addr.Rows) { listA.Add(dr[0].ToString()); } comboBox2.DataSource = listA; }