Ejemplo n.º 1
0
        public string GetNumber()
        {
            var inputDoc = new GenerateDocNumberInput();

            inputDoc.Month   = DateTime.Now.Month;
            inputDoc.Year    = DateTime.Now.Year;
            inputDoc.DocType = (int)Enums.DocumentType.CCF;
            var number = _docNumberService.GenerateNumber(inputDoc);

            return(number);
        }
Ejemplo n.º 2
0
        public void Save(CarComplaintFormDto CCFDto, CarComplaintFormDtoDetil CCFDtoD1)
        {
            TRA_CCF model;

            if (CCFDto.TraCcfId > 0)
            {
                //update
                model = _ccf.GetCCFById(CCFDto.TraCcfId);

                if (model == null)
                {
                    throw new BLLException(ExceptionCodes.BLLExceptions.DataNotFound);
                }

                Mapper.Map <CarComplaintFormDto, TRA_CCF>(CCFDto, model);
            }
            else
            {
                var inputDoc = new GenerateDocNumberInput();

                inputDoc.Month   = DateTime.Now.Month;
                inputDoc.Year    = DateTime.Now.Year;
                inputDoc.DocType = (int)Enums.DocumentType.CCF;

                CCFDto.DocumentNumber = _docNumberService.GenerateNumber(inputDoc);

                model = Mapper.Map <TRA_CCF>(CCFDto);


                model.TRA_CCF_ID = Convert.ToInt64(CCFDto.TraCcfId);
            }
            TRA_CCF_DETAIL model_d1;

            model_d1 = Mapper.Map <TRA_CCF_DETAIL>(CCFDtoD1);

            _ccf.save(model, model_d1);
            _uow.SaveChanges();

            //_ccf.save(dbCCF);
        }
Ejemplo n.º 3
0
        public void SaveList(List <TraCafDto> data, BusinessObject.Business.Login CurrentUser)
        {
            var datatoSave = Mapper.Map <List <TRA_CAF> >(data);

            foreach (var caf in datatoSave)
            {
                TRA_CAF dataCaf = _CafService.GetCafByNumber(caf.SIRS_NUMBER);
                if (!string.IsNullOrEmpty(caf.VENDOR_NAME))
                {
                    var vendorData = _vendorService.GetByShortName(caf.VENDOR_NAME);
                    caf.VENDOR_ID = vendorData.MST_VENDOR_ID;
                }
                else
                {
                    caf.VENDOR_ID = null;
                }
                if (dataCaf == null)
                {
                    caf.REMARK          = null;
                    caf.IS_ACTIVE       = true;
                    caf.DOCUMENT_NUMBER = _docNumberService.GenerateNumber(new GenerateDocNumberInput()
                    {
                        DocType = (int)Enums.DocumentType.CAF,
                        Month   = DateTime.Now.Month,
                        Year    = DateTime.Now.Year
                    });
                    caf.DOCUMENT_STATUS = (int)Enums.DocumentStatus.Draft;
                    _CafService.Save(caf, CurrentUser);
                }
                else
                {
                    dataCaf.IS_ACTIVE = true;
                    dataCaf.REMARK    = null;
                }
            }
            _uow.SaveChanges();
        }
Ejemplo n.º 4
0
        public TemporaryDto Save(TemporaryDto item, Login userLogin)
        {
            TRA_TEMPORARY model;

            if (item == null)
            {
                throw new Exception("Invalid Data Entry");
            }

            try
            {
                bool changed = false;

                if (item.TRA_TEMPORARY_ID > 0)
                {
                    //update
                    model = _TemporaryService.GetTemporaryById(item.TRA_TEMPORARY_ID);

                    if (model == null)
                    {
                        throw new BLLException(ExceptionCodes.BLLExceptions.DataNotFound);
                    }

                    Mapper.Map <TemporaryDto, TRA_TEMPORARY>(item, model);

                    changed = true;
                }
                else
                {
                    var inputDoc = new GenerateDocNumberInput();
                    inputDoc.Month   = DateTime.Now.Month;
                    inputDoc.Year    = DateTime.Now.Year;
                    inputDoc.DocType = (int)Enums.DocumentType.TMP;

                    item.DOCUMENT_NUMBER_TEMP = _docNumberService.GenerateNumber(inputDoc);
                    item.IS_ACTIVE            = true;
                    item.EMPLOYEE_ID_CREATOR  = userLogin.EMPLOYEE_ID;

                    model = Mapper.Map <TRA_TEMPORARY>(item);
                }

                _TemporaryService.saveTemporary(model, userLogin);
                _uow.SaveChanges();

                //set workflow history
                var input = new TempWorkflowDocumentInput()
                {
                    DocumentId = model.TRA_TEMPORARY_ID,
                    ActionType = Enums.ActionType.Modified,
                    UserId     = userLogin.USER_ID
                };

                if (changed)
                {
                    AddWorkflowHistory(input);
                }
                _uow.SaveChanges();
            }
            catch (Exception exception)
            {
                throw exception;
            }

            return(Mapper.Map <TemporaryDto>(model));
        }
