예제 #1
0
        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();
                }
            }
        }
예제 #2
0
        public void SaveTest()
        {
            var obj = new Karyawan
            {
                jabatan_id    = "120d3472-ea93-4e29-8abd-5bd7044d26db",
                nama_karyawan = "Doni",
                alamat        = "Yogyakarta",
                telepon       = "",
                gaji_pokok    = 100000,
                is_active     = true,
                jenis_gajian  = JenisGajian.Mingguan,
                gaji_lembur   = 50000
            };

            var validationError = new ValidationError();

            var result = _bll.Save(obj, ref validationError);

            Console.WriteLine("Error : " + validationError.Message);

            Assert.IsTrue(result != 0);

            var newObj = _bll.GetByID(obj.karyawan_id);

            Assert.IsNotNull(newObj);
            Assert.AreEqual(obj.karyawan_id, newObj.karyawan_id);
            Assert.AreEqual(obj.jabatan_id, newObj.jabatan_id);
            Assert.AreEqual(obj.nama_karyawan, newObj.nama_karyawan);
            Assert.AreEqual(obj.alamat, newObj.alamat);
            Assert.AreEqual(obj.telepon, newObj.telepon);
            Assert.AreEqual(obj.gaji_pokok, newObj.gaji_pokok);
            Assert.AreEqual(obj.is_active, newObj.is_active);
            Assert.AreEqual(obj.keterangan, newObj.keterangan);
            Assert.AreEqual(obj.jenis_gajian, newObj.jenis_gajian);
            Assert.AreEqual(obj.gaji_lembur, newObj.gaji_lembur);
        }