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 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 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 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("") || textBox2.Text.Equals("") || textBox3.Text.Equals("") ) { MessageBox.Show("No se pueden dejar campos vacios"); } else { try { ConnectionDB.ExecuteNonQuery($"UPDATE APPUSER SET password = '******' WHERE username='******' AND password ='******'"); MessageBox.Show("Se ha cambiado la contraseña"); } 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 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 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"); } } }
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"); } } }
public static void CrearNuevo(string fullname, string username, string password, string usertype) { string sql = String.Format( "INSERT INTO appuser(fullname, username, password, userType) VALUES ('{0}', '{1}', '{2}', '{3}');", fullname, username, password, usertype); ConnectionDB.ExecuteNonQuery(sql); }
public static void ActualizarPermisos(string usertype, string fullname) { string sql = string.Format( "UPDATE appuser SET usertype='{0}' WHERE fullname='{1}';", usertype, fullname); ConnectionDB.ExecuteNonQuery(sql); }
private void btnAgre_Click(object sender, EventArgs e) { if (txtName.Equals("") || txtDescrip.Equals("")) { MessageBox.Show("No se puede dejar vacio el campo"); } else { ConnectionDB.ExecuteNonQuery($"INSERT INTO business(name,description) " + $"VALUES ('{txtName.Text}','{txtDescrip.Text}') "); MessageBox.Show("Se ha agregado"); } }
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 btnCambiar_Click(object sender, EventArgs e) { if (txtUsua.Text.Equals("") || txtContra.Text.Equals("")) { MessageBox.Show("No se puede dejar campos vacios"); } else { ConnectionDB.ExecuteNonQuery($"UPDATE appuser SET password = "******"'{txtContra.Text}' " + $"WHERE username='******' "); MessageBox.Show("Se ha cambiado el password"); } }
private void button2_Click(object sender, EventArgs e) { try { ConnectionDB.ExecuteNonQuery($"DELETE FROM APPUSER WHERE username = '******'"); MessageBox.Show("Se ha eliminado el usuario"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button2_Click(object sender, EventArgs e) { try { ConnectionDB.ExecuteNonQuery($"DELETE FROM PRODUCT WHERE name = '{textBox2.Text}'"); MessageBox.Show("Se ha eliminado el producto"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button2_Click(object sender, EventArgs e) { try { ConnectionDB.ExecuteNonQuery($"DELETE FROM APPORDER WHERE idOrder = '{textBox1.Text}'"); MessageBox.Show("Se ha cancelado la orden"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
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 button5_Click(object sender, EventArgs e) { DialogResult deleteconfirm; if (comboBox2.Text == "") { MessageBox.Show("No se pueden dejar el campo vacio "); } else { button2.Enabled = true; deleteconfirm = MessageBox.Show("Se borrara la empresa", "Confirmar", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation); if (deleteconfirm == DialogResult.OK) { try { ConnectionDB.ExecuteNonQuery("DELETE FROM public.BUSINESS WHERE name =" + $"'{comboBox2.Text}'"); textBox4.Clear(); textBox1.Clear(); textBox2.Clear(); textBox3.Clear(); MessageBox.Show("Empresa eliminada", "Eliminar empresa", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception exception) { MessageBox.Show(exception.Message); throw; } } else { comboBox2.Text = ""; } } }
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 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 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 btnCrear_Click(object sender, EventArgs e) { switch (cbxUser.SelectedIndex) { case 0: { ConnectionDB.ExecuteNonQuery($"INSERT INTO APPUSER(fullname, username, password, usertype) " + $"VALUES ('{txtName.Text}', '{txtUser.Text}', '{txtUser.Text}', '{true}') "); MessageBox.Show("Se ha agregado"); break; } case 1: { ConnectionDB.ExecuteNonQuery($"INSERT INTO APPUSER(fullname, username, password, usertype) " + $"VALUES ('{txtName.Text}', '{txtUser.Text}', '{txtUser.Text}', '{false}') "); MessageBox.Show("Se ha agregado"); break; } } }
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 { ConnectionDB.ExecuteNonQuery($"INSERT INTO BUSINESS(name, description)" + $"VALUES('{textBox1.Text}', '{textBox2.Text}')"); MessageBox.Show("Se ha registrado el negocio"); } catch (Exception exp) { MessageBox.Show(exp.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 { bool tipo = true; if (comboBox1.SelectedItem.ToString().Equals("Admin")) { tipo = true; } else if (comboBox1.SelectedItem.ToString().Equals("Cliente")) { tipo = false; } ConnectionDB.ExecuteNonQuery($"INSERT INTO APPUSER(fullname, username, password, userType)" + $"VALUES('{textBox1.Text}', '{textBox2.Text}', '{textBox2.Text}','{tipo}')"); MessageBox.Show("Se ha registrado el usuario"); } catch (AlreadyExistUserException exp) { MessageBox.Show(exp.Message); } catch (Exception exp) { MessageBox.Show(exp.Message); } } }
private void btnElimi_Click(object sender, EventArgs e) { ConnectionDB.ExecuteNonQuery($"DELETE FROM appuser WHERE username='******'"); MessageBox.Show("Usuario eliminado"); }
private void btnElimi_Click(object sender, EventArgs e) { ConnectionDB.ExecuteNonQuery($"DELETE FROM business WHERE name='{txtNom.Text}'"); MessageBox.Show("Se ha borrado la empresa"); }