示例#1
0
        public void ValidateUser()
        {
            var sql =
                $"SELECT userType FROM public.APPUSER WHERE username='******' AND password='******'";

            var conn = Conection.QueryDB(sql);


            if (conn.Rows.Count == 0)
            {
                MessageBox.Show("Usuario inválido. Intente de nuevo.");
            }
            else
            {
                string isAdmin = conn.Rows[0][0].ToString();
                //MessageBox.Show(Convert.ToString(isAdmin));
                if (isAdmin == "True")
                {
                    MessageBox.Show("Login exitoso");
                    this.Hide();
                    new MainMenu().Show();
                }
                else
                {
                    MessageBox.Show("Login exitoso");
                    this.Hide();
                    new MainMenuRegular().Show();
                }
            }
        }
        public ViewHistory()
        {
            InitializeComponent();
            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 sql2 =
                $"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 = 2;";



            var conn = Conection.QueryDB(sql2);

            dataGridView1.DataSource = conn;
        }