Exemplo n.º 1
0
        public void SaveTest()
        {
            var obj = new PembayaranKasbon
            {
                kasbon_id        = "d6ba5c9e-b0ba-40ba-9dc8-f631fc499aab",
                gaji_karyawan_id = null,
                tanggal          = new DateTime(2017, 4, 15),
                nominal          = 50000,
                keterangan       = "cicilan ke #3",
                nota             = _bll.GetLastNota(),
                pengguna_id      = "00b5acfa-b533-454b-8dfd-e7881edd180f"
            };

            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.pembayaran_kasbon_id);

            Assert.IsNotNull(newObj);
            Assert.AreEqual(obj.pembayaran_kasbon_id, newObj.pembayaran_kasbon_id);
            Assert.AreEqual(obj.kasbon_id, newObj.kasbon_id);
            Assert.AreEqual(obj.gaji_karyawan_id, newObj.gaji_karyawan_id);
            Assert.AreEqual(obj.tanggal, newObj.tanggal);
            Assert.AreEqual(obj.nominal, newObj.nominal);
            Assert.AreEqual(obj.keterangan, newObj.keterangan);
            Assert.AreEqual(obj.nota, newObj.nota);
            Assert.AreEqual(obj.pengguna_id, newObj.pengguna_id);
        }
        public int Save(PembayaranKasbon obj)
        {
            var result = 0;

            try
            {
                if (obj.pembayaran_kasbon_id == null)
                {
                    obj.pembayaran_kasbon_id = _context.GetGUID();
                }

                _context.db.Insert <PembayaranKasbon>(obj);

                LogicalThreadContext.Properties["NewValue"] = obj.ToJson();
                _log.Info("Tambah data");

                result = 1;
            }
            catch (Exception ex)
            {
                _log.Error("Error:", ex);
            }

            return(result);
        }
Exemplo n.º 3
0
        public PembayaranKasbon GetByID(string id)
        {
            PembayaranKasbon obj = null;

            using (IDapperContext context = new DapperContext())
            {
                IUnitOfWork uow = new UnitOfWork(context, _log);
                obj = uow.PembayaranKasbonRepository.GetByID(id);
            }

            return(obj);
        }
Exemplo n.º 4
0
        public int Delete(PembayaranKasbon obj)
        {
            var result = 0;

            using (IDapperContext context = new DapperContext())
            {
                IUnitOfWork uow = new UnitOfWork(context, _log);
                result = uow.PembayaranKasbonRepository.Delete(obj);
            }

            return(result);
        }
Exemplo n.º 5
0
        public void DeleteTest()
        {
            var obj = new PembayaranKasbon
            {
                pembayaran_kasbon_id = "4e646d45-b733-4961-aceb-f53be8e7b242"
            };

            var result = _bll.Delete(obj);

            Assert.IsTrue(result != 0);

            var deletedObj = _bll.GetByID(obj.pembayaran_kasbon_id);

            Assert.IsNull(deletedObj);
        }
        public PembayaranKasbon GetByID(string id)
        {
            PembayaranKasbon obj = null;

            try
            {
                obj = _context.db.Get <PembayaranKasbon>(id);
            }
            catch (Exception ex)
            {
                _log.Error("Error:", ex);
            }

            return(obj);
        }
        protected override void Simpan()
        {
            if (_isNewData)
            {
                _pembayaranKasbon = new PembayaranKasbon();
            }

            _pembayaranKasbon.kasbon_id = this._kasbon.kasbon_id;
            _pembayaranKasbon.Kasbon    = this._kasbon;

            _pembayaranKasbon.pengguna_id = this._pengguna.pengguna_id;
            _pembayaranKasbon.Pengguna    = this._pengguna;

            _pembayaranKasbon.nota        = txtNota.Text;
            _pembayaranKasbon.tanggal     = dtpTanggal.Value;
            _pembayaranKasbon.nominal     = NumberHelper.StringToDouble(txtJumlah.Text);
            _pembayaranKasbon.sisa_kasbon = NumberHelper.StringToDouble(txtSisaKasbon.Text);
            _pembayaranKasbon.keterangan  = txtKeterangan.Text;

            var result          = 0;
            var validationError = new ValidationError();

            using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0)))
            {
                if (_isNewData)
                {
                    result = _bll.Save(_pembayaranKasbon, ref validationError);
                }
                else
                {
                    result = _bll.Update(_pembayaranKasbon, ref validationError);
                }

                if (result > 0)
                {
                    Listener.Ok(this, _isNewData, _pembayaranKasbon);
                    this.Close();
                }
                else
                {
                    if (validationError.Message.NullToString().Length > 0)
                    {
                        MsgHelper.MsgWarning(validationError.Message);
                        base.SetFocusObject(validationError.PropertyName, this);
                    }
                }
            }
        }
