private void button1_Click(object sender, EventArgs e) { if (comboBox1.SelectedItem == null || comboBox2.SelectedItem == null) { MessageBox.Show("Llene los campos"); } else { try { DateTime d = DateTime.Now; ConnectionBD.ExecuteNonQuery($"INSERT INTO APPORDER(createDate, idProduct, idAddress) " + $"VALUES('{d}', '{comboBox1.SelectedValue}', '{comboBox2.SelectedValue}'); "); MessageBox.Show("Se ha procesado su orden"); } catch (Exception ex) { MessageBox.Show("Ha ocurrido un error"); } } }
private void button1_Click(object sender, EventArgs e) { if (comboBox1.SelectedItem == null) { throw new NoRestaurantSelected("No se ha seleccionado un restaurante"); } else { try { ConnectionBD.ExecuteNonQuery($"INSERT INTO PRODUCT(idBusiness, name) " + $"VALUES('{comboBox1.SelectedValue}', '{textBox1.Text}');"); MessageBox.Show("Se ha agregado el producto"); } catch (NoRestaurantSelected ex) { MessageBox.Show(ex.Message); } catch (Exception ex) { MessageBox.Show("Ha ocurrido un error"); } } }
private void button1_Click_1(object sender, EventArgs e) { if (textBox1.Text.Equals("")) { MessageBox.Show("Debe cambiar la contraseña"); } else { try { string aux = comboBox1.SelectedItem.ToString(); /*string consulta = $"select password from appuser where username='******'"; * var dt = ConnectionBD.ExecuteQuery(consulta); * var dr = dt.Rows[0]; * var contra = Convert.ToString(dr[0].ToString());*/ string accion = $"update appuser set password = '******'" + $" where username = '******'"; ConnectionBD.ExecuteNonQuery(accion); MessageBox.Show("Se ha actualizado la contraseña"); } catch (Exception ex) { 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 { if (radioButton1.Checked) { ConnectionBD.ExecuteNonQuery($"INSERT INTO APPUSER (fullname, username, password, userType) " + $"VALUES ('{textBox1.Text}', " + $"'{textBox2.Text}', '{textBox3.Text}' ,'{false}')"); MessageBox.Show("Se ha registrado un usuario!"); } else { ConnectionBD.ExecuteNonQuery($"INSERT INTO APPUSER (fullname, username, password, userType) " + $"VALUES ('{textBox1.Text}', " + $"'{textBox2.Text}', '{textBox3.Text}' ,'{true}')"); MessageBox.Show("Se ha registrado un usuario!"); } } catch (Exception ex) { Console.WriteLine("Ha ocurrido un error!"); } } }
private void PoblarControles() { var users = ConnectionBD.ExecuteQuery("SELECT username FROM appuser"); var usersNames = new List <string>(); foreach (DataRow dr in users.Rows) { usersNames.Add(dr[0].ToString()); } comboBox1.DataSource = usersNames; }
private void DeleteUser_Load(object sender, EventArgs e) { var name = ConnectionBD.ExecuteQuery("SELECT username FROM APPUSER"); var nameCombo = new List <string>(); foreach (DataRow dr in name.Rows) { nameCombo.Add(dr[0].ToString()); } comboBox1.DataSource = nameCombo; }
private void button1_Click(object sender, EventArgs e) { try { string nonQuery = $"DELETE FROM BUSINESS WHERE idBusiness ={comboBox1.SelectedValue}"; ConnectionBD.ExecuteNonQuery(nonQuery); MessageBox.Show("Se ha eliminado el negocio"); } catch (Exception ex) { MessageBox.Show("Ha ocurrido un error"); } }
private void button1_Click(object sender, EventArgs e) { // mensaje de prueba //MessageBox.Show(user.IdUser.ToString()); //iduser = Convert.ToInt32(uw.ToString()); //MessageBox.Show(iduser.ToString()); var dt2 = ConnectionBD.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 AND au.idUser = '******'; "); dataGridView1.DataSource = dt2; MessageBox.Show("Datos obtenidos exitosamente"); }
private void button1_Click(object sender, EventArgs e) { try { if (comboBox1.SelectedItem == null) { MessageBox.Show("No se ha escogido un producto"); } else { ConnectionBD.ExecuteNonQuery($"DELETE FROM PRODUCT WHERE idProduct = '{comboBox1.SelectedValue}'"); MessageBox.Show("Se ha eliminado el producto"); } } catch (Exception ex) { MessageBox.Show("Ha ocurrido un error"); } }
private void button1_Click(object sender, EventArgs e) { try { if (comboBox1.SelectedItem == null) { MessageBox.Show("Escoga una dirección"); } else { ConnectionBD.ExecuteNonQuery($"DELETE FROM ADDRESS WHERE idAddress = '{comboBox1.SelectedValue}'"); PoblarControles(); MessageBox.Show("Se ha eliminado la direccion"); } } catch (Exception ex) { MessageBox.Show("Ha ocurrido un error"); } }
public static List <Product> getLista() { string sql = "select * from PRODUCT"; DataTable dt = ConnectionBD.ExecuteQuery(sql); List <Product> lista = new List <Product>(); foreach (DataRow fila in dt.Rows) { Product pr = new Product(); pr.IdProduct = Convert.ToInt32(fila[0].ToString()); pr.IdBusiness = Convert.ToInt32(fila[1].ToString()); pr.Name = fila[2].ToString(); lista.Add(pr); } return(lista); }
public static List <AddressA> getLista() { string sql = "select * from ADDRESS"; DataTable dt = ConnectionBD.ExecuteQuery(sql); List <AddressA> lista = new List <AddressA>(); foreach (DataRow fila in dt.Rows) { AddressA ad = new AddressA(); ad.IdAddress = Convert.ToInt32(fila[0].ToString()); ad.IdUser = Convert.ToInt32(fila[1].ToString()); ad.Address = fila[2].ToString(); lista.Add(ad); } return(lista); }
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 { ConnectionBD.ExecuteNonQuery($"INSERT INTO BUSINESS(name, description) " + $"VALUES('{textBox1.Text}', '{textBox2.Text}');"); MessageBox.Show("Se ha agregado el negocio"); } catch (Exception ex) { MessageBox.Show("Ha ocurrido un error"); } } }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text.Equals("")) { MessageBox.Show("Necesita una dirección"); } else { try { ConnectionBD.ExecuteNonQuery($"INSERT INTO ADDRESS(idUser, address) " + $"VALUES('{logged.IdUser}', '{textBox1.Text}')"); MessageBox.Show("Se ha agregado la direccion"); } catch (Exception ex) { MessageBox.Show("Ha ocurrido un error"); } } }
public static List <Business> getLista() { string sql = "select * from BUSINESS"; DataTable dt = ConnectionBD.ExecuteQuery(sql); List <Business> lista = new List <Business>(); foreach (DataRow fila in dt.Rows) { Business bu = new Business(); bu.IdBusiness = Convert.ToInt32(fila[0].ToString()); bu.Name = fila[1].ToString(); bu.Description = fila[2].ToString(); lista.Add(bu); } return(lista); }
private void button1_Click(object sender, EventArgs e) { try { string query = $"SELECT idUser FROM APPUSER WHERE username = '******'"; var dt = ConnectionBD.ExecuteQuery(query); var dr = dt.Rows[0]; var idUsuario = Convert.ToInt32(dr[0].ToString()); string nonQuery = $"DELETE FROM APPUSER WHERE idUser = {idUsuario}"; ConnectionBD.ExecuteNonQuery(nonQuery); MessageBox.Show("Se ha eliminado el usuario"); } catch (Exception exception) { MessageBox.Show("Ha ocurrido un error!"); } }
public static List <Pedido> getLista() { string sql = "select * from APPORDER"; DataTable dt = ConnectionBD.ExecuteQuery(sql); List <Pedido> lista = new List <Pedido>(); foreach (DataRow fila in dt.Rows) { Pedido ped = new Pedido(); User u = new User(); ped.IdOrder = Convert.ToInt32(fila[0].ToString()); ped.CreateDate = Convert.ToDateTime(fila[1].ToString()); ped.IdProduct = ped.IdOrder = Convert.ToInt32(fila[2].ToString()); ped.IdAddress = Convert.ToInt32(fila[3].ToString()); lista.Add(ped); } return(lista); }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text.Equals("")) { MessageBox.Show("No se pueden dejar campos vacio"); } else { try { ConnectionBD.ExecuteNonQuery($"UPDATE ADDRESS SET address = '{textBox1.Text}' " + $"WHERE idAddress = {comboBox1.SelectedValue}"); PoblarControles(); MessageBox.Show("Se ha modificado la direccion"); } catch (Exception ex) { MessageBox.Show("Ha ocurrido un erros"); } } }
private void button1_Click(object sender, EventArgs e) { ConnectionBD.ExecuteNonQuery($"DELETE FROM APPORDER WHERE idOrder = '{comboBox1.SelectedValue}'"); MessageBox.Show("Orden eliminada"); }