public int Save(Kasbon obj) { var result = 0; try { if (obj.kasbon_id == null) { obj.kasbon_id = _context.GetGUID(); } _context.db.Insert <Kasbon>(obj); LogicalThreadContext.Properties["NewValue"] = obj.ToJson(); _log.Info("Tambah data"); result = 1; } catch (Exception ex) { _log.Error("Error:", ex); } return(result); }
public void SaveTest() { var obj = new Kasbon { karyawan_id = "d3506b64-df74-4283-b17a-6c5dbb770e85", pengguna_id = "00b5acfa-b533-454b-8dfd-e7881edd180f", nota = _bll.GetLastNota(), tanggal = DateTime.Today, nominal = 10000, keterangan = "tessss" }; 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.kasbon_id); Assert.IsNotNull(newObj); Assert.AreEqual(obj.kasbon_id, newObj.kasbon_id); Assert.AreEqual(obj.karyawan_id, newObj.karyawan_id); Assert.AreEqual(obj.nota, newObj.nota); Assert.AreEqual(obj.tanggal, newObj.tanggal); Assert.AreEqual(obj.nominal, newObj.nominal); Assert.AreEqual(obj.keterangan, newObj.keterangan); }
protected override void Simpan() { if (_isNewData) { _kasbon = new Kasbon(); } if (cmbKaryawan.SelectedIndex == 0) { MsgHelper.MsgWarning("Karyawan belum dipilih"); return; } _kasbon.nota = txtNota.Text; _kasbon.tanggal = dtpTanggal.Value; _kasbon.nominal = NumberHelper.StringToDouble(txtJumlah.Text); _kasbon.keterangan = txtKeterangan.Text; var karyawan = _listOfKaryawan[cmbKaryawan.SelectedIndex - 1]; _kasbon.karyawan_id = karyawan.karyawan_id; _kasbon.Karyawan = karyawan; _kasbon.pengguna_id = this._pengguna.pengguna_id; _kasbon.Pengguna = this._pengguna; var result = 0; var validationError = new ValidationError(); using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0))) { if (_isNewData) { result = _bll.Save(_kasbon, ref validationError); } else { result = _bll.Update(_kasbon, ref validationError); } if (result > 0) { Listener.Ok(this, _isNewData, _kasbon); this.Close(); } else { if (validationError.Message.NullToString().Length > 0) { MsgHelper.MsgWarning(validationError.Message); base.SetFocusObject(validationError.PropertyName, this); } } } }
public int Delete(Kasbon obj) { var result = 0; using (IDapperContext context = new DapperContext()) { IUnitOfWork uow = new UnitOfWork(context, _log); result = uow.KasbonRepository.Delete(obj); } return(result); }
public Kasbon GetByID(string id) { Kasbon obj = null; using (IDapperContext context = new DapperContext()) { IUnitOfWork uow = new UnitOfWork(context, _log); obj = uow.KasbonRepository.GetByID(id); } return(obj); }
public void DeleteTest() { var obj = new Kasbon { kasbon_id = "034f800f-5dd6-4173-82cf-88f3879aedb9" }; var result = _bll.Delete(obj); Assert.IsTrue(result != 0); var deletedObj = _bll.GetByID(obj.kasbon_id); Assert.IsNull(deletedObj); }
public int Update(Kasbon 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 Kasbon GetByID(string id) { Kasbon obj = null; try { _sql = SQL_TEMPLATE.Replace("{WHERE}", "WHERE t_kasbon.kasbon_id = @id"); _sql = _sql.Replace("{ORDER BY}", ""); obj = MappingRecordToObject(_sql, new { id }).SingleOrDefault(); } catch (Exception ex) { _log.Error("Error:", ex); } return(obj); }
public int Delete(Kasbon 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 FrmEntryPembayaranKasbon(string header, Kasbon kasbon) : base() { InitializeComponent(); ColorManagerHelper.SetTheme(this, this); base.SetHeader(header); this._log = MainProgram.log; this._bll = new PembayaranKasbonBll(MainProgram.isUseWebAPI, MainProgram.baseUrl, _log); this._kasbon = kasbon; this._pengguna = MainProgram.pengguna; this._isNewData = true; txtNota.Text = this._bll.GetLastNota(); txtNamaKaryawan.Text = this._kasbon.Karyawan.nama_karyawan; txtSisaKasbon.Text = this._kasbon.sisa.ToString(); }
public int Delete(Kasbon obj) { var result = 0; if (_isUseWebAPI) { _unitOfWork = new UnitOfWork(_isUseWebAPI, _baseUrl, _log); result = _unitOfWork.KasbonRepository.Delete(obj); } else { using (IDapperContext context = new DapperContext()) { _unitOfWork = new UnitOfWork(context, _log); result = _unitOfWork.KasbonRepository.Delete(obj); } } return(result); }
public Kasbon GetByID(string id) { Kasbon obj = null; if (_isUseWebAPI) { _unitOfWork = new UnitOfWork(_isUseWebAPI, _baseUrl, _log); obj = _unitOfWork.KasbonRepository.GetByID(id); } else { using (IDapperContext context = new DapperContext()) { _unitOfWork = new UnitOfWork(context, _log); obj = _unitOfWork.KasbonRepository.GetByID(id); } } return(obj); }
public int Delete(Kasbon obj) { var result = 0; try { result = _context.db.Delete <Kasbon>(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 Kasbon GetByID(string id) { Kasbon obj = null; try { var api = string.Format("get_by_id?id={0}", id); var response = RestSharpHelper <OpenRetailWebApiGetResponse <Kasbon> > .GetRequest(_apiUrl, api).Data; if (response.Results.Count > 0) { obj = response.Results[0]; } } catch (Exception ex) { _log.Error("Error:", ex); } return(obj); }
public int Save(Kasbon obj) { var result = 0; if (_isUseWebAPI) { obj.kasbon_id = Guid.NewGuid().ToString(); _unitOfWork = new UnitOfWork(_isUseWebAPI, _baseUrl, _log); result = _unitOfWork.KasbonRepository.Save(obj); } else { using (IDapperContext context = new DapperContext()) { _unitOfWork = new UnitOfWork(context, _log); result = _unitOfWork.KasbonRepository.Save(obj); } } 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(); }
public FrmEntryKasbon(string header, Kasbon kasbon, IList <Karyawan> listOfKaryawan, IKasbonBll bll) : base() { InitializeComponent(); ColorManagerHelper.SetTheme(this, this); base.SetHeader(header); base.SetButtonSelesaiToBatal(); this._listOfKaryawan = listOfKaryawan; this._bll = bll; this._pengguna = MainProgram.pengguna; this._kasbon = kasbon; txtNota.Text = this._kasbon.nota; dtpTanggal.Value = (DateTime)this._kasbon.tanggal; txtKeterangan.Text = this._kasbon.keterangan; txtJumlah.Text = this._kasbon.nominal.ToString(); LoadDataKaryawan(); if (this._kasbon.Karyawan != null) { cmbKaryawan.SelectedItem = this._kasbon.Karyawan.nama_karyawan; } }