コード例 #1
0
        private void button6_Click(object sender, EventArgs e)
        {
            if (textBox5.Text.Equals(""))
            {
                MessageBox.Show("Llene todos los campos");
            }
            else
            {
                try
                {
                    var qr = $"SELECT idBusiness FROM public.business WHERE" +
                             $" name = '{comboBox3.GetItemText(comboBox3.SelectedItem)}'";
                    DataTable dt  = ConnectionBD.ExecuteQuery(qr);
                    int       id4 = Convert.ToInt32(dt.Rows[0][0].ToString());

                    ConnectionBD.ExecuteNonQuery($"INSERT INTO public.product(idBusiness, name)" +
                                                 $" VALUES({id4}, '{textBox5.Text}')");

                    MessageBox.Show("Se ha guardado el producto");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Ha ocurrido un error");
                }
            }
        }
コード例 #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (textBox2.Text.Equals(""))
            {
                MessageBox.Show("Llene todos los campos");
            }
            else
            {
                try
                {
                    var qr =
                        $"SELECT idAddress FROM public.address WHERE" +
                        $" address = '{comboBox2.GetItemText(comboBox2.SelectedItem)}'";
                    DataTable dt  = ConnectionBD.ExecuteQuery(qr);
                    int       id2 = Convert.ToInt32(dt.Rows[0][0].ToString());

                    //MODIFICAR DIRECCION
                    ConnectionBD.ExecuteNonQuery(
                        $"UPDATE public.address SET address = '{textBox2.Text}' WHERE idAddress = {id2}");

                    MessageBox.Show("Se ha modificado la direccion");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("ha ocurrido un error");
                }
            }
        }
コード例 #3
0
        public void login()
        {
            try
            {
                string query =
                    $"SELECT * FROM public.appuser WHERE username='******' AND password='******'";

                var  dt    = ConnectionBD.ExecuteQuery(query);
                bool admin = Convert.ToBoolean(dt.Rows[0][4].ToString());

                if (dt.Rows.Count == 1)
                {
                    Hide();
                    if (admin)
                    {
                        new adminuser().Show();
                    }
                    else
                    {
                        var dr = dt.Rows[0][0];
                        int n  = Convert.ToInt32(dr);
                        new normaluser(n, dt.Rows[0][2].ToString()).Show();
                    }
                }
                else
                {
                    MessageBox.Show("Usuario y/o Contraseña Incorrecta");
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Ha ocurrido un error");
            }
        }
コード例 #4
0
        private void button4_Click(object sender, EventArgs e)
        {
            try
            {
                var qr =
                    $"SELECT idAddress FROM public.address WHERE" +
                    $" address = '{comboBox4.GetItemText(comboBox4.SelectedItem)}'";
                DataTable dt  = ConnectionBD.ExecuteQuery(qr);
                int       id3 = Convert.ToInt32(dt.Rows[0][0].ToString());

                var qr2 = $"SELECT idProduct FROM public.product WHERE" +
                          $" name = '{comboBox3.GetItemText(comboBox3.SelectedItem)}'";
                DataTable dt2 = ConnectionBD.ExecuteQuery(qr2);
                int       id4 = Convert.ToInt32(dt2.Rows[0][0].ToString());

                var date = ((DateTime.Now)).ToString(@"yyyy-MM-dd");;

                ConnectionBD.ExecuteNonQuery($"INSERT INTO public.appOrder(createDate, idProduct, idAddress)" +
                                             $" VALUES('{date}', {id4}, {id3})");

                MessageBox.Show("Su orden ha sido procesada");
            }
            catch (Exception exception)
            {
                MessageBox.Show("Ha ocurrido un error!");
            }
        }
コード例 #5
0
        private void button7_Click(object sender, EventArgs e)
        {
            var qr = $"SELECT idProduct FROM public.product WHERE name" +
                     $" = '{comboBox4.GetItemText(comboBox4.SelectedItem)}'";
            DataTable dt  = ConnectionBD.ExecuteQuery(qr);
            int       id5 = Convert.ToInt32(dt.Rows[0][0].ToString());

            ConnectionBD.ExecuteNonQuery($"DELETE FROM public.product WHERE idProduct = {id5}");

            MessageBox.Show("El producto ha sido eliminado!");
        }
コード例 #6
0
        private void button5_Click(object sender, EventArgs e)
        {
            var qr = $"SELECT idBusiness FROM public.business WHERE" +
                     $" name = '{comboBox2.GetItemText(comboBox2.SelectedItem)}'";
            DataTable dt  = ConnectionBD.ExecuteQuery(qr);
            int       id3 = Convert.ToInt32(dt.Rows[0][0].ToString());

            ConnectionBD.ExecuteNonQuery($"DELETE FROM public.business WHERE idBusiness = {id3}");

            MessageBox.Show("El negocio ha sido eliminado!");
        }
コード例 #7
0
        private void button2_Click_1(object sender, EventArgs e)
        {
            var qr = $"SELECT idUser FROM public.appuser WHERE" +
                     $" username = '******'";
            DataTable dt  = ConnectionBD.ExecuteQuery(qr);
            int       idd = Convert.ToInt32(dt.Rows[0][0].ToString());

            ConnectionBD.ExecuteNonQuery($"DELETE FROM public.appuser WHERE idUser = {idd}");

            MessageBox.Show("El usuario ha sido eliminado!");
        }
コード例 #8
0
        private void button2_Click(object sender, EventArgs e)
        {
            var qr = $"SELECT idAddress FROM public.address WHERE" +
                     $" address = '{comboBox1.GetItemText(comboBox1.SelectedItem)}'";
            DataTable dt  = ConnectionBD.ExecuteQuery(qr);
            int       idd = Convert.ToInt32(dt.Rows[0][0].ToString());

            ConnectionBD.ExecuteNonQuery($"DELETE FROM public.address WHERE idAddress = {idd}");

            MessageBox.Show("La direccion ha sido eliminada!");
        }
コード例 #9
0
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                var dt = ConnectionBD.ExecuteQuery($"SELECT * FROM public.appuser");

                dataGridView1.DataSource = dt;
                MessageBox.Show("Datos obtenidos correctamente");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ha ocurrido un error.");
            }
        }
