public static ProcessDTO getProcess(string id_process)
        {
            ProcessDTO process = new ProcessDTO();

            using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["connectionRRHHDatabase"].ConnectionString))
            {
                SqlCommand command = new SqlCommand("usp_get_process", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@id_process", SqlDbType.BigInt);
                command.Parameters["@id_process"].Value = id_process;
                command.Connection.Open();
                SqlDataReader rdr = command.ExecuteReader();
                while (rdr.Read())
                {
                    process.id_processManagment = rdr["id_processManagment"].ToString();
                    process.name                = rdr["name"].ToString();
                    process.createdBy           = rdr["createdBy"].ToString();
                    process.createdDate         = rdr["createdDate"].ToString();
                    process.categorie_id        = rdr["categorie_id"].ToString();
                    process.categorie_name      = rdr["categorie_name"].ToString();
                    process.completedPorcentage = rdr["completedPorcentage"].ToString();
                    process.template_id         = rdr["template_id"].ToString();
                    process.state_id            = rdr["state_id"].ToString();
                    process.state_name          = rdr["state_name"].ToString();
                    process.state_color         = rdr["state_color"].ToString();
                    process.template_id         = rdr["template_id"].ToString();
                    process.template_name       = rdr["template_name"].ToString();
                    process.completedTasks      = rdr["completedTasks"].ToString();
                    process.totalTasks          = rdr["totalTasks"].ToString();
                    process.previousProcess     = rdr["previousProcess"].ToString();
                    process.nextProcess         = rdr["nextProcess"].ToString();
                }
            };
            return(process);
        }
        public async Task <bool> AddProcessByAlgorithm(ProcessDTO processData)
        {
            var result = false;
            var blocks = await _context.Blocks.Include(x => x.Processes).ToListAsync();

            var blocksDTO = _mapper.Map <List <BlockDTO> >(blocks);

            var resultAlgorithms = _algorithmsDiccionary[processData.AlgorithmType].AddProcessToBlock(processData.Size, blocksDTO);

            if (resultAlgorithms.Equals(0))
            {
                return(result);
            }

            var blockSelected = blocks.Where(x => x.Order.Equals(resultAlgorithms)).FirstOrDefault();

            var processEntity = _mapper.Map <Process>(processData);

            processEntity.Block   = blockSelected;
            processEntity.BlockId = blockSelected.Id;

            _context.Processes.Add(processEntity);
            await _context.SaveChangesAsync();

            result = true;
            return(result);
        }
        public frmProcess(int processID)
        {
            InitializeComponent();
            tabControlMain.IsEnabled         = false;
            dtgEntityGroup.SelectionChanged += DtgEntityGroup_SelectionChanged;
            SetEntities();
            SetRoles();


            //ControlHelper.GenerateContextMenu(dtgAdminRoleTypes);
            lokEntities.SelectionChanged += LokEntities_SelectionChanged;
            tabForm.Visibility            = Visibility.Collapsed;

            lokEntities.SelectionChanged        += LokEntities_SelectionChanged1;
            colRelationshipTail.NewItemEnabled   = true;
            colRelationshipTail.EditItemEnabled  = true;
            colRelationshipTail.EditItemClicked += ColRelationshipTail_EditItemClicked;
            ControlHelper.GenerateContextMenu(dtgEntityGroup);
            ControlHelper.GenerateContextMenu(dtgRelationshipTails);

            if (processID == 0)
            {
                tabForm.IsEnabled = false;
                Message           = new ProcessDTO();
                ShowProcessDTO();
            }
            else
            {
                GetProcess(processID);
            }
        }
