public ViewResult VehicleGroupDetail(int id) { var service = this.Service <IVehicleGroupService>(); var vehicleService = this.Service <IVehicleService>(); var vehicleGroup = service.Get(id); if (vehicleGroup == null) { return(View("~/Areas/Provider/Views/VehicleGroupManagement/VehicleGroupDetail.cshtml")); } VehicleGroupViewModel viewModel = this.Mapper.Map <VehicleGroupViewModel> (vehicleGroup); var providerID = User.Identity.GetUserId(); viewModel.listVehicle = vehicleService.Get() .Where(q => q.Garage.OwnerID == providerID && q.VehicleGroupID != id && !q.IsDeleted) .Select(q => new SelectListItem() { Text = q.Name + " [Biển số: " + q.LicenseNumber + "]" + "[Nhóm: " + (q.VehicleGroupID != null ? q.VehicleGroup.Name : "-chưa có nhóm-") + "]", Value = q.ID.ToString(), Selected = false, }); viewModel.listGroup = service.Get() .Where(q => q.OwnerID == providerID && q.ID != id) .Select(q => new SelectListItem() { Text = q.Name, Value = q.ID.ToString(), Selected = false, }); return(View("~/Areas/Provider/Views/VehicleGroupManagement/VehicleGroupDetail.cshtml", viewModel)); }
public override void RefreshDataView() { if (!bgwMain.IsBusy) { MethodBase.GetCurrentMethod().Info("Fecthing vehicle group data..."); this.SelectedGroup = null; FormHelpers.CurrentMainForm.UpdateStatusInformation("Memuat data kelompok...", false); bgwMain.RunWorkerAsync(); } }
private void bgwMain_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Result is Exception) { this.ShowError("Proses memuat data gagal!"); } if (gvVehicleGroup.RowCount > 0) { SelectedGroup = gvVehicleGroup.GetRow(0) as VehicleGroupViewModel; } FormHelpers.CurrentMainForm.UpdateStatusInformation("Memuat data customer selesai", true); }
public void UpdateGroup(VehicleGroupViewModel vehicleGroup, int userId) { using (var trans = _unitOfWork.BeginTransaction()) { try { // insert new group VehicleGroup entity = new VehicleGroup(); Map(vehicleGroup, entity); _vehicleGroupRepository.AttachNavigation <Customer>(entity.Customer); entity.Id = 0; entity.CreateUserId = entity.ModifyUserId = userId; entity.CreateDate = entity.ModifyDate = DateTime.Now; entity.ModifyUserId = entity.ModifyUserId = userId; entity.ModifyDate = entity.ModifyDate = DateTime.Now; entity.Status = (int)DbConstant.DefaultDataStatus.Active; VehicleGroup insertedVehicleGroup = _vehicleGroupRepository.Add(entity); _unitOfWork.SaveChanges(); // update last group status to deleted _vehicleGroupRepository.AttachNavigation <Customer>(entity.Customer); entity = _vehicleGroupRepository.GetById(vehicleGroup.Id); entity.Status = (int)DbConstant.DefaultDataStatus.Deleted; _vehicleGroupRepository.Update(entity); _unitOfWork.SaveChanges(); //update all vehicle to new group foreach (var vehicle in _vehicleRepository.GetMany(v => v.VehicleGroupId == vehicleGroup.Id && v.Status == (int)DbConstant.DefaultDataStatus.Active)) { _vehicleRepository.AttachNavigation <Customer>(vehicle.Customer); _vehicleRepository.AttachNavigation <Brand>(vehicle.Brand); _vehicleRepository.AttachNavigation <BrawijayaWorkshop.Database.Entities.Type>(vehicle.Type); _vehicleRepository.AttachNavigation <VehicleGroup>(vehicle.VehicleGroup); vehicle.VehicleGroup = insertedVehicleGroup; vehicle.ModifyUserId = entity.ModifyUserId = userId; vehicle.ModifyDate = entity.ModifyDate = DateTime.Now; _vehicleRepository.Update(vehicle); _unitOfWork.SaveChanges(); } trans.Commit(); } catch (System.Exception ex) { trans.Rollback(); throw ex; } } }
public void InsertNewGroup(VehicleGroupViewModel vehicleGroup, int userId) { using (var trans = _unitOfWork.BeginTransaction()) { try { VehicleGroup entity = new VehicleGroup(); Map(vehicleGroup, entity); _vehicleGroupRepository.AttachNavigation <Customer>(entity.Customer); entity.CreateUserId = entity.ModifyUserId = userId; entity.CreateDate = entity.ModifyDate = DateTime.Now; entity.Status = (int)DbConstant.DefaultDataStatus.Active; _vehicleGroupRepository.Add(entity); _unitOfWork.SaveChanges(); trans.Commit(); } catch (System.Exception ex) { trans.Rollback(); throw ex; } } }
public void DeleteVehicleGroup(VehicleGroupViewModel selectedGroup, int userId) { using (var trans = _unitOfWork.BeginTransaction()) { try { VehicleGroup entity = _vehicleGroupRepository.GetById(selectedGroup.Id); Map(selectedGroup, entity); _vehicleGroupRepository.AttachNavigation <Customer>(entity.Customer); entity.Status = (int)BrawijayaWorkshop.Constant.DbConstant.DefaultDataStatus.Deleted; entity.ModifyUserId = userId; entity.ModifyDate = DateTime.Now; _vehicleGroupRepository.Update(entity); _unitOfWork.SaveChanges(); trans.Commit(); } catch (System.Exception ex) { trans.Rollback(); throw ex; } } }
private void btnPrintAll_Click(object sender, EventArgs e) { if (ListInvoices == null || ListInvoices.Count == 0) { this.ShowInformation("Data Invoice tidak ada"); return; } try { ReferenceViewModel category = lookupCategory.GetSelectedDataRow() as ReferenceViewModel; VehicleGroupViewModel vehicleGroup = lookupVehicleGroup.GetSelectedDataRow() as VehicleGroupViewModel; List <RecapInvoiceBySPKItemViewModel> reportDataSource = new List <RecapInvoiceBySPKItemViewModel>(); foreach (var item in this.ListInvoices) { if (item.ItemName == "Gaji Tukang Harian" || item.ItemName == "Gaji Tukang Borongan") { RecapInvoiceBySPKItemViewModel itemWorker = reportDataSource.Where(ds => ds.Category == category.Name && ds.VehicleGroup == vehicleGroup.Name && ds.LicenseNumber == item.Invoice.SPK.Vehicle.ActiveLicenseNumber && (ds.Description == "ONGKOS TUKANG HARIAN" || ds.Description == "ONGKOS TUKANG BORONGAN")).FirstOrDefault(); if (itemWorker != null) { int currentIndex = reportDataSource.IndexOf(itemWorker); if (item.ItemName == "Gaji Tukang Borongan") { decimal commission = item.SubTotalWithoutFee - ((100M / 120M) * item.SubTotalWithoutFee); itemWorker.CommisionNominal = commission; itemWorker.Nominal += (item.SubTotalWithoutFee - commission); itemWorker.Total += item.SubTotalWithFee; itemWorker.Fee += (item.SubTotalWithFee - item.SubTotalWithoutFee); } else { itemWorker.Nominal += item.SubTotalWithoutFee; itemWorker.Total += item.SubTotalWithFee; itemWorker.Fee += (item.SubTotalWithFee - item.SubTotalWithoutFee); } reportDataSource[currentIndex] = itemWorker; } else { itemWorker = new RecapInvoiceBySPKItemViewModel(); itemWorker.Category = category.Name; itemWorker.VehicleGroup = vehicleGroup.Name; itemWorker.LicenseNumber = item.Invoice.SPK.Vehicle.ActiveLicenseNumber; itemWorker.Description = item.ItemName == "Gaji Tukang Harian" ? "ONGKOS TUKANG HARIAN" : "ONGKOS TUKANG BORONGAN"; if (item.ItemName == "Gaji Tukang Borongan") { decimal commission = item.SubTotalWithoutFee - ((100M / 120M) * item.SubTotalWithoutFee); itemWorker.CommisionNominal = commission; itemWorker.Nominal = item.SubTotalWithoutFee - commission; itemWorker.Total = item.SubTotalWithFee; itemWorker.Fee = (item.SubTotalWithFee - item.SubTotalWithoutFee); } else { itemWorker.Nominal = item.SubTotalWithoutFee; itemWorker.Total = item.SubTotalWithFee; itemWorker.Fee = (item.SubTotalWithFee - item.SubTotalWithoutFee); } reportDataSource.Add(itemWorker); } } else { RecapInvoiceBySPKItemViewModel itemSparepart = reportDataSource.Where(ds => ds.Category == category.Name && ds.VehicleGroup == vehicleGroup.Name && ds.LicenseNumber == item.Invoice.SPK.Vehicle.ActiveLicenseNumber && ds.Description == "ONDERDIL").FirstOrDefault(); if (itemSparepart != null) { int currentIndex = reportDataSource.IndexOf(itemSparepart); itemSparepart.Nominal += item.SubTotalWithoutFee; itemSparepart.Total += item.SubTotalWithFee; itemSparepart.Fee += (item.SubTotalWithFee - item.SubTotalWithoutFee); reportDataSource[currentIndex] = itemSparepart; } else { itemSparepart = new RecapInvoiceBySPKItemViewModel(); itemSparepart.Category = category.Name; itemSparepart.VehicleGroup = vehicleGroup.Name; itemSparepart.LicenseNumber = item.Invoice.SPK.Vehicle.ActiveLicenseNumber; itemSparepart.Description = "ONDERDIL"; itemSparepart.Nominal = item.SubTotalWithoutFee; itemSparepart.Total = item.SubTotalWithFee; itemSparepart.Fee = (item.SubTotalWithFee - item.SubTotalWithoutFee); reportDataSource.Add(itemSparepart); } } } string customer = (lookupCustomer.GetSelectedDataRow() as CustomerViewModel).CompanyName; RecapInvoiceBySPKPrintItem report = new RecapInvoiceBySPKPrintItem(customer, category.Name, DateFrom, DateTo); report.DataSource = reportDataSource; report.FillDataSource(); using (ReportPrintTool printTool = new ReportPrintTool(report)) { printTool.PrintDialog(); } } catch (Exception ex) { MethodBase.GetCurrentMethod().Fatal("An error occured while trying to print invoice", ex); this.ShowError("Print Invoice Gagal! Hubungi Developer."); } }
public ViewResult CreateVehicleGroup() { VehicleGroupViewModel viewModel = new VehicleGroupViewModel(); return(View("~/Areas/Provider/Views/VehicleGroupManagement/CreatePopup.cshtml", viewModel)); }