Exemple #1
0
        void update_user()
        {
            string sql_command = @"update users 
            set username = '******', password='******' where id_user = {2};";

            try
            {
                con.open();
                con.command(string.Format(sql_command, this.textBox1.Text, this.textBox2.Text, this.user_id));
                con.close();
                MessageBox.Show("User has been updated succesfully!");
                if (Modu != null)
                {
                    Modu.update_dfv(true);
                }
                this.Close();
            }catch (Exception ex)
            {
                try { con.close(); } catch { }
                if (ex.Message.Contains("UNIQUE") && ex.Message.Contains("user"))
                {
                    MessageBox.Show("Username already registered!");
                }
                else
                {
                    MessageBox.Show(ex.Message);
                }
                Application.DoEvents();
            }
        }
Exemple #2
0
 public void update_sessions()
 {
     try
     {
         string tmp = string.Format(sql, user_id);
         dataGridView1.Columns[1].DefaultCellStyle.Format = "yyyy-MM-dd HH:mm";
         con.open();
         this.dataGridView1.DataSource = con.select(tmp).Tables[0];
         con.close();
         dataGridView1.Columns[1].DefaultCellStyle.Format = "yyyy-MM-dd HH:mm";
     }
     catch { }
 }
Exemple #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            string sql;

            if (isModding)
            {
                sql = @"update session set time_date='{0}',comment='{1}' where id_session={2}";
                con.open();
                con.command(string.Format(sql, dateTimePicker1.Value.ToString("yyyy-MM-dd hh:mm"), this.textBox1.Text, this.session_id));
                con.close();
                ss.update_sessions();
                this.Close();
            }
            else
            {
                sql = @"insert into session(id_user,time_date,comment) values({0},'{2}','{1}')";
                con.open();
                con.command(string.Format(sql, this.session_user, this.textBox1.Text, dateTimePicker1.Value.ToString("yyyy-MM-dd hh:mm")));
                con.close();
                ss.update_sessions();
                this.Close();
            }
        }
Exemple #4
0
        private void MainMenu_Load(object sender, EventArgs e)
        {
            string sql = @"
            select username from users where id_user={0}
            ";

            con = new sqlite_connector();
            con.open();

            string title = con.select(string.Format(sql, id_user.ToString())).Tables[0].Rows[0].ItemArray[0].ToString();

            con.close();
            this.Text += ": Logged in as " + title;
            if (id_user == ROOT_ID)
            {
                mod_users = new ToolStripMenuItem("Users", null, userToolStripMenuItem);
                menuStrip1.Items.Add(mod_users);
            }
        }
Exemple #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!check_valid_values())
            {
                MessageBox.Show("One or more fields are empty!");
            }
            else
            {
                string username = textBox1.Text;
                string password = textBox2.Text;
                string sql      = @"select id_user from users where username='******' and password='******'";
                string id       = "";
                con.open();
                try
                {
                    id = con.select(string.Format(sql, username, password)).
                         Tables[0].Rows[0].ItemArray[0].ToString();
                    con.close();
                }catch (System.IndexOutOfRangeException ex)
                {
                    try { con.close(); } catch { }
                    id = "";
                }

                if (id == "")
                {
                    MessageBox.Show("Entered credentials are incorrect.");
                }
                else
                {
                    login_ok = true;
                    login_id = Convert.ToInt32(id);
                    this.Close();
                }
            }
        }
Exemple #6
0
 private void Modify_Users_Load(object sender, EventArgs e)
 {
     con.open();
     this.dataGridView1.DataSource = con.select(sql_main).Tables[0];
     con.close();
 }