Пример #4
0
        public async Task <ActionResult <ProcessDTO> > GetProcess(int id)
        {
            var process = await _context.Processes.FindAsync(id);

            if (process == null)
            {
                return(NotFound());
            }
            var processExchanges = _context.ProcessExchanges
                                   .Where(p => p.ProcessId == id)
                                   .Join(
                _context.ElementaryFlows,
                exc => exc.ElementaryFlowId,
                flow => flow.Id,
                (exc, flow) => new ExchangeDTO
            {
                Value    = exc.Value,
                FlowName = flow.Name,
                UnitName = flow.Unit.Name
            }).ToList();

            var p = new ProcessDTO();

            p.ElementaryExchanges = processExchanges;
            p.ProcessInformation  = process;
            return(p);
        }
        public frmTransitionInfo(ProcessDTO process, TransitionDTO transition)
        {
            InitializeComponent();
            Transition = transition;
            //TransitionActions = transitionActions;
            Process = process;

            ShowMessage();
            SetBaseData();
            dtgTransitionActionList.SelectionChanged += dtgTransitionActionList_SelectionChanged;

            ControlHelper.GenerateContextMenu(dtgFormulaList);
            ControlHelper.GenerateContextMenu(dtgTransitionActionList);
            ControlHelper.GenerateContextMenu(dtgListActivities);
            ControlHelper.GenerateContextMenu(dtgEntityGroup);


            ControlHelper.GenerateContextMenu(dtgActionTargets);
            dtgActionTargets.CellEditEnded += DtgActionTargets_CellEditEnded;
            dtgActionTargets.RowLoaded     += DtgActionTargets_RowLoaded;


            colEntityGroup.EditItemEnabled  = true;
            colEntityGroup.NewItemEnabled   = true;
            colEntityGroup.EditItemClicked += ColEntityGroup_EditItemClicked;
        }
Пример #6
0
        public void Save_Signal()
        {
            A.NewUser();

            A.Commit();



            var psp = A.PasportRandom(1);
            var res = A.NewResource();

            A.Commit();

            var dto = new ProcessDTO {
                OperationId = psp.Oper[0], ZagotId = psp.Zagot[0], EquipmentId = res.Id, PersonUntn = A.SessionUntn
            };

            var saver = new FinSaver(A.Connection);

            saver.Save(dto);

            var signals = Signal.Find(A.Connection, (int)dto.OperationId, (int)dto.ZagotId, (int)dto.EquipmentId);



            Assert.AreEqual(1, signals.Count());
        }
Пример #7
0
        public bool processExpiredMedicine(ProcessDTO processDTO)
        {
            try
            {
                Db.Ado.BeginTran();
                DateTime dateTime = DateTime.Now;

                var tempResult = Db.Queryable <MEDICINE_STOCK>()
                                 .Where(it => it.MEDICINE_ID == processDTO._medicine_id &&
                                        it.BATCH_ID == processDTO._batch_id).Single();

                EXPIRED_MEDICINE_PROCESS expiredMedicine = new EXPIRED_MEDICINE_PROCESS
                {
                    STOCK_ID       = tempResult.STOCK_ID,
                    STAFF_ID       = processDTO._staff_id,
                    PROCESS_DATE   = dateTime,
                    PROCESS_NUMBER = tempResult.AMOUNT
                };

                Db.Insertable(expiredMedicine).ExecuteCommand();

                tempResult.AMOUNT = 0;
                Db.Updateable(tempResult).ExecuteCommand();



                Db.Ado.CommitTran();
                return(true);
            }catch (Exception e)
            {
                Db.Ado.RollbackTran();
                return(false);
            }
        }
        public void UpdateProcess(string computerId, string processId, ProcessDTO process)
        {
            ProcessPerfomance newProcessPerfomance = _mapper.Map <ProcessPerfomanceDTO, ProcessPerfomance>
                                                         (process.PerfomanceInformation);

            newProcessPerfomance.CreationDate = process.Information.CreationDate;
            newProcessPerfomance.RecordDate   = DateTime.Now;
            newProcessPerfomance.ProcessId    = processId;
            _unitOfWork.ProcessesPerfomance.Add(newProcessPerfomance);
            _unitOfWork.SaveChanges();

            ProcessInformation dbprocessInformation = _unitOfWork.ProcessesInformation
                                                      .GetProcessInformationByProcessId(processId);

            if (dbprocessInformation != null)
            {
                _unitOfWork.ProcessesInformation.Remove(dbprocessInformation);
            }
            ProcessInformation newProcessInformation = _mapper.Map <ProcessInformationDTO, ProcessInformation>
                                                           (process.Information);

            newProcessInformation.ProcessId = processId;

            _unitOfWork.ProcessesInformation.Add(newProcessInformation);
            _unitOfWork.SaveChanges();
        }
Пример #9
0
        public void Save_Person_1()
        {
            A.NewUser();

            var psp = A.PasportRandom(1);
            var res = A.NewResource();

            A.Commit();

            var Person = new Person(A.Connection, A.RandomUntn());

            var oz = new OperZagot(A.Connection, psp.Oper[0], psp.Zagot[0]);

            oz.CompleteWork(res, Person);

            var dto = new ProcessDTO {
                OperationId = oz.OperId, ZagotId = oz.ZagotId, EquipmentId = res.Id, PersonUntn = Person.Untn
            };

            var saver = new FinSaver(A.Connection);

            saver.Save(dto);

            Assert.AreEqual(1, oz.Work.Count());
            Assert.AreEqual(Person, oz.Work.First().Person);
        }
        public void AddProcess(string computerId, ProcessDTO process)
        {
            Process newProcess = new Process
            {
                ComputerId = computerId,
                Name       = process.Information.Name,
            };

            _unitOfWork.Processes.Add(newProcess);
            _unitOfWork.SaveChanges();
            string processId = _unitOfWork.Processes
                               .GetProcessByComputerIdAndName(computerId, process.Information.Name).Id;

            ProcessPerfomance newProcessPerfomance = _mapper.Map <ProcessPerfomanceDTO, ProcessPerfomance>
                                                         (process.PerfomanceInformation);

            newProcessPerfomance.CreationDate = process.Information.CreationDate;
            newProcessPerfomance.ProcessId    = processId;
            newProcessPerfomance.RecordDate   = DateTime.Now;
            _unitOfWork.ProcessesPerfomance.Add(newProcessPerfomance);
            _unitOfWork.SaveChanges();

            ProcessInformation newProcessInformation = _mapper.Map <ProcessInformationDTO, ProcessInformation>
                                                           (process.Information);

            newProcessInformation.ProcessId = processId;
            _unitOfWork.ProcessesInformation.Add(newProcessInformation);
            _unitOfWork.SaveChanges();
        }
Пример #11
0
        public void SimulateMRP(ProcessDTO dtoProcess, GenerateMRPDTO dtoGen)
        {
            Database db = null;

            try {
                db = Common.CurrentDatabase;
                db.KeepConnection = true;
                db.BeginTransaction(IsolationLevel.Serializable);

                ProcessDAO dao = new ProcessDAO(db);
                dao.SimulateMRP(null, dtoProcess.PROCESS_NO, dtoGen);

                db.Commit();
            }
            catch (Exception) {
                db.Rollback();
                throw;
            }
            finally {
                if (db.DBConnectionState == ConnectionState.Open)
                {
                    db.Close();
                }
            }
        }
Пример #12
0
        public void UpdateFinishTime(ProcessDTO dto)
        {
            Database db = null;

            try {
                CheckBeforeSave();

                db = Common.CurrentDatabase;
                db.KeepConnection = true;
                db.BeginTransaction(IsolationLevel.Serializable);

                ProcessDAO dao = new ProcessDAO(db);
                dao.UpdateFinishProcess(null, dto);

                db.Commit();
            }
            catch (Exception) {
                db.Rollback();
                throw;
            }
            finally {
                if (db.DBConnectionState == ConnectionState.Open)
                {
                    db.Close();
                }
            }
        }
Пример #13
0
        public void Save_DateTimeStart()
        {
            A.NewUser();



            var psp = A.PasportRandom(1);


            Assert.AreEqual(200, psp.Document.Rank);

            A.Commit();



            var dto = new ProcessDTO {
                OperationId   = psp.Oper[0],
                ZagotId       = psp.Zagot[0],
                EquipmentId   = A.NewResource().Id,
                DateTimeStart = new DateTime(2018, 2, 1),
                PersonUntn    = A.SessionUntn,
            };

            new FinSaver(A.Connection).Save(dto);


            var oz = new OperZagot(A.Connection, psp.Oper[0], psp.Zagot[0]);

            Assert.IsNotNull(oz.DeformStart);
            Assert.AreEqual(dto.DateTimeStart, oz.DeformStart);
        }
        //--------------------------------------------- Updates --------------------------------------------
        public static bool updateProcess(ProcessDTO pProcessDTO)
        {
            using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["connectionRRHHDatabase"].ConnectionString))
            {
                SqlCommand command = new SqlCommand("usp_update_process", connection);
                command.CommandType = System.Data.CommandType.StoredProcedure;

                command.Parameters.Add("@id_process", SqlDbType.Int);
                command.Parameters["@id_process"].Value = pProcessDTO.id_processManagment;
                command.Parameters.Add("@name", SqlDbType.NVarChar);
                command.Parameters["@name"].Value = pProcessDTO.name;
                command.Parameters.Add("@previousProcess", SqlDbType.BigInt);
                command.Parameters["@previousProcess"].Value = pProcessDTO.previousProcess;
                command.Parameters.Add("@nextProcess", SqlDbType.BigInt);
                command.Parameters["@nextProcess"].Value = pProcessDTO.nextProcess;
                command.Parameters.Add("@completedPorcentage", SqlDbType.Int);
                command.Parameters["@completedPorcentage"].Value = pProcessDTO.completedPorcentage;
                command.Parameters.Add("@state_id", SqlDbType.TinyInt);
                command.Parameters["@state_id"].Value = pProcessDTO.state_id;
                command.Parameters.Add("@userLog", SqlDbType.Int);
                command.Parameters["@userLog"].Value = pProcessDTO.userLog;

                command.Connection.Open();
                int result = command.ExecuteNonQuery();
                if (result != 0)
                {
                    return(true);
                }
                return(false);
            };
        }
Пример #15
0
 public IHttpActionResult Put(ProcessDTO processDTO)
 {
     if (!ProcessData.updateProcess(processDTO))
     {
         return(BadRequest());
     }
     return(Ok());
 }
        public IHttpActionResult GetProcessLogs(string id, string cId = "")
        {
            IMongoQuery query;// = Query<ProcessLog>.EQ(e => e.ProcessInstanceId, id);

            if (cId == "")
            {
                query = Query <ProcessLog> .EQ(e => e.ProcessInstanceId, id);
            }
            else
            {
                var paras = new List <string> {
                    id, cId
                };
                query = Query <ProcessLog> .In(e => e.ProcessInstanceId, paras);
            }


            var queryResult = collection.Find(query).ToList();

            foreach (var item in queryResult)
            {
                if (item.Key == "GateContractorQuaProcess")
                {
                    foreach (var itemHistoryField in item.HistoryField)
                    {
                    }
                }
            }
            queryResult.ForEach(r =>
            {
                r.UserName = GetUserName(r.UserId);//employees.Find(e => e.EmployeeID == r.UserId) == null ? r.UserId : employees.Find(e => e.EmployeeID == r.UserId).Name;
                r.TaskName = r.TaskName ?? "起始表单";
                r.KeyName  = r.KeyName ?? (queryResult.Find(rr => rr.KeyName != null) == null ? string.Empty : queryResult.Find(rr => rr.KeyName != null).KeyName);
                r.HistoryField.ForEach(h => h.Value = h.Value == "False" ? string.Empty : h.Value);
            });

            var result = new List <ProcessDTO>();

            foreach (var q in queryResult.OrderByDescending(o => o.Stamp).GroupBy(e => e.FormatStampMonthly))
            {
                var dto            = new ProcessDTO();
                var firstOrDefault = queryResult.FirstOrDefault();
                if (firstOrDefault != null)
                {
                    dto.KeyName = firstOrDefault.KeyName;
                }
                dto.Month = q.Key;
                dto.Logs  = new List <ProcessLog>();
                foreach (var v in q)
                {
                    dto.Logs.Add(v);
                }
                result.Add(dto);
            }

            return(Ok(result));
            //return Ok(queryResult.OrderBy(r => r.Stamp).ToList().GroupBy(e => e.FormatStampMonthly));
        }
