예제 #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (textBox3.Text.Equals(""))
            {
                MessageBox.Show("Error no se puede dejar vacio");
            }
            else
            {
                try
                {
                    string query  = $"SELECT id_user 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(id_user, address) VALUES(" +
                                                 $"{iduser}," +
                                                 $"'{textBox3.Text}')");
                    MessageBox.Show("Dirección Registrada");
                    DatosAddress();
                }
                catch (Exception)
                {
                    MessageBox.Show("Ha ocurrido un error");
                }
            }
        }
예제 #2
0
        private void button7_Click(object sender, EventArgs e) //Agregar Productos
        {
            if (textBox3.Text.Equals(""))
            {
                MessageBox.Show("Digite los datos pedidos !");
            }
            else
            {
                try
                {
                    var query2 = ConnectionDB.ExecuteQuery("select idbusiness from business " +
                                                           $"WHERE name ='{comboBox1.Text}'");
                    var query3 = query2.Rows[0];
                    var query4 = Convert.ToInt32(query3[0].ToString());
                    var query  = "";
                    query = "INSERT INTO product(idBusiness,name)" +
                            $"VALUES ('{query4}', '{textBox3.Text}')";

                    ConnectionDB.ExecuteNonQuery(query);
                    MessageBox.Show("Producto Agregado");
                }
                catch (Exception exception)
                {
                    MessageBox.Show("No se ha agregado");
                    throw;
                }
            }
        }
예제 #3
0
        private void button5_Click(object sender, EventArgs e) //Actualizar contraseña
        {
            if (textBox5.Text.Equals(""))
            {
                MessageBox.Show("Ingrese la nueva contraseña por favor");
            }
            else
            {
                var query2 = ConnectionDB.ExecuteQuery("select iduser from appuser " +
                                                       $"WHERE username ='******'");
                var query3 = query2.Rows[0];
                var query4 = Convert.ToInt32(query3[0].ToString());

                var NonQuery = $"UPDATE appuser SET password= '******' WHERE iduser= '******'";
                try
                {
                    ConnectionDB.ExecuteNonQuery(NonQuery);
                    MessageBox.Show("Contraseña Actualizada");
                }
                catch (Exception exception)
                {
                    MessageBox.Show("Usuario no eliminado");
                }
            }
        }
예제 #4
0
        private void button10_Click(object sender, EventArgs e)
        {
            try
            {
                string query  = $"SELECT id_product FROM product WHERE name ='{comboBox6.Text}'";
                var    dt     = ConnectionDB.ExecuteQuery(query);
                var    dr     = dt.Rows[0];
                var    iduser = Convert.ToInt32(dr[0].ToString());

                string query2    = $"SELECT id_address FROM address WHERE address ='{comboBox8.Text}'";
                var    dt2       = ConnectionDB.ExecuteQuery(query2);
                var    dr2       = dt2.Rows[0];
                var    idaddress = Convert.ToInt32(dr2[0].ToString());

                ConnectionDB.ExecuteNonQuery($"INSERT INTO apporder(createdate, id_product, id_address) VALUES(" +
                                             $"'{type.dia}'," +
                                             $"{iduser}," +
                                             $"{idaddress})");
                MessageBox.Show("Orden Registrada");
                DatosProduct();
                DatosOrden();
                DatosAddress();
            }
            catch (Exception)
            {
                MessageBox.Show("Ha ocurrido un error");
            }
        }
        public static List <Product> getLista()
        {
            string sql = "select * from GANANCIA";

            DataTable dt = ConnectionDB.ExecuteQuery(sql);

            List <Product> lista = new List <Product>();

            foreach (DataRow fila in dt.Rows)
            {
                Product p = new Product();
                p.idProducto              = Convert.ToDecimal(fila[0].ToString());
                p.nombre                  = fila[1].ToString();
                p.stock_ingresado         = Convert.ToDecimal(fila[2].ToString());
                p.stock_actual            = Convert.ToDecimal(fila[3].ToString());
                p.precio_unidad_compra    = Convert.ToDecimal(fila[4].ToString());
                p.precio_unidad_venta     = Convert.ToDecimal(fila[5].ToString());
                p.cantidad_vendida        = Convert.ToDecimal(fila[6].ToString());
                p.precio_compra_acumulado = Convert.ToDecimal(fila[7].ToString());
                p.precio_venta_acumulado  = Convert.ToDecimal(fila[8].ToString());
                p.ganancia                = Convert.ToDecimal(fila[9].ToString());

                lista.Add(p);
            }

            return(lista);
        }