Exemplo n.º 8
0
        public int Update(PembayaranKasbon obj, ref ValidationError validationError)
        {
            var validatorResults = _validator.Validate(obj);

            if (!validatorResults.IsValid)
            {
                foreach (var failure in validatorResults.Errors)
                {
                    validationError.Message      = failure.ErrorMessage;
                    validationError.PropertyName = failure.PropertyName;
                    return(0);
                }
            }

            return(Update(obj));
        }
        public int Delete(PembayaranKasbon obj)
        {
            var result = 0;

            try
            {
                var api      = "delete";
                var response = RestSharpHelper <OpenRetailWebApiPostResponse> .PostRequest(_apiUrl, api, obj);

                result = Convert.ToInt32(response.Results);
            }
            catch (Exception ex)
            {
                _log.Error("Error:", ex);
            }

            return(result);
        }
        public PembayaranKasbon GetByID(string id)
        {
            PembayaranKasbon obj = null;

            try
            {
                obj = _context.db.Get <PembayaranKasbon>(id);
                if (obj != null)
                {
                    obj.entity_state = EntityState.Unchanged;
                }
            }
            catch (Exception ex)
            {
                _log.Error("Error:", ex);
            }

            return(obj);
        }
Exemplo n.º 11
0
        public int Delete(PembayaranKasbon obj)
        {
            var result = 0;

            if (_isUseWebAPI)
            {
                _unitOfWork = new UnitOfWork(_isUseWebAPI, _baseUrl, _log);
                result      = _unitOfWork.PembayaranKasbonRepository.Delete(obj);
            }
            else
            {
                using (IDapperContext context = new DapperContext())
                {
                    _unitOfWork = new UnitOfWork(context, _log);
                    result      = _unitOfWork.PembayaranKasbonRepository.Delete(obj);
                }
            }

            return(result);
        }
Exemplo n.º 12
0
        public PembayaranKasbon GetByID(string id)
        {
            PembayaranKasbon obj = null;

            if (_isUseWebAPI)
            {
                _unitOfWork = new UnitOfWork(_isUseWebAPI, _baseUrl, _log);
                obj         = _unitOfWork.PembayaranKasbonRepository.GetByID(id);
            }
            else
            {
                using (IDapperContext context = new DapperContext())
                {
                    _unitOfWork = new UnitOfWork(context, _log);
                    obj         = _unitOfWork.PembayaranKasbonRepository.GetByID(id);
                }
            }

            return(obj);
        }
        public PembayaranKasbon GetByID(string id)
        {
            PembayaranKasbon obj = null;

            try
            {
                var api      = string.Format("get_by_id?id={0}", id);
                var response = RestSharpHelper <OpenRetailWebApiGetResponse <PembayaranKasbon> > .GetRequest(_apiUrl, api).Data;

                if (response.Results.Count > 0)
                {
                    obj = response.Results[0];
                }
            }
            catch (Exception ex)
            {
                _log.Error("Error:", ex);
            }

            return(obj);
        }
        public int Delete(PembayaranKasbon obj)
        {
            var result = 0;

            try
            {
                result = _context.db.Delete <PembayaranKasbon>(obj) ? 1 : 0;

                if (result > 0)
                {
                    LogicalThreadContext.Properties["OldValue"] = obj.ToJson();
                    _log.Info("Hapus data");
                }
            }
            catch (Exception ex)
            {
                _log.Error("Error:", ex);
            }

            return(result);
        }
        public FrmEntryPembayaranKasbon(string header, Kasbon kasbon, PembayaranKasbon pembayaranKasbon)
            : base()
        {
            InitializeComponent();
            ColorManagerHelper.SetTheme(this, this);

            base.SetHeader(header);
            base.SetButtonSelesaiToBatal();

            this._log              = MainProgram.log;
            this._bll              = new PembayaranKasbonBll(MainProgram.isUseWebAPI, MainProgram.baseUrl, _log);
            this._kasbon           = kasbon;
            this._pembayaranKasbon = pembayaranKasbon;
            this._pengguna         = MainProgram.pengguna;

            txtNota.Text         = this._pembayaranKasbon.nota;
            dtpTanggal.Value     = (DateTime)this._pembayaranKasbon.tanggal;
            txtNamaKaryawan.Text = this._kasbon.Karyawan.nama_karyawan;
            txtSisaKasbon.Text   = this._kasbon.sisa.ToString();
            txtKeterangan.Text   = this._pembayaranKasbon.keterangan;
            txtJumlah.Text       = this._pembayaranKasbon.nominal.ToString();
        }