Пример #17
0
 private static void PrintProperties(ProcessDTO obj)
 {
     foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(obj))
     {
         string name  = descriptor.Name;
         object value = descriptor.GetValue(obj);
         Console.WriteLine("{0}={1}", name, value);
     }
 }
Пример #18
0
        public void Exception_3()
        {
            //  OperId & ZagotId does not exist
            var dto = new ProcessDTO {
                OperationId = 3, ZagotId = 3
            };

            Assert.ThrowsException <ArgumentException>(() => new FinSaver(A.Connection).Save(dto));
        }
Пример #19
0
 public object GetEditInfo(Guid ID)
 {
     using (ProcessService processService = new ProcessService())
     {
         ProcessDTO model = new ProcessDTO(processService.GetInfo(ID));
         model.ListTypes = EnumObjHelper.GetEnumList <sysBpmsProcess.e_TypeLU>().Select(c => new QueryModel(c.Key.ToString(), c.Value)).ToList();
         return(model);
     }
 }
Пример #20
0
        public void Exception_1()
        {
            // no OperId & ZagotId
            var dto = new ProcessDTO {
                PassportId = 1
            };

            Assert.ThrowsException <ArgumentException>(() => new FinSaver(A.Connection).Save(dto));
        }
Пример #21
0
        public void Exception_2()
        {
            // no ZagotId
            var dto = new ProcessDTO {
                OperationId = 1
            };

            Assert.ThrowsException <ArgumentException>(() => new FinSaver(A.Connection).Save(dto));
        }
