/// <summary> /// Constructs a new Waste view with the corresponding view model. /// </summary> /// <param name="viewModel"> /// The view model for this view. /// </param> /// <exception cref="ArgumentException"> /// In the event that the supplied WasteViewModel is null, will throw ArgumentException. /// </exception> public Waste(WasteViewModel viewModel) { InitializeComponent(); m_viewModel = viewModel; if (m_viewModel == null) { throw new ArgumentException("Expected valid WasteViewModel instance."); } DataContext = m_viewModel; }
public IActionResult Edit(WasteViewModel model) { var response = ResponseModelFactory.CreateInstance; if (ConfigurationManager.AppSettings.IsTrialVersion) { response.SetIsTrial(); return(Ok(response)); } if (AuthContextService.CurrentUser.SchoolGuid == null) { response.SetFailed("请登录学校账号"); return(Ok(response)); } using (_dbITMContext) { var ene = _dbITMContext.Orgs.FirstOrDefault(x => x.SchoolName == AuthContextService.CurrentUser.SchoolName); var entity = _dbITMContext.Wastes.FirstOrDefault(x => x.Id == model.Id); if (model.Receiver != "") { entity.Status = 1; } entity.Imgs = model.Imgs; entity.FullName = model.FullName; entity.HandleDate = model.HandleDate; entity.SwillNumber = model.SwillNumber; entity.WasteoilNumber = model.WasteoilNumber; entity.OtherWasteNumber = model.OtherWasteNumber; var eneNewHandlerName = _dbITMContext.Users.FirstOrDefault(x => x.Name == model.NewHandlerName && x.OrganizationId == ene.OrganizationId); if (eneNewHandlerName != null) { entity.NewHandlerName = model.NewHandlerName; entity.HandlerId = eneNewHandlerName.UserId; } else { response.SetFailed("暂无交接负责人信息"); return(Ok(response)); } entity.ReceiverCompanyId = model.ReceiverCompanyId; entity.Receiver = model.Receiver; entity.ReceiverCompanyName = model.ReceiverCompanyName; entity.ReceiverIdentityCard = model.ReceiverIdentityCard; entity.Note = model.Note; _dbITMContext.SaveChanges(); response.SetSuccess("修改成功"); return(Ok(response)); } }
private WasteViewModel InitIndexViewModel(WasteViewModel model) { var company = GlobalFunctions.GetCompanyList(_companyBll); var listPlant = GlobalFunctions.GetPlantAll(); if (CurrentUser.UserRole != Enums.UserRole.Administrator) { var userPlantCompany = _userPlantMapBll.GetCompanyByUserId(CurrentUser.USER_ID); var poaMapCompany = _poaMapBll.GetCompanyByPoaId(CurrentUser.USER_ID); var distinctCompany = company.Where(x => userPlantCompany.Contains(x.Value)); if (CurrentUser.UserRole == Enums.UserRole.POA) { distinctCompany = company.Where(x => poaMapCompany.Contains(x.Value)); } var getCompany = new SelectList(distinctCompany, "Value", "Text"); company = getCompany; var itemPlant = GlobalFunctions.GetPlantAll().Where(x => CurrentUser.ListUserPlants.Contains(x.Value)); listPlant = new SelectList(itemPlant, "Value", "Text"); } model.CompanyCodeList = company; model.PlantWerksList = listPlant; model.MonthList = GlobalFunctions.GetMonthList(_monthBll); model.YearList = WasteYearList(); model.Month = DateTime.Now.Month.ToString(); model.Year = DateTime.Now.Year.ToString(); var input = Mapper.Map <WasteGetByParamInput>(model); input.WasteProductionDate = null; input.UserId = CurrentUser.USER_ID; input.UserRole = CurrentUser.UserRole; input.ListUserPlants = CurrentUser.ListUserPlants; var dbData = _wasteBll.GetAllByParam(input); //var dbWasteQty = _wasteBll.CalculateWasteQuantity(dbData); model.Details = Mapper.Map <List <WasteDetail> >(dbData); return(model); }
public PartialViewResult FilterWasteIndex(WasteViewModel model) { var input = Mapper.Map <WasteGetByParamInput>(model); if (input.WasteProductionDate != null) { input.WasteProductionDate = Convert.ToDateTime(input.WasteProductionDate).ToString(); } input.UserId = CurrentUser.USER_ID; input.UserRole = CurrentUser.UserRole; input.ListUserPlants = CurrentUser.ListUserPlants; var dbData = _wasteBll.GetAllByParam(input); var result = Mapper.Map <List <WasteDetail> >(dbData); var viewModel = new WasteViewModel(); viewModel.Details = result; viewModel.IsNotViewer = CurrentUser.UserRole != Enums.UserRole.Viewer && CurrentUser.UserRole != Enums.UserRole.Controller; return(PartialView("_WasteTableIndex", viewModel)); }
/// <summary> /// Inits all the various views for the application, which will be pushed and popped on the /// primary window as requested or required. /// </summary> private void InitViews() { if (m_filteringEngine == null) { throw new Exception("Engine must be initialized prior to initializing views, as views require references to allow user control."); } // We null check, because if the save state load worked, these conditions will be // false and we won't overwrite our restored state. // This collection is initialized here because it has a direct connection to the UI. if (m_filteredApplicationsTable == null) { m_filteredApplicationsTable = new ConcurrentDictionary <string, FilteredAppModel>(); } if (m_modelDashboard == null) { m_modelDashboard = new DashboardModel(m_filteringEngine); } if (m_viewModelDashboard == null) { m_viewModelDashboard = new DashboardViewModel(m_modelDashboard); } if (m_modelStatistics == null) { m_modelStatistics = new StatisticsModel(); } if (m_viewModelStatistics == null) { m_viewModelStatistics = new StatisticsViewModel(m_modelStatistics); } if (m_modelSettings == null) { m_modelSettings = new SettingsModel(); } if (m_viewModelSettings == null) { m_viewModelSettings = new SettingsViewModel(m_modelSettings); } if (m_viewModelWaste == null) { m_viewModelWaste = new WasteViewModel(m_viewModelSettings, m_viewModelDashboard); } // Necessary because we use a background worker. This thread != UI thread. Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate() { m_modelStatistics.FilterCategories = m_filteringCategoriesObservable; m_modelSettings.FilterCategories = m_filteringCategoriesObservable; m_primaryWindow = new MainWindow(); m_viewProgressWait = new ProgressWait(); m_viewStatistics = new Statistics(m_viewModelStatistics); m_viewDashboard = new Dashboard(m_viewModelDashboard); m_viewSettings = new Settings(m_viewModelSettings, new AddCategoryControl(m_filteringEngine)); m_viewWaste = new Waste(m_viewModelWaste); m_primaryWindow.ViewChangeRequest += OnViewChangeRequest; m_viewDashboard.ViewChangeRequest += OnViewChangeRequest; m_viewStatistics.ViewChangeRequest += OnViewChangeRequest; m_viewSettings.ViewChangeRequest += OnViewChangeRequest; m_viewWaste.ViewChangeRequest += OnViewChangeRequest; // Listen for the statistics view requests for app-wide stats deletion. m_viewStatistics.ClearStatisticsRequested += OnClearAllStatsRequest; MainWindow = m_primaryWindow; } ); }