protected override void Simpan() { if (_isNewData) { _karyawan = new Karyawan(); } _karyawan.nama_karyawan = txtNama.Text; _karyawan.alamat = txtAlamat.Text; _karyawan.telepon = txtTelepon.Text; _karyawan.is_active = rdoAktif.Checked ? true : false; var jabatan = _listOfJabatan[cmbJabatan.SelectedIndex]; _karyawan.jabatan_id = jabatan.jabatan_id; _karyawan.Jabatan = jabatan; _karyawan.jenis_gajian = (JenisGajian)cmbJenisGaji.SelectedIndex; _karyawan.gaji_pokok = NumberHelper.StringToDouble(txtGajiPokok.Text); _karyawan.gaji_lembur = NumberHelper.StringToDouble(txtLembur.Text); var result = 0; var validationError = new ValidationError(); if (_isNewData) { result = _bll.Save(_karyawan, ref validationError); } else { result = _bll.Update(_karyawan, ref validationError); } if (result > 0) { Listener.Ok(this, _isNewData, _karyawan); if (_isNewData) { base.ResetForm(this); txtNama.Focus(); } else { this.Close(); } } else { if (validationError.Message.Length > 0) { MsgHelper.MsgWarning(validationError.Message); base.SetFocusObject(validationError.PropertyName, this); } else { MsgHelper.MsgUpdateError(); } } }
public void UpdateTest() { var obj = new Karyawan { karyawan_id = "72f28a4f-f364-423a-a09b-2b9571543fde", jabatan_id = "f1e4ea09-b777-4e56-bb90-db2bf9211468", nama_karyawan = "Bangkit", alamat = "Klaten", telepon = "0813283838383", gaji_pokok = 200000, is_active = true, jenis_gajian = JenisGajian.Mingguan, gaji_lembur = 60000 }; var validationError = new ValidationError(); var result = _bll.Update(obj, ref validationError); Console.WriteLine("Error : " + validationError.Message); Assert.IsTrue(result != 0); var updatedObj = _bll.GetByID(obj.karyawan_id); Assert.IsNotNull(updatedObj); Assert.AreEqual(obj.karyawan_id, updatedObj.karyawan_id); Assert.AreEqual(obj.jabatan_id, updatedObj.jabatan_id); Assert.AreEqual(obj.nama_karyawan, updatedObj.nama_karyawan); Assert.AreEqual(obj.alamat, updatedObj.alamat); Assert.AreEqual(obj.telepon, updatedObj.telepon); Assert.AreEqual(obj.gaji_pokok, updatedObj.gaji_pokok); Assert.AreEqual(obj.is_active, updatedObj.is_active); Assert.AreEqual(obj.keterangan, updatedObj.keterangan); Assert.AreEqual(obj.jenis_gajian, updatedObj.jenis_gajian); Assert.AreEqual(obj.gaji_lembur, updatedObj.gaji_lembur); Assert.AreEqual(obj.total_kasbon, updatedObj.total_kasbon); Assert.AreEqual(obj.total_pembayaran_kasbon, updatedObj.total_pembayaran_kasbon); }