public void Update(IBarangModel barangModel) { DataAccessStatus dataAccessStatus = new DataAccessStatus(); try { RecordExistsCheck((BarangModel)barangModel, TypeOfExistenceCheck.DoesExistInDB, RequestType.Update); } catch (DataAccessException ex) { ex.DataAccessStatusInfo.CustomMessage = "Barang tidak dapat diubah, dikarenakan data barang tidak ditemukan."; ex.DataAccessStatusInfo.ExceptionMessage = string.Copy(ex.Message); ex.DataAccessStatusInfo.StackTrace = string.Copy(ex.StackTrace); throw ex; } try { _context.Conn.Update((BarangModel)barangModel); } catch (SQLiteException ex) { dataAccessStatus.SetValues(status: "Error", operationSucceeded: false, exceptionMessage: ex.Message, customMessage: "Terjadi kesalahan saat menyimpan data Barang.", helpLink: ex.HelpLink, errorCode: ex.ErrorCode, stackTrace: ex.StackTrace); throw new DataAccessException(message: ex.Message, innerException: ex.InnerException, dataAccessStatus: dataAccessStatus); } }
public StokBarangEntryView(bool isNewData = true, int barangID = 0, IStokBarangModel model = null, IBarangModel barangModel = null) { InitializeComponent(); _isNewData = isNewData; _barangID = barangID; panelUp.LabelInfo = isNewData ? $"TAMBAH {_typeName.ToUpper()}" : $"UBAH {_typeName.ToUpper()}"; if (!_isNewData) { _model = model; textBoxStokAwal.IntegerValue = model.stok_awal; dateTimePickerTanggal.Value = model.tanggal; textBoxBarangMasuk.IntegerValue = model.barang_masuk; textBoxBarangKeluar.IntegerValue = model.barang_keluar; textBoxStokAkhir.IntegerValue = model.stok_akhir; textBoxStokAwal.ReadOnly = false; textBoxStokAkhir.ReadOnly = false; } else { if (barangModel != null) { textBoxStokAwal.IntegerValue = barangModel.stok_akhir; textBoxBarangMasuk.IntegerValue = 0; textBoxBarangKeluar.IntegerValue = 0; textBoxStokAkhir.IntegerValue = barangModel.stok_akhir; } } operationButtons.OnSaveButtonClick += OperationButtons_OnSaveButtonClick; }
public ReturnPenjualanEventArgs(IBarangModel barang, int qty, int status, string keterangan) { Barang = barang; Qty = qty; Status = status; Keterangan = keterangan; }
public BarangEntryView(bool isNewData = true, IBarangModel model = null) { InitializeComponent(); _isNewData = isNewData; panelUp.LabelInfo = isNewData ? $"TAMBAH {_typeName.ToUpper()}" : $"UBAH {_typeName.ToUpper()}"; if (!_isNewData) { _model = model; } operationButtons.OnSaveButtonClick += OperationButtons_OnSaveButtonClick; }
public void Add(IBarangModel barangModel) { DataAccessStatus dataAccessStatus = new DataAccessStatus(); var exists = _context.Conn.ExecuteScalar <bool>("SELECT COUNT(1) from barang where nama=@nama", new { barangModel.nama }); if (exists) { dataAccessStatus.Status = "Error"; dataAccessStatus.CustomMessage = "Nama barang sudah ada, silahkan ganti dengan nama yang lain."; throw new DataAccessException(dataAccessStatus);; } try { _context.Conn.Insert((BarangModel)barangModel); } catch (SQLiteException ex) { dataAccessStatus.SetValues(status: "Error", operationSucceeded: false, exceptionMessage: ex.Message, customMessage: "Terjadi kesalahan saat menambahkan data Barang.", helpLink: ex.HelpLink, errorCode: ex.ErrorCode, stackTrace: ex.StackTrace); throw new DataAccessException(message: ex.Message, innerException: ex.InnerException, dataAccessStatus: dataAccessStatus); } try { RecordExistsCheck(barangModel, TypeOfExistenceCheck.DoesExistInDB, RequestType.ConfirmAdd); } catch (DataAccessException ex) { ex.DataAccessStatusInfo.Status = "Error"; ex.DataAccessStatusInfo.OperationSucceeded = false; ex.DataAccessStatusInfo.CustomMessage = "Tidak dapat menemukan data barang di database setelah sukses menambahkan data."; ex.DataAccessStatusInfo.ExceptionMessage = string.Copy(ex.Message); ex.DataAccessStatusInfo.StackTrace = string.Copy(ex.StackTrace); throw ex; } }
private bool RecordExistsCheck(IBarangModel barangModel, TypeOfExistenceCheck typeOfExistenceCheck, RequestType requestType) { bool exists = false; bool recordExistsCheckPassed = true; DataAccessStatus dataAccessStatus = new DataAccessStatus(); try { if (requestType == RequestType.Add || requestType == RequestType.ConfirmAdd) { exists = _context.Conn.ExecuteScalar <bool>("SELECT COUNT(1) from barang where nama=@nama", new { barangModel.nama }); } else if (requestType == RequestType.Update || requestType == RequestType.ConfirmDelete || requestType == RequestType.Delete) { exists = _context.Conn.ExecuteScalar <bool>("SELECT COUNT(1) from barang where id=@id", new { barangModel.id }); } } catch (SQLiteException ex) { throw ex; } if ((typeOfExistenceCheck == TypeOfExistenceCheck.DoesExistInDB) && !exists) { dataAccessStatus.Status = "Error"; recordExistsCheckPassed = false; throw new DataAccessException(dataAccessStatus); } else if ((typeOfExistenceCheck == TypeOfExistenceCheck.DoesNotExistInDB) && exists) { dataAccessStatus.Status = "Error"; recordExistsCheckPassed = false; throw new DataAccessException(dataAccessStatus); } return(recordExistsCheckPassed); }
public void ValidateModel(IBarangModel model) { _modelDAC.ValidateModel(model); }
public void Delete(IBarangModel model) { _repo.Delete(model); }
public void Update(IBarangModel model) { ValidateModel(model); _repo.Update(model); }
public void Insert(IBarangModel model) { ValidateModel(model); _repo.Insert(model); }
public void ValidateModelDataAnnotations(IBarangModel barangModel) { _modelDataAnnotationCheck.ValidateModel(barangModel); }
public void Delete(IBarangModel barangModel) { _barangRepository.Delete(barangModel); }
public void Update(IBarangModel barangModel) { _barangRepository.Update(barangModel); }
public void Add(IBarangModel barangModel) { _barangRepository.Add(barangModel); }
public BarangServicesFixture() { _barangModel = new BarangModel(); _barangService = new BarangServices(null, new ModelDataAnnotationCheck()); }