Ejemplo n.º 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         conn.Open();
         Sha sha = new Sha(password.Text);
         cmd = new OleDbCommand("Select * from Users", conn);
         dr  = cmd.ExecuteReader();
         int str = 0;
         while (dr.Read())
         {
             str = int.Parse(dr[0].ToString());
             str++;
         }
         dr.Close();
         cmd             = conn.CreateCommand();
         cmd.CommandText = "insert into Users values (" + str + ",'" + username.Text + "','" + sha.GetPassword() + "',0,'" + fname.Text + "','" + lname.Text + "');";
         cmd.ExecuteNonQuery();
         MessageBox.Show("Create User Success!");
         conn.Close();
     }
     catch (OleDbException ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Ejemplo n.º 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         conn.Open();
         cmd = new OleDbCommand("Select * from Users where Username='******'", conn);
         dr  = cmd.ExecuteReader();
         Sha sha = new Sha(password.Text);
         dr.Read();
         if (dr["Password"].ToString() == sha.GetPassword())
         {
             if (int.Parse(dr["Permission"].ToString()) == 1)
             {
                 AdminLogin admin = new AdminLogin(int.Parse(dr["id"].ToString()));
                 admin.Show();
                 this.Close();
             }
             else
             {
                 Users user = new Users(int.Parse(dr["id"].ToString()));
                 user.Show();
                 this.Close();
             }
         }
         else
         {
             MessageBox.Show("Error!");
         }
         dr.Close();
         conn.Close();
     }
     catch (OleDbException ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }