Пример #1
0
        // Сохранение задачи

        private async void btnSaveTask_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                _newTaskBD.ID_StaffSender = ID_User;

                // Добавление новой задачи

                if (_isNewRecord)
                {
                    _databasenEtities.TaskBD.Add(_newTaskBD);
                }

                int resultDB = await _databasenEtities.SaveChangesAsync();

                MessageService.MetroMessageDialogResult(resultDB);

                if (_isNewRecord && resultDB > -1)
                {
                    DataContext      = _newTaskBD = new TaskBD();
                    tbCompanyID.Text = tbPeopleID.Text = "0";
                    tbDealID.Text    = tbGoodsID.Text = "0";
                }
            }
            catch (Exception ex)
            {
                MessageService.MetroMessageDialogError(ex.Message);
            }
        }
Пример #2
0
 protected override void OnViewExecuting(object viewModel)
 {
     SetViewModel <TaskItemEditVM>(m => {
         m.Tasks = TaskBD.GetRefList();
         m.Users = UserBD.GetRefList();
     });
 }
Пример #3
0
        private void Save(TaskEditVM.EditInput input)
        {
            Task task;

            if (input.Id == 0)
            {
                task = new Task();
            }
            else
            {
                task = TaskBD.Get(input.Id);
            }

            task.Name          = input.Name;
            task.User          = input.User.ToReferencedDO(UserBD);
            task.CreateDate    = input.CreateDate;
            task.PlanBeginDate = input.PlanBeginDate;
            task.PlanEndDate   = input.PlanEndDate;
            task.BeginDate     = input.BeginDate;
            task.EndDate       = input.EndDate;
            task.Status        = input.Status;


            TaskBD.Save(task);
        }
Пример #4
0
        // Открытие карточки задачи

        private void dgTask_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (dgTask.SelectedItem != null)
            {
                TaskBD taskBD = (TaskBD)dgTask.SelectedItem;
                NavigationService.Content = new TaskPage(taskBD.ID);
            }
        }
Пример #5
0
 public ActionResult Delete(TaskSearchVM searchvm, TaskListVM listvm)
 {
     foreach (var id in listvm.Input.SelectedValues)
     {
         TaskBD.Delete(id);
     }
     return(List(searchvm, listvm));
 }
Пример #6
0
        public ActionResult Edit(int id)
        {
            var m = new TaskEditVM
            {
                Input = Map <Task, TaskEditVM.EditInput>(TaskBD.Get(id))
            };

            return(ForView(m));
        }
Пример #7
0
        public ActionResult List(TaskSearchVM searchvm, TaskListVM listvm)
        {
            if (!ModelState.IsValid)
            {
                return(ClientShowMessage());
            }
            var filter = BuildFilter(searchvm.Input);

            if (filter != null)
            {
                listvm.ResultList = TaskBD.GetDtoList <TaskListVM.ListRow>(listvm.Input.Pager,
                                                                           filter,
                                                                           listvm.Input.OrderExpression);
            }
            return(ForView("List", listvm));
        }
Пример #8
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            Task.Factory.StartNew(() =>
            {
                try
                {
                    // Получение задачи

                    if (Application.Current.Properties.Contains("ReceiveTask") && (bool)Application.Current.Properties["ReceiveTask"] == true)
                    {
                        TaskBD[] tempTaskBD = _databasenEtities.TaskBD.Where(a => a.ID_Staff == ID_User && a.ID_Condition != 1 || a.ID_Post == a.Staff.ID_Post && a.ID_Staff == null && a.ID_Condition != 1).Take(1).ToArray();

                        if (tempTaskBD.Length != 0)
                        {
                            _ID_Row = tempTaskBD[0].ID;
                        }
                        else
                        {
                            Dispatcher.Invoke(() => MessageService.MetroMessageDialog("Получение задачи", "Для вас на данный момент нету задач."));
                        }

                        _isNewRecord = false;
                        Application.Current.Properties["ReceiveTask"] = false;

                        if (tempTaskBD.Length == 0)
                        {
                            return;
                        }
                    }

                    TaskBD taskBD = _newTaskBD;
                    List <CardClient> companyList = new List <CardClient> {
                        new CardClient()
                    };
                    List <People> peopleList = new List <People> {
                        new People()
                    };
                    List <Goods> goodsList = new List <Goods> {
                        new Goods()
                    };

                    if (!_isNewRecord)
                    {
                        taskBD  = _databasenEtities.TaskBD.Single(a => a.ID == _ID_Row);
                        ID_User = (int)taskBD.ID_StaffSender;
                    }

                    PostPeople[] postPeopleArr = _databasenEtities.PostPeople.OrderBy(a => a.Name).ToArray();
                    Staff[] staffArr           = _databasenEtities.Staff.ToArray();
                    companyList.AddRange(_databasenEtities.CardClient.Where(a => !String.IsNullOrEmpty(a.NameCompany)).ToArray());
                    peopleList.AddRange(_databasenEtities.People.ToArray());
                    goodsList.AddRange(_databasenEtities.Goods.ToArray());
                    ConditionTask[] conditionTaskArr = _databasenEtities.ConditionTask.OrderBy(a => a.Name).ToArray();

                    Dispatcher.Invoke(() =>
                    {
                        DataContext               = taskBD;
                        cbPost.ItemsSource        = postPeopleArr;
                        cbStaffSender.ItemsSource = staffArr;
                        cbStaffSender.DataContext = this;
                        cbPeople.ItemsSource      = peopleList;
                        cbCompany.ItemsSource     = companyList;
                        cbGoods.ItemsSource       = goodsList;
                        cbStatus.ItemsSource      = conditionTaskArr;

                        if (_isNewRecord)
                        {
                            cbStaffSender.IsEnabled = false;
                        }

                        if (taskBD.ID_Client == null)
                        {
                            tbCompanyID.Text = "0";
                        }

                        if (taskBD.ID_People == null)
                        {
                            tbPeopleID.Text = "0";
                        }

                        if (taskBD.ID_Deal == null)
                        {
                            tbDealID.Text = "0";
                        }

                        if (taskBD.ID_Goods == null)
                        {
                            tbGoodsID.Text = "0";
                        }

                        gMain.IsEnabled = true;
                    });
                }
                catch (Exception ex)
                {
                    MessageService.MetroMessageDialogError(ex.Message);
                }
            });
        }