示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string query = $"SELECT EXISTS(SELECT * FROM APPUSER WHERE username = '******'" +
                               $"AND password = '******')";
                var dt = ConnectionDB.executeQuery(query);
                var dr = dt.Rows[0][0];
                if ((bool)dr)
                {
                    string quer = $"SELECT * FROM APPUSER WHERE username = '******'" +
                                  $"AND password = '******'";

                    var dte = ConnectionDB.executeQuery(quer);

                    Program.activeUser.Id       = Convert.ToInt32(dte.Rows[0][0]);
                    Program.activeUser.Name     = Convert.ToString(dte.Rows[0][1]);
                    Program.activeUser.Nickname = Convert.ToString(dte.Rows[0][2]);
                    Program.activeUser.Password = Convert.ToString(dte.Rows[0][3]);
                    Program.activeUser.Type     = Convert.ToBoolean(dte.Rows[0][4]);

                    this.Hide();
                    new Main().Show();
                }
                else
                {
                    MessageBox.Show("El usuario y contraseña no existen :(");
                }
            }
            catch
            {
                MessageBox.Show("Ha ocurrido un error @.@");
            }
        }
示例#2
0
        private void LoadDataToTables()
        {
            string query = $"SELECT idbusiness from business where name = '{comboBox1.Text.ToString()}'";
            var    dr    = ConnectionDB.executeQuery(query);

            idBusiness = dr.Rows[0][0].ToString();
            var dt = ConnectionDB.executeQuery($"SELECT p.idProduct, p.name FROM PRODUCT p WHERE idbusiness = {idBusiness} ");

            dataGridView1.DataSource = dt;
        }
示例#3
0
        private void Productos_Load(object sender, EventArgs e)
        {
            string query         = "SELECT name from business";
            var    businessCombo = new List <string>();
            var    business      = ConnectionDB.executeQuery(query);

            foreach (DataRow dr in business.Rows)
            {
                businessCombo.Add(dr[0].ToString());
            }
            comboBox1.DataSource = businessCombo;
            LoadDataToTables();
        }
示例#4
0
        private void LoadDataToTables()
        {
            string query = "";

            if (Program.activeUser.Type)
            {
                query = "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";
            }
            else
            {
                query = $"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 = {Program.activeUser.Id.ToString()}";
            }
            var dt = ConnectionDB.executeQuery(query);

            dataGridView1.DataSource = dt;

            if (Program.activeUser.Type)
            {
                var dt2 = ConnectionDB.executeQuery("SELECT p.idProduct, p.name, b.name as empresa FROM PRODUCT p, business b WHERE b.idbusiness = p.idbusiness");
                dataGridView2.DataSource = dt2;
                var dt3 = ConnectionDB.executeQuery($"SELECT * FROM address where iduser = '******'");
                dataGridView3.DataSource = dt3;
            }
        }
示例#5
0
        private void LoadDataToTables()
        {
            var dt = ConnectionDB.executeQuery("SELECT * FROM business");

            dataGridView1.DataSource = dt;
        }