private void lookUpSparepart_EditValueChanged(object sender, EventArgs e)
        {
            SparepartViewModel sparepart = lookUpSparepart.GetSelectedDataRow() as SparepartViewModel;

            this.Code = sparepart.Code;
            this.Unit = sparepart.UnitReference.Name;
        }
        public void DeleteSparepart(SparepartViewModel sparepart, int userId)
        {
            DateTime serverTime = DateTime.Now;
            List <SpecialSparepartDetail> details = _specialSparepartDetailRepository.GetMany(spd => spd.SparepartId == sparepart.Id).ToList();

            foreach (var iDetails in details)
            {
                iDetails.Status       = (int)DbConstant.DefaultDataStatus.Deleted;
                iDetails.ModifyDate   = serverTime;
                iDetails.ModifyUserId = userId;
                _specialSparepartDetailRepository.AttachNavigation(iDetails.CreateUser);
                _specialSparepartDetailRepository.AttachNavigation(iDetails.ModifyUser);
                _specialSparepartDetailRepository.AttachNavigation(iDetails.PurchasingDetail);
                _specialSparepartDetailRepository.AttachNavigation(iDetails.Sparepart);
                _specialSparepartDetailRepository.AttachNavigation(iDetails.SparepartManualTransaction);
                _specialSparepartDetailRepository.Update(iDetails);
            }

            sparepart.Status       = (int)DbConstant.DefaultDataStatus.Deleted;
            sparepart.ModifyDate   = serverTime;
            sparepart.ModifyUserId = userId;
            Sparepart entity = _sparepartRepository.GetById(sparepart.Id);

            Map(sparepart, entity);
            _sparepartRepository.AttachNavigation(entity.CreateUser);
            _sparepartRepository.AttachNavigation(entity.ModifyUser);
            _sparepartRepository.AttachNavigation(entity.CategoryReference);
            _sparepartRepository.AttachNavigation(entity.UnitReference);
            _sparepartRepository.Update(entity);

            _unitOfWork.SaveChanges();
        }
        private void btnConfirmChange_Click(object sender, EventArgs e)
        {
            if (this.SelectedVehicleWheel != null)
            {
                if (this.SelectedVehicleWheel.ReplaceWithWheelDetailId > 0)
                {
                    SpecialSparepartDetailViewModel vw = _wheelDetailChanged.Where(wdc => wdc.Id == this.SelectedVehicleWheel.ReplaceWithWheelDetailId).FirstOrDefault();

                    if (vw != null)
                    {
                        _wheelDetailChanged.Remove(vw);
                    }
                }

                SparepartViewModel sparepartWheel           = lookUpChangedWheel.GetSelectedDataRow() as SparepartViewModel;
                SpecialSparepartDetailViewModel wheelDetail = lookUpChangedSerialNumber.GetSelectedDataRow() as SpecialSparepartDetailViewModel;
                if (sparepartWheel != null && wheelDetail != null)
                {
                    this.SelectedVehicleWheel.ReplaceWithWheelDetailName = sparepartWheel.Name;
                    this.SelectedVehicleWheel.SparepartId = sparepartWheel.Id;
                    this.SelectedVehicleWheel.ReplaceWithWheelDetailId           = wheelDetail.Id;
                    this.SelectedVehicleWheel.ReplaceWithWheelDetailSerialNumber = wheelDetail.SerialNumber;
                    this.SelectedVehicleWheel.IsUsedWheelRetrieved = ckeUsedGoodRetrieved.Checked;
                    this.SelectedVehicleWheel.Price = this.Price;

                    _wheelDetailChanged.Add(wheelDetail);
                }
            }

            gvVehicleWheel.RefreshData();
        }
Esempio n. 4
0
 public override void RefreshDataView()
 {
     if (!bgwMain.IsBusy)
     {
         MethodBase.GetCurrentMethod().Info("Fecthing sparepart data...");
         _selectedSparepart = null;
         FormHelpers.CurrentMainForm.UpdateStatusInformation("Memuat data sparepart...", false);
         bgwMain.RunWorkerAsync();
     }
 }
Esempio n. 5
0
        private void bgwMain_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Result is Exception)
            {
                this.ShowError("Proses memuat data gagal!");
            }

            if (gvSparepart.RowCount > 0)
            {
                SelectedSparepart = gvSparepart.GetRow(0) as SparepartViewModel;
            }

            FormHelpers.CurrentMainForm.UpdateStatusInformation("Memuat data sparepart selesai", true);
        }
Esempio n. 6
0
        public void UpdateSparepart(SparepartViewModel sparepart, int userId)
        {
            DateTime serverTime = DateTime.Now;

            sparepart.ModifyDate   = serverTime;
            sparepart.ModifyUserId = userId;
            Sparepart entity = _sparepartRepository.GetById(sparepart.Id);

            Map(sparepart, entity);
            _sparepartRepository.AttachNavigation(entity.CreateUser);
            _sparepartRepository.AttachNavigation(entity.ModifyUser);
            _sparepartRepository.AttachNavigation(entity.CategoryReference);
            _sparepartRepository.AttachNavigation(entity.UnitReference);
            _sparepartRepository.Update(entity);
            _unitOfWork.SaveChanges();
        }
Esempio n. 7
0
        public void InsertSparepart(SparepartViewModel sparepart, int userId)
        {
            DateTime serverTime = DateTime.Now;

            sparepart.CreateDate   = serverTime;
            sparepart.CreateUserId = userId;
            sparepart.ModifyDate   = serverTime;
            sparepart.ModifyUserId = userId;
            sparepart.Status       = (int)DbConstant.DefaultDataStatus.Active;
            Sparepart entity = new Sparepart();

            Map(sparepart, entity);
            _sparepartRepository.AttachNavigation(entity.CreateUser);
            _sparepartRepository.AttachNavigation(entity.ModifyUser);
            _sparepartRepository.AttachNavigation(entity.CategoryReference);
            _sparepartRepository.AttachNavigation(entity.UnitReference);
            _sparepartRepository.Add(entity);
            _unitOfWork.SaveChanges();
        }
        private void lookUpSparepart_EditValueChanged(object sender, EventArgs e)
        {
            if (this.SparepartId > 0)
            {
                //check if special sparepart

                LookUpEdit         lookup    = (LookUpEdit)sender;
                SparepartViewModel sparepart = (SparepartViewModel)lookup.GetSelectedDataRow();

                if (sparepart.IsSpecialSparepart)
                {
                    lookUpSerialNumber.Enabled = true;
                    txtQty.Text    = "1";
                    txtQty.Enabled = false;

                    _presenter.LoadSSDetails(sparepart.Id);
                }
                else
                {
                    lookUpSerialNumber.Enabled = false;
                    txtQty.Text    = "0";
                    txtQty.Enabled = true;
                }

                //check if used good
                ckeIsReturnRequired.Enabled = _presenter.IsUsedSparepartRequired();
                ckeIsReturnRequired.Checked = false;

                //get last usage info
                _presenter.GetLastUsageRecord();
                if (this.LastUsageRecord != null)
                {
                    lblValLastUsageDate.Text = this.LastUsageRecord.CreateDate.ToShortDateString();
                    lblValLastUsageQty.Text  = this.LastUsageRecord.TotalQuantity.ToString();
                }
                else
                {
                    lblValLastUsageDate.Text = "--";
                    lblValLastUsageQty.Text  = "--";
                }
            }
        }
 private void GvStockCard_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
 {
     SelectedSparepart = (gvStockCard.GetFocusedRow() as GroupSparepartStockCardViewModel).Sparepart;
 }