Exemple #1
0
        public static bool attemp_login(string uname, string pass)
        {
            DbInterface.open();
            Dictionary <string, string> args = new Dictionary <string, string>();

            args.Add("@uname", uname);
            args.Add("@pass", pass);
            string[][] count = DbInterface.returnQuery(" SELECT * FROM user WHERE username = @uname AND password = @pass ", args);
            if (count.Length > 0)
            {
                isAllowedLogin = true;
            }
            else
            {
                isAllowedLogin = false;
            }
            DbInterface.close();
            return(isAllowedLogin);
        }
Exemple #2
0
        private void read(object sender, EventArgs e)
        {
            try
            {
                if (!checkView())
                {
                    throw new Exception();
                }
                tab_action[tabControl1.SelectedTab]();
                DbInterface.open();
                lblStatus.Text = "Begin Query";
                string tab   = tab_table[tabControl1.SelectedTab];
                string query = READ.query[tab];
                lblStatus.Text = "Querying";
                string[][] data = DbInterface.returnQuery(query);
                lblStatus.Text = "Query Successful";
                lblStatus.Text = "get table data";
                DbInterface.close();
                DbInterface.open();
                string[] column = DbInterface.getColumn(tab);
                lblStatus.Text = "Populating table";
                DataTable dt = new DataTable();
                foreach (string s in column)
                {
                    dt.Columns.Add(new DataColumn(s));
                }
                foreach (string[] s in data)
                {
                    dt.Rows.Add(s);
                }
                view.dataGridView1.DataSource = dt;
                foreach (DataGridViewColumn c in view.dataGridView1.Columns)
                {
                    c.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                }
                DbInterface.close();
            }
            catch (Exception ex) {
                DbInterface.close();

                lblStatus.Text = "Query Failed";
            }
        }