Exemplo n.º 16
0
        public int Save(PembayaranKasbon obj)
        {
            var result = 0;

            if (_isUseWebAPI)
            {
                obj.pembayaran_kasbon_id = Guid.NewGuid().ToString();

                _unitOfWork = new UnitOfWork(_isUseWebAPI, _baseUrl, _log);
                result      = _unitOfWork.PembayaranKasbonRepository.Save(obj);
            }
            else
            {
                using (IDapperContext context = new DapperContext())
                {
                    _unitOfWork = new UnitOfWork(context, _log);
                    result      = _unitOfWork.PembayaranKasbonRepository.Save(obj);
                }
            }

            return(result);
        }
Exemplo n.º 17
0
        public void SaveTest()
        {
            var obj = new GajiKaryawan
            {
                karyawan_id = "72f28a4f-f364-423a-a09b-2b9571543fde",
                pengguna_id = "00b5acfa-b533-454b-8dfd-e7881edd180f",
                tanggal     = DateTime.Today,
                nota        = _bll.GetLastNota(),
                bulan       = 3,
                tahun       = 2017,
                kehadiran   = 24,
                absen       = 1,
                gaji_pokok  = 3000000,
                lembur      = 0,
                bonus       = 0,
                potongan    = 0,
                jam         = 1,
                keterangan  = "tesss",
                jumlah_hari = 6,
                tunjangan   = 0
            };

            // item pembayaran kasbon
            var listOfPembayaranKasbon = new List <PembayaranKasbon>();

            var pembayaranKasbon1 = new PembayaranKasbon
            {
                kasbon_id = "d6ba5c9e-b0ba-40ba-9dc8-f631fc499aab",
                Kasbon    = new Kasbon {
                    kasbon_id = "d6ba5c9e-b0ba-40ba-9dc8-f631fc499aab"
                },
                nominal    = 600000,
                keterangan = "Pembayaran dari gaji"
            };

            var pembayaranKasbon2 = new PembayaranKasbon
            {
                kasbon_id = "89a3fbb2-441c-4043-b858-755e112cd997",
                Kasbon    = new Kasbon {
                    kasbon_id = "89a3fbb2-441c-4043-b858-755e112cd997"
                },
                nominal    = 100000,
                keterangan = "Pembayaran dari gaji"
            };

            listOfPembayaranKasbon.Add(pembayaranKasbon1);
            listOfPembayaranKasbon.Add(pembayaranKasbon2);
            obj.item_pembayaran_kasbon = listOfPembayaranKasbon;

            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.gaji_karyawan_id);

            Assert.IsNotNull(newObj);
            Assert.AreEqual(obj.gaji_karyawan_id, newObj.gaji_karyawan_id);
            Assert.AreEqual(obj.karyawan_id, newObj.karyawan_id);
            Assert.AreEqual(obj.pengguna_id, newObj.pengguna_id);
            Assert.AreEqual(obj.tanggal, newObj.tanggal);
            Assert.AreEqual(obj.nota, newObj.nota);
            Assert.AreEqual(obj.bulan, newObj.bulan);
            Assert.AreEqual(obj.tahun, newObj.tahun);
            Assert.AreEqual(obj.kehadiran, newObj.kehadiran);
            Assert.AreEqual(obj.absen, newObj.absen);
            Assert.AreEqual(obj.gaji_pokok, newObj.gaji_pokok);
            Assert.AreEqual(obj.lembur, newObj.lembur);
            Assert.AreEqual(obj.bonus, newObj.bonus);
            Assert.AreEqual(obj.potongan, newObj.potongan);
            Assert.AreEqual(obj.jam, newObj.jam);
            Assert.AreEqual(obj.lainnya, newObj.lainnya);
            Assert.AreEqual(obj.keterangan, newObj.keterangan);
            Assert.AreEqual(obj.jumlah_hari, newObj.jumlah_hari);
            Assert.AreEqual(obj.tunjangan, newObj.tunjangan);
        }