public static void AddUser(UserModel user)
        {
            string password = EncryptPassword.Encrypt(user.Password, "zxc123");

            using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
            {
                if (CheckIfUserExist(user) > 0)
                {
                    System.Windows.Forms.MessageBox.Show("Username sudah ada!", "Error", System.Windows.Forms.MessageBoxButtons.OK);
                }
                else
                {
                    cnn.Execute("INSERT INTO User (Username, Password, Nama, Jabatan, Instalasi, Role) " +
                                "VALUES (@Username, '" + password + "', @Nama, @Jabatan, @Instalasi, @Role)", user);
                }
            }
        }
예제 #2
0
 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex < 0)
     {
         return;
     }
     if (e.ColumnIndex == dataGridView1.Columns["updateButton"].Index)
     {
         UserModel newUser = new UserModel();
         newUser.Username  = (string)dataGridView1.Rows[e.RowIndex].Cells[3].Value;
         newUser.Password  = EncryptPassword.Encrypt((string)dataGridView1.Rows[e.RowIndex].Cells[4].Value, "zxc123");
         newUser.Nama      = (string)dataGridView1.Rows[e.RowIndex].Cells[5].Value;
         newUser.Jabatan   = (string)dataGridView1.Rows[e.RowIndex].Cells[6].Value;
         newUser.Instalasi = (string)dataGridView1.Rows[e.RowIndex].Cells[7].Value;
         newUser.Role      = (int)dataGridView1.Rows[e.RowIndex].Cells[8].Value;
         SqliteDataAccess.UpdateUser(ut.Rows[e.RowIndex][1].ToString(), newUser);
     }
     if (e.ColumnIndex == dataGridView1.Columns["deleteButton"].Index)
     {
         SqliteDataAccess.DeleteUser((string)dataGridView1.Rows[e.RowIndex].Cells[3].Value);
         dataGridView1.Rows.RemoveAt(e.RowIndex);
         initUserTable();
     }
 }