コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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;
        }
コード例 #3
0
 public ReturnPenjualanEventArgs(IBarangModel barang, int qty, int status, string keterangan)
 {
     Barang     = barang;
     Qty        = qty;
     Status     = status;
     Keterangan = keterangan;
 }
コード例 #4
0
        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;
        }
コード例 #5
0
        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;
            }
        }
コード例 #6
0
        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);
        }
コード例 #7
0
 public void ValidateModel(IBarangModel model)
 {
     _modelDAC.ValidateModel(model);
 }
コード例 #8
0
 public void Delete(IBarangModel model)
 {
     _repo.Delete(model);
 }
コード例 #9
0
 public void Update(IBarangModel model)
 {
     ValidateModel(model);
     _repo.Update(model);
 }
コード例 #10
0
 public void Insert(IBarangModel model)
 {
     ValidateModel(model);
     _repo.Insert(model);
 }
コード例 #11
0
ファイル: BarangServices.cs プロジェクト: izhal27/demo_MVP
 public void ValidateModelDataAnnotations(IBarangModel barangModel)
 {
     _modelDataAnnotationCheck.ValidateModel(barangModel);
 }
コード例 #12
0
ファイル: BarangServices.cs プロジェクト: izhal27/demo_MVP
 public void Delete(IBarangModel barangModel)
 {
     _barangRepository.Delete(barangModel);
 }
コード例 #13
0
ファイル: BarangServices.cs プロジェクト: izhal27/demo_MVP
 public void Update(IBarangModel barangModel)
 {
     _barangRepository.Update(barangModel);
 }
コード例 #14
0
ファイル: BarangServices.cs プロジェクト: izhal27/demo_MVP
 public void Add(IBarangModel barangModel)
 {
     _barangRepository.Add(barangModel);
 }
コード例 #15
0
 public BarangServicesFixture()
 {
     _barangModel   = new BarangModel();
     _barangService = new BarangServices(null, new ModelDataAnnotationCheck());
 }