Exemple #1
0
 private void btnSimpan_Click(object sender, EventArgs e)
 {
     using (var db = new AkunModel())
     {
         var result = db.Akun.SingleOrDefault(a => a.Username == lblUsername.Text);
         if (result != null)
         {
             result.Poin    = int.Parse(lblSkor.Text);
             result.Kondisi = lblKeterangan.Text;
             db.SaveChanges();
             MessageBox.Show("Data tersimpan!");
         }
     }
 }
Exemple #2
0
        private void DaftarAkun()
        {
            if (tbNama.Text != "" && tbUmur.Text != "" && tbPassword.Text != "" && tbKonfirmasiPass.Text != "")
            {
                if (tbPassword.Text.Length > 8)
                {
                    if (tbPassword.Text == tbKonfirmasiPass.Text)
                    {
                        using (var db = new AkunModel())
                        {
                            string jenisKelamin;
                            if (rbLaki.Checked)
                            {
                                jenisKelamin = "Laki-laki";
                            }
                            else
                            {
                                jenisKelamin = "Perempuan";
                            }

                            Akun newAkun = new Akun
                            {
                                Username = tbNama.Text,
                                Umur     = Convert.ToInt32(tbUmur.Text),
                                Gender   = jenisKelamin,
                                Password = tbPassword.Text,
                            };
                            db.Akun.Add(newAkun);
                            db.SaveChanges();
                            MessageBox.Show("Akun terdaftar");
                            Close();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Password tidak sama");
                    }
                }
                else
                {
                    MessageBox.Show("Password harus lebih dari 8 karalter");
                }
            }
            else
            {
                MessageBox.Show("Data harus diisi lengkap!");
            }
        }
Exemple #3
0
 private void deleteAccountToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (var db = new AkunModel())
     {
         db.Akun.RemoveRange(db.Akun.Where(item => item.Username == lblUsername.Text));
         db.SaveChanges();
         lblUsername.Text      = "(UserName)";
         lblGender.Text        = "-";
         lblUmur.Text          = "-";
         btnCekKondisi.Enabled = false;
         btnPsikolog.Enabled   = false;
         btnLogin.Visible      = true;
         lblLogin.Visible      = true;
     }
     loginForm.isCorrect = false;
     MessageBox.Show("Akun Telah Dihapus");
 }
Exemple #4
0
        private void EditAkun()
        {
            using (var db = new AkunModel())
            {
                var result = db.Akun.SingleOrDefault(a => a.Username == akun.Username);
                if (result != null)
                {
                    if (tbNama.Text != "" && tbUmur.Text != "" && tbPassword.Text != "" && tbKonfirmasiPass.Text != "")
                    {
                        if (PasswordCheck(tbPassword.Text, tbKonfirmasiPass.Text))
                        {
                            result.Username = tbNama.Text;
                            result.Umur     = Convert.ToInt32(tbUmur.Text);
                            result.Password = tbPassword.Text;

                            if (rbLaki.Checked)
                            {
                                result.Gender = "Laki-laki";
                            }
                            else
                            {
                                result.Gender = "Perempuan";
                            }

                            db.SaveChanges();
                            MessageBox.Show("Kontak berhasil diperbarui");
                            Close();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Nama, Alamat, dan Nomor Telepon harus diisi");
                    }
                }
            }
        }