// Memproses data pengubahan yang di-input user private void BtnSave_Click(object sender, EventArgs e) { long nomor = 0; Boolean progress = true; // Pengecekan isi textbox if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "") { MessageBox.Show("Informasi tidak boleh ada yang kosong!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { // Cek apakah format nomor telepon sudah benar try { nomor = long.Parse(textBox2.Text); } catch (FormatException) { MessageBox.Show($"Nomor hanya boleh mengandung angka!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); progress = false; } // Cek apakah format E-mail sudah benar try { var addr = new System.Net.Mail.MailAddress(textBox4.Text); } catch { MessageBox.Show("Format E-mail tidak benar!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); progress = false; } // Memulai proses edit jika semua format pengisian sudah benar if (progress == true) { Data data = new Data(); using (var db = new DBModel()) { var profil = db.Akun.SingleOrDefault(k => k.Uname == Data.uname); var ex = db.Experience.SingleOrDefault(k => k.Akun == Data.uname); profil.First_Name = textBox1.Text; profil.Last_Name = textBox3.Text; profil.Phone = textBox2.Text; profil.Email = textBox4.Text; db.SaveChanges(); var query = (from akun in db.Akun where akun.Uname == Data.uname select akun).FirstOrDefault(); data.dataProfil(query.First_Name, query.Last_Name, query.Email, (query.Id).ToString(), query.Phone, query.Uname); } MessageBox.Show("Pergantian data berhasil!", "Notifikasi", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Visible = false; Profile propil = new Profile(); Home home = new Home(); propil.Visible = false; home.ShowDialog(); } } }