private void LoadComboBoxes()
        {
            try
            {
                var dti = ConnectionDB.ExecuteQuery("SELECT iduser FROM appuser " +
                                                    $"WHERE username = '******'");
                var dri    = dti.Rows[0];
                int auxidu = Convert.ToInt16(dri[0].ToString());

                var direcciones = ConnectionDB.ExecuteQuery("SELECT idaddress,address FROM address " +
                                                            $"WHERE iduser = {auxidu}");
                var direccionesCombo = new List <string>();

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

                foreach (DataRow dr in direcciones.Rows)
                {
                    direccionesCombo.Add(dr[0].ToString() + " " + dr[1].ToString());
                }

                foreach (DataRow dr in negocios.Rows)
                {
                    negocosCombo.Add(dr[0].ToString() + " " + dr[1].ToString());
                }

                cmbDirecciones.DataSource = direccionesCombo;
                cmbNegocios.DataSource    = negocosCombo;

                string auxcadena = cmbNegocios.SelectedItem.ToString();
                int    auxlim    = LimiteFinal(auxcadena);
                int    auxid     = 0;
                if (auxlim > 0)
                {
                    auxid = Convert.ToInt16(auxcadena.Substring(0, auxlim));
                }
                else
                {
                    auxid = Convert.ToInt16($"{auxcadena[0]}");
                }

                var producto = ConnectionDB.ExecuteQuery("SELECT idproduct,name FROM product " +
                                                         $"WHERE idbusiness = {auxid}");
                var productoCombo = new List <string>();

                foreach (DataRow dr in producto.Rows)
                {
                    productoCombo.Add(dr[0].ToString() + " " + dr[1].ToString());
                }
                cmbProductos.DataSource = productoCombo;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ha ocurrido un erro al cargar las listas!");
            }
        }
Exemplo n.º 2
0
        private void LoadHistorial()
        {
            var dti = ConnectionDB.ExecuteQuery("SELECT iduser FROM appuser " +
                                                $"WHERE username = '******'");
            var dri   = dti.Rows[0];
            int auxid = Convert.ToInt16(dri[0].ToString());
            var dt    = ConnectionDB.ExecuteQuery("SELECT idaddress,address FROM address " +
                                                  $"WHERE iduser = {auxid}");

            dgvDirecciones.DataSource = dt;
            var dt2 = ConnectionDB.ExecuteQuery("SELECT app.idorder,apu.fullname,adr.address," +
                                                "pro.name,bus.name,app.createdate " +
                                                "FROM APPORDER app, PRODUCT pro, APPUSER apu, ADDRESS adr, BUSINESS bus " +
                                                "WHERE app.idaddress = adr.idaddress AND adr.iduser = apu.iduser " +
                                                $"AND apu.iduser = {auxid} AND app.idproduct = pro.idproduct AND pro.idbusiness = bus.idbusiness");

            dgvOrdenes.DataSource = dt2;
        }
Exemplo n.º 3
0
        private void LoadComboBoxes()
        {
            var dti = ConnectionDB.ExecuteQuery("SELECT iduser FROM appuser " +
                                                $"WHERE username = '******'");
            var dri    = dti.Rows[0];
            int auxidu = Convert.ToInt16(dri[0].ToString());

            var ordenes = ConnectionDB.ExecuteQuery("SELECT app.idorder,adr.address," +
                                                    "pro.name,bus.name,app.createdate " +
                                                    "FROM APPORDER app, PRODUCT pro, APPUSER apu, ADDRESS adr, BUSINESS bus " +
                                                    $"WHERE app.idaddress = adr.idaddress AND adr.iduser = apu.iduser AND apu.iduser = {auxidu}" +
                                                    "AND app.idproduct = pro.idproduct AND pro.idbusiness = bus.idbusiness");
            var ordenesCombo = new List <string>();

            foreach (DataRow dr in ordenes.Rows)
            {
                ordenesCombo.Add(dr[0].ToString() + " " + dr[1].ToString() + " " +
                                 dr[2].ToString() + " " + dr[3].ToString() + " " + dr[4].ToString());
            }
            cmbOrdenes.DataSource = ordenesCombo;
        }
Exemplo n.º 4
0
 public uscAnadirDireccion()
 {
     InitializeComponent();
     username = ControlDeUsuario.DevolverUserName();
 }