Пример #22
0
        /// <summary>
        /// Update record by using the table's primary key.
        /// </summary>
        /// <param name="database"></param>
        /// <param name="data">Data which to update.</param>
        /// <param name="oldPROCESS_NO">Old Key #1</param>
        /// <returns></returns>
        public int UpdateWithPK(Database database, ProcessDTO data, NZString oldPROCESS_NO)
        {
            Database db = UseDatabase(database);

            StringBuilder sb = new StringBuilder();

            #region SQL Statement
            sb.AppendLine(" UPDATE " + data.TableName);
            sb.AppendLine(" SET ");
            sb.AppendLine("  " + ProcessDTO.eColumns.PROCESS_NO + "=:PROCESS_NO");
            sb.AppendLine("  ," + ProcessDTO.eColumns.PROCESS_TYPE + "=:PROCESS_TYPE");
            sb.AppendLine("  ," + ProcessDTO.eColumns.STATUS + "=:STATUS");
            sb.AppendLine("  ," + ProcessDTO.eColumns.DESCRIPTION + "=:DESCRIPTION");
            sb.AppendLine("  ," + ProcessDTO.eColumns.START_PRCS_TIME + "=:START_PRCS_TIME");
            sb.AppendLine("  ," + ProcessDTO.eColumns.END_PRCS_TIME + "=:END_PRCS_TIME");
            sb.AppendLine("  ," + ProcessDTO.eColumns.FILTER_TIMESTAMP + "=:FILTER_TIMESTAMP");
            sb.AppendLine("  ," + ProcessDTO.eColumns.FILE_NAME + "=:FILE_NAME");
            sb.AppendLine("  ," + ProcessDTO.eColumns.MD5SUM + "=:MD5SUM");
            sb.AppendLine("  ," + ProcessDTO.eColumns.IS_CANCEL + "=:IS_CANCEL");
            sb.AppendLine("  ," + ProcessDTO.eColumns.CANCEL_DATE + "=:CANCEL_DATE");
            sb.AppendLine("  ," + ProcessDTO.eColumns.CANCEL_BY + "=:CANCEL_BY");
            sb.AppendLine("  ," + ProcessDTO.eColumns.CANCEL_MACHINE + "=:CANCEL_MACHINE");
            sb.AppendLine("  ," + ProcessDTO.eColumns.PROCESS_DATE + "=:PROCESS_DATE");
            sb.AppendLine("  ," + ProcessDTO.eColumns.PROCESS_BY + "=:PROCESS_BY");
            sb.AppendLine("  ," + ProcessDTO.eColumns.PROCESS_MACHINE + "=:PROCESS_MACHINE");
            sb.AppendLine("  ," + ProcessDTO.eColumns.RESERVE1 + "=:RESERVE1");
            sb.AppendLine("  ," + ProcessDTO.eColumns.RESERVE2 + "=:RESERVE2");
            sb.AppendLine(" WHERE ");
            sb.AppendLine("  " + ProcessDTO.eColumns.PROCESS_NO + "=:oldPROCESS_NO");
            #endregion

            DataRequest req = new DataRequest(sb.ToString());
            #region Parameters
            req.Parameters.Add("PROCESS_NO", DataType.NVarChar, data.PROCESS_NO.Value);
            req.Parameters.Add("PROCESS_TYPE", DataType.NVarChar, data.PROCESS_TYPE.Value);
            req.Parameters.Add("STATUS", DataType.NVarChar, data.STATUS.Value);
            req.Parameters.Add("DESCRIPTION", DataType.NVarChar, data.DESCRIPTION.Value);
            req.Parameters.Add("START_PRCS_TIME", DataType.DateTime, data.START_PRCS_TIME.Value);
            req.Parameters.Add("END_PRCS_TIME", DataType.DateTime, data.END_PRCS_TIME.Value);
            req.Parameters.Add("FILTER_TIMESTAMP", DataType.DateTime, data.FILTER_TIMESTAMP.Value);
            req.Parameters.Add("FILE_NAME", DataType.NVarChar, data.FILE_NAME.Value);
            req.Parameters.Add("MD5SUM", DataType.NVarChar, data.MD5SUM.Value);
            req.Parameters.Add("IS_CANCEL", DataType.Number, data.IS_CANCEL.Value);
            req.Parameters.Add("CANCEL_DATE", DataType.DateTime, data.CANCEL_DATE.Value);
            req.Parameters.Add("CANCEL_BY", DataType.NVarChar, data.CANCEL_BY.Value);
            req.Parameters.Add("CANCEL_MACHINE", DataType.NVarChar, data.CANCEL_MACHINE.Value);
            req.Parameters.Add("PROCESS_DATE", DataType.DateTime, data.PROCESS_DATE.Value);
            req.Parameters.Add("PROCESS_BY", DataType.NVarChar, data.PROCESS_BY.Value);
            req.Parameters.Add("PROCESS_MACHINE", DataType.NVarChar, data.PROCESS_MACHINE.Value);
            req.Parameters.Add("RESERVE1", DataType.NVarChar, data.RESERVE1.Value);
            req.Parameters.Add("RESERVE2", DataType.NVarChar, data.RESERVE2.Value);
            req.Parameters.Add("oldPROCESS_NO", DataType.NVarChar, oldPROCESS_NO.Value);
            #endregion

            return(db.ExecuteNonQuery(req));
        }
Пример #23
0
        public void Exception_4()
        {
            var psp = A.PasportRandom(1);
            //  OperId  does not exist
            var dto = new ProcessDTO {
                OperationId = 3, ZagotId = psp.Zagot[0]
            };

            Assert.ThrowsException <ArgumentException>(() => new FinSaver(A.Connection).Save(dto));
        }
Пример #24
0
        /// <summary>
        /// Check exist before manipulate data. If found record will update data. Otherwise insert new data.
        /// </summary>
        /// <param name="database"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public int AddNewOrUpdate(Database database, ProcessDTO data)
        {
            Database db = UseDatabase(database);

            if (Exist(database, data.PROCESS_NO))
            {
                return(UpdateWithoutPK(db, data));
            }

            return(AddNew(db, data));
        }