예제 #6
0
        private void button6_Click(object sender, EventArgs e) //nueva orden
        {
            try
            {
                var query2 = ConnectionDB.ExecuteQuery("select idproduct from product " +
                                                       $"WHERE name ='{comboBox7.Text}'");
                var query3 = query2.Rows[0];
                var query4 = Convert.ToInt32(query3[0].ToString());

                var add = ConnectionDB.ExecuteQuery("select idaddress from address " +
                                                    $"WHERE address ='{comboBox2.Text}'");
                var addre   = add.Rows[0];
                var address = Convert.ToInt32(addre[0].ToString());


                var query = "";
                query = "INSERT INTO APPORDER(createDate, idProduct, idAddress)" +
                        $" VALUES('{DateTime.UtcNow.ToString("d")}','{query4}','{address}')";
                ConnectionDB.ExecuteNonQuery(query);
                MessageBox.Show("Se ha hecho el pedido");
            }
            catch (Exception exception)
            {
                MessageBox.Show("No se ha hecho el pedido");
                throw;
            }
        }
예제 #7
0
        private void btnCambiarContra_Click(object sender, EventArgs e)
        {
            try
            {
                string query  = $"SELECT password from appuser WHERE username ='******'";
                var    dt     = ConnectionDB.ExecuteQuery(query);
                var    dr     = dt.Rows[0];
                var    iduser = Convert.ToString(dr[0].ToString());

                if (txtActual.Text.Equals(iduser) && txtNueva.Text.Equals(txtRepetir.Text))
                {
                    string actualizar =
                        $"UPDATE appuser SET password = '******' WHERE password = '******'";
                    ConnectionDB.ExecuteNonQuery(actualizar);
                    MessageBox.Show("Se ha actualizado la contra");
                }
                else
                {
                    MessageBox.Show("Datos incorrectos");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Ha ocurrido un Error");
            }
        }
예제 #8
0
 private void button4_Click(object sender, EventArgs e) //Nueva direccion
 {
     if (textBox3.Text.Equals(""))
     {
         MessageBox.Show("ingrese los datos requeridos.");
     }
     else
     {
         try
         {
             var query2 = ConnectionDB.ExecuteQuery("select iduser from appuser " +
                                                    $"WHERE username ='******'");
             var query3 = query2.Rows[0];
             var query4 = Convert.ToInt32(query3[0].ToString());
             var query  = "";
             query = "INSERT INTO ADDRESS(iduser,address)" +
                     $"values('{query4}','{textBox3.Text}')";
             ConnectionDB.ExecuteNonQuery(query);
             MessageBox.Show("se ha guardado la nueva ubicacion.");
         }
         catch (Exception exception)
         {
             MessageBox.Show("No se ha registrado la ubicacion");
             throw;
         }
     }
 }
예제 #9
0
        private void button3_Click(object sender, EventArgs e) //actualizar la ubicacion
        {
            if (textBox2.Text.Equals(""))
            {
                MessageBox.Show("Ingrese los datos requeridos.");
            }
            else
            {
                try
                {
                    var add = ConnectionDB.ExecuteQuery("select idaddress from address " +
                                                        $"WHERE address ='{comboBox4.Text}'");
                    var addre   = add.Rows[0];
                    var address = Convert.ToInt32(addre[0].ToString());

                    var query = "";
                    query =
                        $"UPDATE ADDRESS SET address = '{textBox2.Text}' WHERE idAddress = '{address}'";
                    ConnectionDB.ExecuteNonQuery(query);
                    MessageBox.Show("Se ha actualizado la direccion");
                }
                catch (Exception exception)
                {
                    MessageBox.Show("No se ha actualizado la direccion.");
                    throw;
                }
            }
        }
예제 #10
0
        private void AdminWF_Load(object sender, EventArgs e)
        {
            //usuarios
            var users      = ConnectionDB.ExecuteQuery("SELECT username FROM appuser");
            var usersCombo = new List <string>();

            foreach (DataRow row in users.Rows)
            {
                usersCombo.Add(row[0].ToString());
            }
            comboBox3.DataSource = usersCombo;

            //negocios

            var negocios      = ConnectionDB.ExecuteQuery("SELECT name FROM business");
            var negocioscombo = new List <string>();

            foreach (DataRow row in negocios.Rows)
            {
                negocioscombo.Add(row[0].ToString());
            }
            comboBox1.DataSource = negocioscombo;
            comboBox6.DataSource = negocioscombo;

            //productos
            var productos      = ConnectionDB.ExecuteQuery("SELECT name FROM product");
            var productosCombo = new List <string>();

            foreach (DataRow row in productos.Rows)
            {
                productosCombo.Add(row[0].ToString());
            }
            comboBox2.DataSource = productosCombo;
        }
        private void btnInicioSesion_Click(object sender, EventArgs e)
        {
            try
            {
                string query      = $"SELECT password FROM appuser WHERE username ='******'";
                var    dt         = ConnectionDB.ExecuteQuery(query);
                var    dr         = dt.Rows[0];
                var    contrasena = Convert.ToString(dr[0].ToString());

                if (txtPassword.Text.Equals(contrasena))
                {
                    u.admin = cboUsuarios.Text;
                    frmPrincipal ventana = new frmPrincipal(u);
                    ventana.Show();
                    //this.Hide();
                }
                else
                {
                    MessageBox.Show("Contraseña Incorrecta");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Ha ocurrido un error");
            }
        }
예제 #12
0
        private void frmPrincipal_Load(object sender, EventArgs e)
        {
            MessageBox.Show("Bienvenido/a");
            try
            {
                string query         = $"SELECT usertype FROM appuser WHERE username ='******'";
                var    dt            = ConnectionDB.ExecuteQuery(query);
                var    dr            = dt.Rows[0];
                var    tipodeusuario = Convert.ToString(dr[0].ToString());

                if (tipodeusuario.Equals("admin"))
                {
                    tabContenedor.TabPages[1].Parent = null;
                    tabContenedor.TabPages[4].Parent = null;
                }
                else
                {
                    tabContenedor.TabPages[0].Parent = null;
                    tabContenedor.TabPages[1].Parent = null;
                    tabContenedor.TabPages[1].Parent = null;
                    tabContenedor.TabPages[1].Parent = null;
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Ha ocurrido un error");
            }

            DatosAppUser();
            DatosAddress();
            DatosBusiness();
            DatosProduct();
            DatosOrden();
        }
예제 #13
0
        private void button5_Click(object sender, EventArgs e)
        {
            if (textBox7.Text.Equals(""))
            {
                MessageBox.Show("No se pueden dejar campos vacios");
            }
            else
            {
                try
                {
                    string query  = $"SELECT id_business from business WHERE name ='{comboBox1.Text}'";
                    var    dt     = ConnectionDB.ExecuteQuery(query);
                    var    dr     = dt.Rows[0];
                    var    iduser = Convert.ToInt32(dr[0].ToString());

                    ConnectionDB.ExecuteNonQuery($"INSERT INTO product(id_business, name) VALUES(" +
                                                 $"{iduser}," +
                                                 $"'{textBox7.Text}')");
                    MessageBox.Show("Producto Registrado");
                    DatosProduct();
                    DatosBusiness();
                }
                catch (Exception)
                {
                    MessageBox.Show("Ha ocurrido un error");
                }
            }
        }
예제 #14
0
        public static DataTable getlista(Usuario us)
        {
            string sql = string.Format("SELECT ad.idAddress, ad.address FROM ADDRESS ad WHERE idUser = {0}", us.userID);

            var dt = ConnectionDB.ExecuteQuery(sql);

            return(dt);
        }
예제 #15
0
        public static int UserQueryId(string password)
        {
            string query  = $"SELECT idUser FROM appuser WHERE password = '******'";
            var    dt     = ConnectionDB.ExecuteQuery(query);
            var    dr     = dt.Rows[0];
            var    idUser = Convert.ToInt32(dr[0].ToString());

            return(idUser);
        }
예제 #16
0
        public static int AddressQueryId(int idUser)
        {
            string query     = $"SELECT idAddress FROM address WHERE idUser = {idUser}";
            var    dt        = ConnectionDB.ExecuteQuery(query);
            var    dr        = dt.Rows[0];
            var    idAddress = Convert.ToInt32(dr[0].ToString());

            return(idAddress);
        }
예제 #17
0
        public static int ProductQueryid(string name)
        {
            string query     = $"SELECT idProduct FROM product WHERE name = '{name}'";
            var    dt        = ConnectionDB.ExecuteQuery(query);
            var    dr        = dt.Rows[0];
            var    idProduct = Convert.ToInt32(dr[0]);

            return(idProduct);
        }
예제 #18
0
        public static DataTable viewAllorders()
        {
            var sql = "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 dt = ConnectionDB.ExecuteQuery(sql);

            return(dt);
        }
예제 #19
0
        public static DataTable viewUserOrder(Usuario us)
        {
            var sql = string.Format("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 = {0};",
                                    us.userID);

            var dt = ConnectionDB.ExecuteQuery(sql);

            return(dt);
        }
예제 #20
0
        private void Form1_Load(object sender, EventArgs e)
        {
            var users      = ConnectionDB.ExecuteQuery("SELECT username FROM appuser");
            var usersCombo = new List <string>();

            foreach (DataRow row in users.Rows)
            {
                usersCombo.Add(row[0].ToString());
            }
            comboBox1.DataSource = usersCombo;
        }
        private void frmInicioDeSesion_Load(object sender, EventArgs e)
        {
            string query      = "select username from appuser";
            var    users      = ConnectionDB.ExecuteQuery(query);
            var    usersCombo = new List <string>();

            foreach (DataRow dr in users.Rows)
            {
                usersCombo.Add(dr[0].ToString());
            }

            cboUsuarios.DataSource = usersCombo;
        }
예제 #22
0
        private void frmCambiarContrasena_Load(object sender, EventArgs e)
        {
            string query2     = "select username from appuser";
            var    users      = ConnectionDB.ExecuteQuery(query2);
            var    usersCombo = new List <string>();

            foreach (DataRow dr in users.Rows)
            {
                usersCombo.Add(dr[0].ToString());
            }

            comboBox1.DataSource = usersCombo;
        }
예제 #23
0
        public void DatosAppUser()
        {
            string query2     = "select username from appuser";
            var    users      = ConnectionDB.ExecuteQuery(query2);
            var    usersCombo = new List <string>();

            foreach (DataRow dr in users.Rows)
            {
                usersCombo.Add(dr[0].ToString());
            }

            comboBox3.DataSource = usersCombo;
        }
예제 #24
0
        private void button1_Click(object sender, EventArgs e) //Rload ver usuario
        {
            var Query = "SELECT * FROM appuser";
            var dt    = ConnectionDB.ExecuteQuery(Query);

            try
            {
                dataGridView1.DataSource = dt;
            }
            catch (Exception exception)
            {
                MessageBox.Show("Error");
            }
        }
예제 #25
0
        private void button4_Click(object sender, EventArgs e) //RldNegocio
        {
            var Query = "SELECT * FROM business";
            var dt    = ConnectionDB.ExecuteQuery(Query);

            try
            {
                dataGridView2.DataSource = dt;
            }
            catch (Exception exception)
            {
                MessageBox.Show("Error");
            }
        }
        //Mostrando historial (tabla3):
        public static void ProductQueryGainT2(DataGridView dataGridView1)
        {
            try
            {
                var dt = ConnectionDB.ExecuteQuery($"SELECT SUM(ganancia)FROM GANANCIADIAARTICULO;");

                dataGridView1.DataSource = dt;
            }

            catch (Exception exception)
            {
                MessageBox.Show("Ha ocurrido un problema");
            }
        }
예제 #27
0
        public void DatosBusiness()
        {
            string query2     = "select business.name from business";
            var    users      = ConnectionDB.ExecuteQuery(query2);
            var    usersCombo = new List <string>();

            foreach (DataRow dr in users.Rows)
            {
                usersCombo.Add(dr[0].ToString());
            }

            comboBox4.DataSource = usersCombo;
            comboBox1.DataSource = usersCombo;
        }
예제 #28
0
        public void DatosProduct()
        {
            string query2     = "select product.name from product";
            var    users      = ConnectionDB.ExecuteQuery(query2);
            var    usersCombo = new List <string>();

            foreach (DataRow dr in users.Rows)
            {
                usersCombo.Add(dr[0].ToString());
            }

            comboBox5.DataSource = usersCombo;
            comboBox6.DataSource = usersCombo;
        }
예제 #29
0
        public void DatosAddress()
        {
            string query2     = "select address from address";
            var    users      = ConnectionDB.ExecuteQuery(query2);
            var    usersCombo = new List <string>();

            foreach (DataRow dr in users.Rows)
            {
                usersCombo.Add(dr[0].ToString());
            }

            comboBox2.DataSource = usersCombo;
            comboBox8.DataSource = usersCombo;
        }
예제 #30
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                var dt = ConnectionDB.ExecuteQuery("SELECT * FROM appuser");

                dataGridView1.DataSource = dt;
                MessageBox.Show("Datos obtenidos correctamente");
            }
            catch (Exception)
            {
                MessageBox.Show("Ha ocurrido un problema");
            }
        }