Ejemplo n.º 5
0
        public TraCrfDto SaveCrf(TraCrfDto data, Login userLogin)
        {
            var remark = data.REMARK_ID;

            data.REMARK_ID = null;
            var datatosave = Mapper.Map <TRA_CRF>(data);

            datatosave.BODY_TYPE   = data.Body;
            datatosave.MODIFIED_BY = userLogin.USER_ID;

            var dataFleet = _fleetService.GetFleetByParam(new FleetParamInput()
            {
                EmployeeId  = datatosave.EMPLOYEE_ID,
                VehicleType = datatosave.VEHICLE_TYPE
            }).FirstOrDefault();

            if (datatosave.TRA_CRF_ID > 0)
            {
            }
            else
            {
                //datatosave.role_type


                datatosave.DOCUMENT_NUMBER = _docNumberService.GenerateNumber(new GenerateDocNumberInput()
                {
                    Month   = DateTime.Now.Month,
                    Year    = DateTime.Now.Year,
                    DocType = (int)Enums.DocumentType.CRF
                });

                //datatosave.DELIV_CITY = datatosave.LOCATION_CITY;
                //datatosave.DELIV_ADDRESS = datatosave.LOCATION_OFFICE;

                //datatosave.WITHD_CITY = dataFleet != null ? dataFleet.CITY : null;
                //datatosave.WITHD_ADDRESS = dataFleet != null ? dataFleet.ADDRESS : null;
            }

            if (datatosave.VEHICLE_TYPE == "WTC" || (datatosave.VEHICLE_TYPE == "BENEFIT" && datatosave.VEHICLE_USAGE == "COP"))
            {
                datatosave.RELOCATION_TYPE = "RELOCATE_UNIT";
            }
            if (data.DOCUMENT_STATUS != (int)Enums.DocumentStatus.Cancelled)
            {
                datatosave.MST_REMARK = null;
                datatosave.REMARK     = null;
            }
            else
            {
                datatosave.REMARK = remark;
                _CrfService.SaveCrf(datatosave, userLogin);
                return(data);
                //AddWorkflowHistory(data, userLogin, Enums.ActionType.Created, null);
            }


            datatosave.BODY_TYPE    = dataFleet != null ? dataFleet.BODY_TYPE : null;
            datatosave.MST_FLEET_ID = dataFleet != null ? dataFleet.MST_FLEET_ID : (long?)null;
            var isCompleted = false;

            if (data.DOCUMENT_STATUS == (int)Enums.DocumentStatus.InProgress &&
                DateTime.Now >= data.EFFECTIVE_DATE)
            {
                if (data.PRICE != null)
                {
                    data.DOCUMENT_STATUS = (int)Enums.DocumentStatus.Completed;
                    isCompleted          = CompleteDocument(data.TRA_CRF_ID, userLogin);
                    if (isCompleted)
                    {
                        datatosave.DOCUMENT_STATUS = data.DOCUMENT_STATUS;
                    }
                }
            }
            if (!data.IsSend)
            {
                data.TRA_CRF_ID = _CrfService.SaveCrf(datatosave, userLogin);
                if (data.DOCUMENT_STATUS == (int)Enums.DocumentStatus.Draft)
                {
                    AddWorkflowHistory(data, userLogin, Enums.ActionType.Created, null);
                }
            }
            else
            {
                data.TRA_CRF_ID = _CrfService.SaveCrf(datatosave, userLogin);

                //AddWorkflowHistory(data, userLogin, Enums.ActionType.Submit, null);
                _uow.SaveChanges();

                SubmitCrf(data, userLogin);
            }



            return(data);
        }