Пример #25
0
        public ProcessDTO PutProcess(int id, [FromBody] ProcessDTO p)
        {
            var pr = db.Process.FirstOrDefault(x => x.ProcessID == p.ProcessID);

            if (pr.Description != p.Description)
            {
                pr.Description = p.Description;
            }

            db.SaveChanges();
            return(converter.ProcessToDTO(pr));
        }
Пример #26
0
        public ProcessDTO PostProcess([FromBody] ProcessDTO p)
        {
            Console.WriteLine(p);

            var a = db.Process.Add(converter.DTOToProcess(p));

            Console.WriteLine(p.Description);

            db.SaveChanges();

            return(converter.ProcessToDTO(a.Entity));
        }
        public async Task <IActionResult> FreeProcess(ProcessDTO process)
        {
            var result = await _repository.FreeProcess(process);

            if (result)
            {
                TempData["Msg"] = "Released process";
                return(RedirectToAction("Index"));
            }
            TempData["Msg"] = "Something went very wrong :c";
            return(RedirectToAction("Index"));
        }
Пример #28
0
        public async Task <ActionResult> ApproveProcess(ProcessDTO vm)
        {
            var process = await FindAsyncProcess(vm.Id);

            if (vm.IsApproved && process != null)
            {
                await ApproveSaveAsync(process);

                return(RedirectToAction("Details", new { id = process.Id }));
            }

            return(View("Approve", process));
        }
        public IActionResult processExpiredMedicine([FromForm] ProcessDTO processDTO)
        {
            ProcessManager processManager = new ProcessManager();
            var            result         = processManager.processExpiredMedicine(processDTO);

            if (result)
            {
                return(Ok(JsonCreate.newInstance(ConstMessage.INSERT_SUCCESS, result)));
            }
            else
            {
                return(Conflict(JsonCreate.newInstance(ConstMessage.CONFILICT, result)));
            }
        }
Пример #30
0
        public bool processProblemMedicine(ProcessDTO processDTO)
        {
            try
            {
                Db.Ado.BeginTran();
                DateTime dateTime = DateTime.Now;

                var tempResult = Db.Queryable <MEDICINE_STOCK, STOCK_IN, CONTRACT>
                                     ((ms, si, c) => ms.STOCK_ID == si.STOCK_ID && si.CONTRACT_ID == c.CONTRACT_ID).
                                 Where((ms, si, c) => ms.BATCH_ID == processDTO._batch_id && ms.MEDICINE_ID == processDTO._medicine_id)
                                 .Select((ms, si, c) => new
                {
                    ms.STOCK_ID,
                    c.CONTRACT_ID,
                    ms.AMOUNT
                }).Single();

                if (tempResult.AMOUNT < processDTO._num)
                {
                    throw new Exception();
                }

                PROBLEM_MEDICINE_RETURN problemMedicineReturn = new PROBLEM_MEDICINE_RETURN
                {
                    STOCK_ID      = tempResult.STOCK_ID,
                    CONTRACT_ID   = tempResult.CONTRACT_ID,
                    STAFF_ID      = processDTO._staff_id,
                    RETURN_NUMBER = processDTO._num,
                    RETURN_DATE   = dateTime
                };

                Db.Insertable(problemMedicineReturn).ExecuteCommand();

                MEDICINE_STOCK medicine = new MEDICINE_STOCK
                {
                    STOCK_ID    = tempResult.STOCK_ID,
                    MEDICINE_ID = processDTO._medicine_id,
                    BATCH_ID    = processDTO._batch_id,
                    AMOUNT      = tempResult.AMOUNT - processDTO._num
                };
                Db.Updateable(medicine).ExecuteCommand();

                Db.Ado.CommitTran();
                return(true);
            }catch (Exception e)
            {
                Db.Ado.RollbackTran();
                return(false);
            }
        }