Exemple #1
0
        private void configurarGraficoPastel()
        {
            // Posicion (ubicacion) y tamanio
            graficoPastel.Top    = 5;
            graficoPastel.Left   = 5;
            graficoPastel.Width  = 350;
            graficoPastel.Height = 250;

            var dt = ConexionBD.EjecutarConsulta("SELECT b.name AS Negocio, sum(cp.cant) AS pedidos " +
                                                 "FROM BUSINESS b, " +
                                                 "(SELECT p.idBusiness, p.name, count(ap.idProduct) AS cant " +
                                                 "FROM PRODUCT p, APPORDER ap " +
                                                 "WHERE p.idProduct = ap.idProduct " +
                                                 "GROUP BY p.idProduct " +
                                                 "ORDER BY p.name ASC) AS cp " +
                                                 "WHERE b.idBusiness = cp.idBusiness " +
                                                 "GROUP BY b.idBusiness;");

            // Configuracion de series, leyenda y poblado de datos
            graficoPastel.Series = new SeriesCollection();

            foreach (DataRow dr in dt.Rows)
            {
                graficoPastel.Series.Add(new PieSeries {
                    Title  = $"{dr[0].ToString()}",
                    Values = new ChartValues <int> {
                        Convert.ToInt32(dr[1].ToString())
                    }, DataLabels = true
                });
            }

            graficoPastel.LegendLocation = LegendLocation.Bottom;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string id          = "";
                string idDireccion = "";
                var    dt3         = ConexionBD.EjecutarConsulta(
                    $"SELECT ad.idAddress FROM ADDRESS ad WHERE ad.address = '{comboBox2.Text}'");

                foreach (DataRow dr in dt3.Rows)
                {
                    idDireccion = dr[0].ToString();
                }

                //id del producto
                var dt4 = ConexionBD.EjecutarConsulta("SELECT pro.idproduct " +
                                                      "FROM PRODUCT pro " +
                                                      $"WHERE pro.name = '{comboBox1.Text}'");

                foreach (DataRow dr in dt4.Rows)
                {
                    id = dr[0].ToString();
                }

                ConexionBD.EjecutarComando("INSERT INTO APPORDER(createDate, idProduct, idAddress) " +
                                           $"VALUES('{textBox1.Text}', {id}, {idDireccion});");

                MessageBox.Show("Orden agregada");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Algo salio mal");
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                int id  = 0;
                var dt2 = ConexionBD.EjecutarConsulta("SELECT app.iduser " +
                                                      "FROM APPUSER app " +
                                                      $"WHERE app.username = '******'");
                foreach (DataRow dr in dt2.Rows)
                {
                    id = Convert.ToInt32(dr[0].ToString());
                }

                var dt = ConexionBD.EjecutarConsulta("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 = {id};");

                dataGridView1.DataSource = dt;
            }
            catch (Exception ex)
            {
                MessageBox.Show("algo salio mal");
            }
        }
Exemple #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var dt = ConexionBD.EjecutarConsulta("SELECT * FROM PRODUCT;");

                dataGridView1.DataSource = dt;
            }
            catch (Exception ex)
            {
                MessageBox.Show("algo salio mal");
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            var dt = ConexionBD.EjecutarConsulta("SELECT pro.name " +
                                                 "FROM PRODUCT pro " +
                                                 $"WHERE pro.idbusiness = {comboBox3.Text}");

            var dtcombo = new List <string>();

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

            comboBox1.DataSource = dtcombo;
        }
        public DirrecionAgregar()
        {
            InitializeComponent();

            var dt = ConexionBD.EjecutarConsulta("SELECT app.iduser " +
                                                 "FROM APPUSER app " +
                                                 $"WHERE app.username = '******'");

            foreach (DataRow dr in dt.Rows)
            {
                id = Convert.ToInt32(dr[0].ToString());
            }

            textBox2.Text = Convert.ToString(id);
        }
        public ProductoAgregar()
        {
            InitializeComponent();

            var dt = ConexionBD.EjecutarConsulta("SELECT bus.idbusiness " +
                                                 "FROM BUSINESS bus;");

            var dtcombo = new List <string>();

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

            comboBox1.DataSource = dtcombo;
        }
        public OrdenAgregar()
        {
            InitializeComponent();


            //id del usuario para las direcciones
            int id  = 0;
            var dt4 = ConexionBD.EjecutarConsulta("SELECT app.iduser " +
                                                  "FROM APPUSER app " +
                                                  $"WHERE app.username = '******'");

            foreach (DataRow dr in dt4.Rows)
            {
                id = Convert.ToInt32(dr[0].ToString());
            }

            var dt2 = ConexionBD.EjecutarConsulta("SELECT ad.address " +
                                                  "FROM ADDRESS ad " +
                                                  $"WHERE ad.iduser = {id}");

            var dtcombo2 = new List <string>();

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

            comboBox2.DataSource = dtcombo2;

            //fecha actual
            DateTime hoy = DateTime.Now;

            textBox1.Text = hoy.ToString("dd/MM/yyyy");

            //Id empresa
            var dt5 = ConexionBD.EjecutarConsulta("SELECT bus.idbusiness " +
                                                  "FROM BUSINESS bus;");

            var dtcombo3 = new List <string>();

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

            comboBox3.DataSource = dtcombo3;
        }
Exemple #9
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string id  = "";
                var    dt1 = ConexionBD.EjecutarConsulta("SELECT app.iduser " +
                                                         "FROM APPUSER app " +
                                                         $"WHERE app.username = '******'");
                foreach (DataRow dr in dt1.Rows)
                {
                    id = dr[0].ToString();
                }

                var dt = ConexionBD.EjecutarConsulta("SELECT ad.idAddress, ad.address " +
                                                     $"FROM ADDRESS ad WHERE idUser = {id}");

                dataGridView1.DataSource = dt;
            }
            catch (Exception ex)
            {
                MessageBox.Show("algo salio mal");
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Equals("") || textBox2.Text.Equals(""))
            {
                try
                {
                    throw new ErrorEmptyDataException("No se pueden dejar espacios vacios");
                }
                catch (ErrorEmptyDataException ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else if (!textBox1.Text.Equals(textBox2.Text))
            {
                try
                {
                    throw new ErrorNotValidDataException("El usuario y contrasena debes ser iguales");
                }
                catch (ErrorNotValidDataException ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                try
                {
                    var dt = ConexionBD.EjecutarConsulta("SELECT ap.usertype, ap.iduser " +
                                                         "FROM APPUSER ap " +
                                                         $"WHERE ap.username = '******' AND ap.password = '******';");

                    if (dt.Rows[0][0].Equals(true))
                    {
                        MessageBox.Show($"Bienvenido Administrador {textBox1.Text}");
                        Administrador admin = new Administrador();
                        admin.Show();
                    }
                    else
                    {
                        int id  = 0;
                        var dt2 = ConexionBD.EjecutarConsulta("SELECT app.iduser " +
                                                              "FROM APPUSER app " +
                                                              $"WHERE app.username = '******'");
                        foreach (DataRow dr in dt2.Rows)
                        {
                            id = Convert.ToInt32(dr[0].ToString());
                        }

                        MessageBox.Show($"Bienvenido Usuario {textBox1.Text}");
                        ActualUsuario.personaActual(textBox1.Text);
                        ActualUsuario.IdActual(id);
                        UsuarioComun user = new UsuarioComun();
                        user.Show();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Ocurrio un Problema");
                }
            }
        }