コード例 #10
0
        private void button8_Click(object sender, EventArgs e)
        {
            try
            {
                var dt = 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");

                dataGridView2.DataSource = dt;
                MessageBox.Show("Datos obtenidos correctamente");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ha ocurrido un error.");
            }
        }
コード例 #11
0
        private void adminuser_Load(object sender, EventArgs e)
        {
            var users      = ConnectionBD.ExecuteQuery($"SELECT username FROM public.appuser");
            var userscombo = new List <string>();

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

            comboBox1.DataSource = userscombo;

            var busi       = ConnectionBD.ExecuteQuery($"SELECT name FROM public.business");
            var busicombo  = new List <string>();
            var busicombo2 = new List <string>();
            var busicombo3 = new List <string>();

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

            comboBox2.DataSource = busicombo;

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

            comboBox3.DataSource = busicombo2;

            var prod      = ConnectionBD.ExecuteQuery($"SELECT name FROM public.product");
            var prodcombo = new List <string>();

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

            comboBox4.DataSource = prodcombo;
        }
コード例 #12
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Equals("") ||
                textBox2.Text.Equals(""))
            {
                MessageBox.Show("Llene todos los campos");
            }
            else
            {
                try
                {
                    var sl = $"SELECT * FROM public.appuser WHERE username = '******'";
                    var dt = ConnectionBD.ExecuteQuery(sl);
                    if (dt != null)
                    {
                        if (checkBox1.Checked)
                        {
                            ConnectionBD.ExecuteNonQuery($"INSERT INTO" +
                                                         $" public.appuser(fullname, username, password," +
                                                         $" userType) VALUES('{textBox1.Text}', '{textBox2.Text}'," +
                                                         $" '{textBox2.Text}'," +
                                                         $" {true})");
                        }
                        else
                        {
                            ConnectionBD.ExecuteNonQuery($"INSERT INTO" +
                                                         $" public.appuser(fullname, username, password," +
                                                         $" userType) VALUES('{textBox1.Text}', '{textBox2.Text}'," +
                                                         $" '{textBox2.Text}'," +
                                                         $" {false})");
                        }

                        MessageBox.Show("El usuario ha sido creado");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("El usuario ya existe...");
                }
            }
        }
コード例 #13
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Equals(""))
            {
                MessageBox.Show("Llene todos los campos!");
            }
            else
            {
                try
                {
                    ConnectionBD.ExecuteNonQuery($"INSERT INTO public.address(idUser, address)" +
                                                 $" VALUES({id}, '{textBox1.Text}')");

                    MessageBox.Show("La direccion se ha guardado!");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Ha ocurrido un error!");
                }
            }
        }
コード例 #14
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Equals("") ||
                textBox2.Text.Equals("") ||
                textBox3.Text.Equals("") ||
                textBox4.Text.Equals(""))
            {
                MessageBox.Show("Llene todos los campos");
            }
            else
            {
                try
                {
                    string query =
                        $"SELECT * FROM public.appuser WHERE username='******' AND password='******'";
                    var dt = ConnectionBD.ExecuteQuery(query);

                    if (dt.Rows.Count == 1)
                    {
                        if (textBox3.Text.Equals(textBox4.Text))
                        {
                            ConnectionBD.ExecuteNonQuery($"UPDATE public.appuser SET password = '******' WHERE" +
                                                         $" username = '******'");
                            MessageBox.Show("Se ha actualizado la contraseña");

                            Hide();
                            new Form1().Show();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Usuario y/o Contraseña Incorrecta");
                    }
                }
                catch (Exception exception)
                {
                    MessageBox.Show("Ha ocurrido un error!");
                }
            }
        }
コード例 #15
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (textBox3.Text.Equals("") ||
                textBox4.Text.Equals(""))
            {
                MessageBox.Show("Llene todos los campos");
            }
            else
            {
                try
                {
                    ConnectionBD.ExecuteNonQuery($"INSERT INTO public.business(name, description)" +
                                                 $" VALUES('{textBox3.Text}', '{textBox4.Text}')");

                    MessageBox.Show("Se ha creado el negocio");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Ha ocurrido un error");
                }
            }
        }
コード例 #16
0
        private void normaluser_Load(object sender, EventArgs e)
        {
            var addr = ConnectionBD.ExecuteQuery($"SELECT address FROM public.address" +
                                                 $" WHERE idUser = {id}");
            var addrcombo  = new List <string>();
            var addrcombo2 = new List <string>();
            var addrcombo3 = new List <string>();

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

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

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

            comboBox1.DataSource = addrcombo;
            comboBox2.DataSource = addrcombo2;
            comboBox4.DataSource = addrcombo3;

            var prod      = ConnectionBD.ExecuteQuery($"SELECT name FROM public.product");
            var prodcombo = new List <string>();

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

            comboBox3.DataSource = prodcombo;
        }