コード例 #1
0
        private bool CheckMe(decimal?workerId)
        {
            if (!workerId.HasValue)
            {
                ShowMessage(string.Format("К пользователю '{0}' не привязан работник. Невозможно создать выполнение работы", WMSEnvironment.Instance.AuthenticatedUser.GetSignature()));
                return(false);
            }

            if (!OpenCloseInArgumentArgument.Get(_context))
            {
                return(true);
            }

            var workerFilter = string.Format("{0} = {1} and {2} = {3} and {4} is null"
                                             , Working.WORKERID_RPropertyName
                                             , workerId.Value
                                             , Working.WORKID_RPropertyName
                                             , CurrentWork.GetKey()
                                             , Working.WORKINGTILLPropertyName);

            var warehouseCode = WarehouseCode.Get(_context);
            var filter        = GetWorkersFilter(false); // в данном случае неважно, есть ли working

            filter += (!string.IsNullOrEmpty(filter) ? " and " : string.Empty) +
                      string.Format("(workerid = {0})", workerId);
            Worker[] items;
            using (var mgr = IoC.Instance.Resolve <IBaseManager <Worker> >())
                items = mgr.GetFiltered(filter, GetModeEnum.Partial).ToArray();
            if (items.Length == 0)
            {
                ShowMessage(
                    string.Format(
                        "Сотрудник (код '{0}') не существует или не привязан к складу (код '{1}') на даты работ",
                        workerId, warehouseCode));
                return(false);
            }

            using (var mgr = IoC.Instance.Resolve <IBaseManager <Working> >())
            {
                var workingItems = mgr.GetFiltered(workerFilter, GetModeEnum.Partial).ToArray();
                if (workingItems.Length > 0)
                {
                    var action = ShowMessage(string.Format("Сотрудник '{0}' уже выполняет работу (код '{1}'). Создать новую детализацию?", items.FirstOrDefault().WorkerFIO, CurrentWork.GetKey()), "Внимание!", MessageBoxButton.YesNo, MessageBoxImage.Warning);
                    return(action == MessageBoxResult.Yes);
                }
            }

            return(true);
        }
コード例 #2
0
        private bool CloseMyWorkings()
        {
            var workerId = WMSEnvironment.Instance.WorkerId;

            if (!CheckMe(workerId))
            {
                return(false);
            }

            var workerFilter = string.Format("{0} = {1} and {2} = {3} and {4} is null"
                                             , Working.WORKERID_RPropertyName
                                             , workerId
                                             , Working.WORKID_RPropertyName
                                             , CurrentWork.GetKey()
                                             , Working.WORKINGTILLPropertyName);

            try
            {
                using (var mgr = IoC.Instance.Resolve <IBaseManager <Working> >())
                {
                    var workings = mgr.GetFiltered(workerFilter, GetModeEnum.Partial).ToArray();

                    foreach (var working in workings)
                    {
                        working.WORKINGTILL = GetCorrectDate();
                    }
                    mgr.Update(workings);
                }
                return(true);
            }
            catch (Exception ex)
            {
                var message = ExceptionHelper.GetErrorMessage(ex);
                _log.Warn(message, ex);
                ShowMessage(message, "Ошибка при добавлении выполнения работ");

                return(false);
            }
        }
コード例 #3
0
        private bool AddMe()
        {
            var workerId = WMSEnvironment.Instance.WorkerId;

            try
            {
                if (!ValidateWorkingByWorkerId(workerId))
                {
                    return(false);
                }

                if (!CheckMe(workerId))
                {
                    return(false);
                }

                var w = new Working
                {
                    WORKERID_R  = workerId,
                    WORKID_R    = CurrentWork.GetKey <decimal>(),
                    WORKINGFROM = GetCorrectDate(),
                    TruckCode   = WMSEnvironment.Instance.TruckCode,
                    WORKINGADDL = false
                };

                using (var mgr = IoC.Instance.Resolve <IBaseManager <Working> >())
                    mgr.Insert(ref w);
            }
            catch (Exception ex)
            {
                var message = ExceptionHelper.GetErrorMessage(ex);
                _log.Warn(message, ex);

                ShowMessage(message, "Ошибка при добавлении сотрудника");
                return(false);
            }
            return(true);
        }
コード例 #4
0
 private string GetWorkersFilter(bool freeOnly)
 {
     return(RclShowWorkManageActivity.GetWorkersFilter(CurrentWork.GetKey <decimal?>(), WarehouseCode.Get(_context), freeOnly));
 }