private void button1_Click(object sender, EventArgs e) { if (textBox1.Text.Equals("")) { MessageBox.Show("No puede dejar los campos vacios"); } else { try { string query = $"SELECT idaddress FROM ADDRESS WHERE address ='{comboBox1.SelectedItem.ToString()}'"; var dt = BDconnection.realizarConsulta(query); var dr = dt.Rows[0]; var idaddress = Convert.ToInt32(dr[0].ToString()); string nonQuery = $"UPDATE ADDRESS SET address = '{textBox1.Text}' WHERE idAddress = {idaddress}"; BDconnection.realizarAccion(nonQuery); MessageBox.Show("Se ha modificado la direccion"); } catch (Exception ex) { MessageBox.Show("Ha ocurrido un error!"); } } }
private void button6_Click(object sender, EventArgs e) { var dt = BDconnection.realizarConsulta("SELECT * FROM BUSINESS"); dataGridView1.DataSource = dt; MessageBox.Show("Datos obtenidos exitosamente"); }
private void button2_Click(object sender, EventArgs e) { var dn = BDconnection.realizarConsulta($"SELECT username FROM APPUSER WHERE username = '******'"); var dr1 = dn.Rows[0]; var dc2 = BDconnection.realizarConsulta($"SELECT password FROM APPUSER WHERE username = '******'"); var dr2 = dc2.Rows[0]; if (dr1[0].ToString().Equals(textBox1.Text) && dr2[0].ToString().Equals(textBox2.Text)) { var dt = BDconnection.realizarConsulta($"SELECT usertype FROM APPUSER WHERE username='******'"); var dr = dt.Rows[0]; if (dr[0].ToString() == "True") { FormAdmon frmA = new FormAdmon(); frmA.Show(); } else if (dr[0].ToString() == "False") { FormNoAdmon frmN = new FormNoAdmon(); frmN.Show(); } } else { MessageBox.Show("Datos incorrectos"); } }
private void AddOrder_Load(object sender, EventArgs e) { var bus = BDconnection.realizarConsulta("SELECT idbusiness FROM BUSINESS"); var busCombo = new List <string>(); foreach (DataRow dr in bus.Rows) { busCombo.Add(dr[0].ToString()); } comboBox1.DataSource = busCombo; var dir = BDconnection.realizarConsulta("SELECT idaddress FROM ADDRESS"); var dirCombo = new List <string>(); foreach (DataRow ds in dir.Rows) { dirCombo.Add(ds[0].ToString()); } comboBox2.DataSource = dirCombo; var prod = BDconnection.realizarConsulta($"SELECT idProduct FROM PRODUCT WHERE idBusiness={comboBox1.Text}"); var prodCombo = new List <string>(); foreach (DataRow dt in prod.Rows) { prodCombo.Add(dt[0].ToString()); } comboBox3.DataSource = prodCombo; }
private void button1_Click(object sender, EventArgs e) { var dn = BDconnection.realizarConsulta($"SELECT username FROM APPUSER WHERE username = '******'"); var dr1 = dn.Rows[0]; var dc2 = BDconnection.realizarConsulta($"SELECT password FROM APPUSER WHERE username = '******'"); var dr2 = dc2.Rows[0]; if (dr1[0].ToString().Equals(textBox1.Text) && dr2[0].ToString().Equals(textBox2.Text)) { try { string query = $"SELECT idUser FROM APPUSER WHERE username ='******'"; var dt = BDconnection.realizarConsulta(query); var dr = dt.Rows[0]; var idUser = Convert.ToInt32(dr[0].ToString()); string nonQuery = $"UPDATE APPUSER SET password = '******' WHERE idUser = {idUser}"; BDconnection.realizarAccion(nonQuery); MessageBox.Show("Se ha modificado la direccion"); } catch (Exception ex) { MessageBox.Show("Ha ocurrido un error!"); } } else { MessageBox.Show("Datos incorrectos"); } }
private void button4_Click(object sender, EventArgs e) { var dt = BDconnection.realizarConsulta($"SELECT ad.idAddress, ad.address FROM ADDRESS ad WHERE idUser={textBox1.Text}"); dataGridView1.DataSource = dt; MessageBox.Show("Datos obtenidos exitosamente"); }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text.Equals("")) { MessageBox.Show("No puede dejar los campos vacios"); } else { //try // { var dt = BDconnection.realizarConsulta( $"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 AND au.idUser = {textBox1.Text}"); dataGridView1.DataSource = dt; MessageBox.Show("Datos obtenidos exitosamente"); //} /*catch (Exception esg) * { * MessageBox.Show("Ha cocurrido un problema"); * }*/ } }
private void button9_Click(object sender, EventArgs e) { var dt = BDconnection.realizarConsulta("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"); }
private void ModidyAddress_Load(object sender, EventArgs e) { var address = BDconnection.realizarConsulta("SELECT address FROM ADDRESS"); var addressCombo = new List <string>(); foreach (DataRow dr in address.Rows) { addressCombo.Add(dr[0].ToString()); } comboBox1.DataSource = addressCombo; }
private void AddProduct_Load(object sender, EventArgs e) { var prod = BDconnection.realizarConsulta("SELECT idbusiness FROM Business"); var prodCombo = new List <string>(); foreach (DataRow dr in prod.Rows) { prodCombo.Add(dr[0].ToString()); } comboBox1.DataSource = prodCombo; }