예제 #1
0
        public ActionResult UpdateRequestTakeChildrens([DataSourceRequest] DataSourceRequest request, TmcView dictionary)
        {
            Tmc d = db.Tmcs.First(o => o.Id == dictionary.Id);

            d.StateType               = dictionary.StateType;
            d.Name                    = dictionary.Name;
            d.Code                    = dictionary.Code;
            d.Count                   = dictionary.Count;
            d.CountActual             = dictionary.CountActual;
            d.OwnerEmployeeId         = dictionary.OwnerEmployeeId;
            d.Number                  = dictionary.Number;
            d.CountFact               = dictionary.CountFact;
            d.CountConvert            = dictionary.CountConvert;
            d.ExpiryDate              = dictionary.ExpiryDate;
            d.ManufactureDate         = dictionary.ManufactureDate;
            d.Manufacturer            = dictionary.Manufacturer;
            d.MeasureTypeConvertDicId = dictionary.MeasureTypeConvertDicId;
            d.MeasureTypeDicId        = dictionary.MeasureTypeDicId;
            d.PackageDicId            = dictionary.PackageDicId;
            d.Rack                    = dictionary.Rack;
            d.Safe                    = dictionary.Safe;
            d.Serial                  = dictionary.Serial;
            d.StorageDicId            = dictionary.StorageDicId;
            d.TmcTypeDicId            = dictionary.TmcTypeDicId;
            d.ReceivingDate           = dictionary.ReceivingDate;
            db.SaveChanges();

            var newDictionary = db.TmcViews.First(o => o.Id == d.Id);

            dictionary.MeasureTypeDicValue = newDictionary.MeasureTypeDicValue;

            return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState)));
        }
예제 #2
0
        public ActionResult CreateTmc([DataSourceRequest] DataSourceRequest request, TmcViewModel model)
        {
            TmcRepository repo = new TmcRepository(false);

            Tmc tmc = new Tmc()
            {
                Id                      = Guid.NewGuid(),
                StateType               = model.StateType,
                Name                    = model.Name,
                Code                    = model.Code,
                CreatedDate             = DateTime.Now,
                CreatedEmployeeId       = UserHelper.GetCurrentEmployee().Id,
                Count                   = model.Count,
                CountActual             = model.CountActual,
                OwnerEmployeeId         = model.OwnerEmployeeId,
                Number                  = model.Number,
                CountFact               = model.CountFact,
                CountConvert            = model.CountFact,
                ExpiryDate              = model.ExpiryDate,
                ManufactureDate         = model.ManufactureDate,
                Manufacturer            = model.Manufacturer,
                MeasureTypeConvertDicId = model.MeasureTypeConvertDicId,
                MeasureTypeDicId        = model.MeasureTypeDicId,
                PackageDicId            = model.PackageDicId,
                Rack                    = model.Rack,
                Safe                    = model.Safe,
                Serial                  = model.Serial,
                StorageDicId            = model.StorageDicId,
                TmcTypeDicId            = model.TmcTypeDicId,
                ReceivingDate           = model.ReceivingDate,
                TmcInId                 = Guid.Parse(model.TmcInIdString),
            };

            repo.Insert(tmc);
            repo.Save();
            model.Id = tmc.Id;

            var newDictionary = repo.TvGetAsQuarable(o => o.Id == tmc.Id).First();

            model.MeasureTypeDicValue = newDictionary.MeasureTypeDicValue;

            var appRepo = new ApplicationPoaRepository(false);

            appRepo.AddLimsTmcTemp(new LimsTmcTemp()
            {
                TmcId         = tmc.Id,
                TmcInId       = tmc.TmcInId,
                CountRequest  = model.CountRequest,
                CountReceived = null,
                IsSelected    = model.IsSelected,
                CreatedDate   = DateTime.Now
            });
            appRepo.Save();

            return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
        }
예제 #3
0
        public ActionResult DestroyRequestTakeChildrens([DataSourceRequest] DataSourceRequest request, TmcView dictionary)
        {
            if (dictionary != null)
            {
                Tmc d = db.Tmcs.First(o => o.Id == dictionary.Id);
                db.Tmcs.Remove(d);
                db.SaveChanges();
            }

            return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState)));
        }
예제 #4
0
        public ActionResult AddTmc(Guid id)
        {
            var tmc = db.Tmcs.FirstOrDefault(t => t.Id == id);

            if (tmc == null)
            {
                tmc = new Tmc()
                {
                    Id    = id,
                    Count = 0
                };
            }
            return(PartialView(tmc));
        }
예제 #5
0
        public ActionResult UpdateTmc([DataSourceRequest] DataSourceRequest request, TmcViewModel model)
        {
            TmcRepository repo = new TmcRepository(false);
            Tmc           tmc  = repo.GetAsQuarable(o => o.Id == model.Id).FirstOrDefault();

            if (tmc != null)
            {
                //tmc.StateType = model.StateType;
                //tmc.Name = model.Name;
                //tmc.Code = model.Code;
                //tmc.Count = model.Count;
                //tmc.CountActual = model.CountRequest.Value;
                //tmc.OwnerEmployeeId = model.OwnerEmployeeId;
                //tmc.Number = model.Number;
                //tmc.CountFact = model.CountRequest.Value;
                //tmc.CountConvert = model.CountRequest.Value;
                //tmc.ExpiryDate = model.ExpiryDate;
                //tmc.ManufactureDate = model.ManufactureDate;
                //tmc.Manufacturer = model.Manufacturer;
                //tmc.MeasureTypeConvertDicId = model.MeasureTypeConvertDicId;
                //tmc.MeasureTypeDicId = model.MeasureTypeDicId;
                //tmc.PackageDicId = model.PackageDicId;
                //tmc.Rack = model.Rack;
                //tmc.Safe = model.Safe;
                //tmc.Serial = model.Serial;
                //tmc.StorageDicId = model.StorageDicId;
                //tmc.TmcTypeDicId = model.TmcTypeDicId;
                //tmc.ReceivingDate = model.ReceivingDate;
                tmc.MeasureTypeDicId = model.MeasureTypeDicId;
            }

            repo.Save();

            if (tmc != null)
            {
                var newDictionary = repo.TvGetAsQuarable(o => o.Id == tmc.Id).First();
                model.MeasureTypeDicValue = newDictionary.MeasureTypeDicValue;

                var appRepo     = new ApplicationPoaRepository(false);
                var limsTmcTemp = appRepo.GetLimsTmcTemps(ltt => ltt.TmcId == tmc.Id && ltt.TmcInId == tmc.TmcInId).FirstOrDefault();
                if (limsTmcTemp != null)
                {
                    limsTmcTemp.CountRequest  = model.CountRequest;
                    limsTmcTemp.CountReceived = model.CounReceived;
                }
                appRepo.Save();
            }
            return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
        }
 public async Task <IActionResult> Edit([Bind("Id,InventoryNumber,Name,Description,TypeId,PurchaseDate,ResponsiblePersonId,FactoryNumber,WriteOffDate,RoomId,ActId,WarrantyDate")] Tmc tmc)
 {
     try
     {
         await _tmcs.UpdateAsync(tmc);
     }
     catch (DbUpdateConcurrencyException)
     {
         if (!await _tmcs.ItemExists(x => x.Id == tmc.Id))
         {
             return(NotFound());
         }
         throw;
     }
     return(RedirectToAction(nameof(Index)));
 }
예제 #7
0
        public ActionResult ConfirmAcceptTmc(Guid id, Tmc tmc)
        {
            TmcRepository repo     = new TmcRepository(false);
            var           tmcExist = repo.GetAsQuarable(o => o.Id == id).FirstOrDefault();

            if (tmcExist != null)
            {
                if (tmcExist.StateType == Tmc.TmcStatuses.Accepted)
                {
                    tmcExist.CountFact    += tmc.Count;
                    tmcExist.CountActual  += tmc.CountConvert;
                    tmcExist.CountConvert += tmc.CountConvert;
                }
                else
                {
                    tmcExist.CountFact   = tmc.Count;
                    tmcExist.CountActual = tmcExist.CountConvert = tmc.CountConvert;
                }

                tmcExist.StateType = Tmc.TmcStatuses.Accepted;

                if (tmc.MeasureTypeConvertDicId != null)
                {
                    tmcExist.MeasureTypeConvertDicId = tmc.MeasureTypeConvertDicId;
                }
                else
                {
                    tmcExist.MeasureTypeConvertDicId = tmcExist.MeasureTypeDicId;
                    tmcExist.CountActual             = tmcExist.CountConvert = tmcExist.CountFact = tmc.Count;
                }
                tmcExist.OwnerEmployeeId = UserHelper.GetCurrentEmployee().Id;
                tmcExist.ReceivingDate   = tmc.ReceivingDate ?? DateTime.Now;
                repo.Save();

                ApplicationPoaRepository repository = new ApplicationPoaRepository(false);
                var limsTmcTemp = repository.GetLimsTmcTemps(ltt => ltt.TmcId == tmc.Id && ltt.TmcInId == tmc.TmcInId).FirstOrDefault();
                if (limsTmcTemp != null)
                {
                    limsTmcTemp.CountReceived = tmc.Count;
                }
                repository.Save();
            }

            return(Json(id, JsonRequestBehavior.AllowGet));
        }
예제 #8
0
        public ActionResult DestroyTmc([DataSourceRequest] DataSourceRequest request, TmcViewModel dictionary)
        {
            TmcRepository            repo    = new TmcRepository(false);
            ApplicationPoaRepository poaRepo = new ApplicationPoaRepository(false);

            if (dictionary != null)
            {
                var limsTmcTemp = poaRepo.GetLimsTmcTemps(ltt => ltt.TmcId == dictionary.Id && ltt.TmcInId == dictionary.TmcInId).FirstOrDefault();
                poaRepo.DeleteLimsTmcTemp(limsTmcTemp);
                poaRepo.Save();

                Tmc d = repo.GetAsQuarable(o => o.Id == dictionary.Id).First();
                repo.Delete(d);
                repo.Save();
            }

            return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState)));
        }
예제 #9
0
        public ActionResult CreateTmcListFirst([DataSourceRequest] DataSourceRequest request, TmcView dictionary)
        {
            Tmc tmc = new Tmc()
            {
                Id    = Guid.NewGuid(),
                Name  = dictionary.Name,
                Count = dictionary.Count,
                //CountActual = dictionary.CountActual,
                //CountFact = dictionary.CountFact,
                // OwnerEmployeeValue = dictionary.OwnerEmployeeValue,
                StateType = 1,
                Rack      = dictionary.Rack,
                Safe      = dictionary.Safe,
                MeasureTypeConvertDicId = dictionary.MeasureTypeConvertDicId,
                //MeasureTypeConvertDicValue = dictionary.MeasureTypeConvertDicValue,
                //StateTypeValue = dictionary.StateTypeValue,
                CountConvert      = dictionary.CountConvert,
                Manufacturer      = dictionary.Manufacturer,
                CreatedDate       = DateTime.Now,                       //dictionary.CreatedDate,
                CreatedEmployeeId = UserHelper.GetCurrentEmployee().Id, //dictionary.CreatedEmployeeId,
                ExpiryDate        = dictionary.ExpiryDate,
                ManufactureDate   = dictionary.ManufactureDate,
                MeasureTypeDicId  = dictionary.MeasureTypeDicId,
                //MeasureTypeDicValue = dictionary.MeasureTypeDicValue,
                OwnerEmployeeId = dictionary.OwnerEmployeeId,
                Number          = dictionary.Number,
                TmcTypeDicId    = dictionary.TmcTypeDicId,
                //StorageDicValue = dictionary.StorageDicValue,
                //TmcTypeDicValue = dictionary.TmcTypeDicValue,
                StorageDicId = dictionary.StorageDicId,
                Serial       = dictionary.Serial,
                PackageDicId = dictionary.PackageDicId,
                //PackageDicValue = dictionary.PackageDicValue,
                Code = dictionary.Code,
            };

            db.Tmcs.Add(tmc);
            db.SaveChanges();
            dictionary = db.TmcViews.First(o => o.Id == tmc.Id);
            return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState)));
        }
예제 #10
0
        public ActionResult CreateRequestTakeChildrens([DataSourceRequest] DataSourceRequest request, TmcViewModel dictionary)
        {
            Tmc tmc = new Tmc()
            {
                Id                      = Guid.NewGuid(),
                StateType               = dictionary.StateType,
                Name                    = dictionary.Name,
                Code                    = dictionary.Code,
                CreatedDate             = DateTime.Now,
                CreatedEmployeeId       = UserHelper.GetCurrentEmployee().Id,
                Count                   = dictionary.Count,
                CountActual             = dictionary.CountActual,
                OwnerEmployeeId         = dictionary.OwnerEmployeeId,
                Number                  = dictionary.Number,
                CountFact               = dictionary.CountFact,
                CountConvert            = dictionary.CountFact,
                ExpiryDate              = dictionary.ExpiryDate,
                ManufactureDate         = dictionary.ManufactureDate,
                Manufacturer            = dictionary.Manufacturer,
                MeasureTypeConvertDicId = dictionary.MeasureTypeConvertDicId,
                MeasureTypeDicId        = dictionary.MeasureTypeDicId,
                PackageDicId            = dictionary.PackageDicId,
                Rack                    = dictionary.Rack,
                Safe                    = dictionary.Safe,
                Serial                  = dictionary.Serial,
                StorageDicId            = dictionary.StorageDicId,
                TmcTypeDicId            = dictionary.TmcTypeDicId,
                ReceivingDate           = dictionary.ReceivingDate,
                TmcInId                 = Guid.Parse(dictionary.TmcInIdString),
            };

            db.Tmcs.Add(tmc);
            db.SaveChanges();
            dictionary.Id = tmc.Id;

            var newDictionary = db.TmcViews.First(o => o.Id == tmc.Id);

            dictionary.MeasureTypeDicValue = newDictionary.MeasureTypeDicValue;

            return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState)));
        }
예제 #11
0
        public ActionResult ConfirmAddTmc(Guid id, Tmc tmc)
        {
            var item = db.Tmcs.First(o => o.Id == id);

            item.StateType    = 1;
            item.CountFact    = tmc.Count;
            item.CountConvert = tmc.CountConvert;
            if (tmc.MeasureTypeConvertDic != null)
            {
                item.MeasureTypeConvertDicId = tmc.MeasureTypeConvertDic.Id;
            }
            else
            {
                item.MeasureTypeConvertDicId = item.MeasureTypeDicId;
                item.CountConvert            = item.CountFact = tmc.Count;
            }
            item.OwnerEmployeeId = UserHelper.GetCurrentEmployee().Id;

            item.ReceivingDate = tmc.ReceivingDate ?? DateTime.Now;


            db.SaveChanges();
            return(Json(id, JsonRequestBehavior.AllowGet));
        }
예제 #12
0
        public ActionResult CreateApplication([DataSourceRequest] DataSourceRequest request, TmcInViewModel model)
        {
            if (ModelState.IsValid)
            {
                ApplicationPoaRepository repo = new ApplicationPoaRepository(false);
                TmcIn tmcIn = new TmcIn()
                {
                    Id                   = Guid.NewGuid(),
                    StateType            = model.StateType,
                    ContractDate         = model.ContractDate,
                    ContractNumber       = model.ContractNumber,
                    CreatedDate          = DateTime.Now,
                    CreatedEmployeeId    = UserHelper.GetCurrentEmployee().Id,
                    IsFullDelivery       = model.IsFullDelivery,
                    LastDeliveryDate     = model.LastDeliveryDate,
                    OwnerEmployeeId      = model.OwnerEmployeeId,
                    Provider             = model.Provider,
                    ProviderBin          = model.ProviderBin,
                    ExecutorEmployeeId   = model.ExecutorEmployeeId,
                    AgreementEmployeeId  = model.AgreementEmployeeId,
                    AccountantEmployeeId = model.AccountantEmployeeId
                };

                repo.Insert(tmcIn);
                repo.Save();

                var newDictionary = repo.GetTmcInViews(o => o.Id == tmcIn.Id).First();
                model.TmcInId                 = tmcIn.Id;
                model.OwnerEmployeeValue      = newDictionary.OwnerEmployeeValue;
                model.StateTypeValue          = newDictionary.StateTypeValue;
                model.PowerOfAttorney         = newDictionary.PowerOfAttorney;
                model.IsFullDeliveryValue     = newDictionary.IsFullDeliveryValue;
                model.ExecutorEmployeeValue   = newDictionary.ExecutorEmployeeValue;
                model.AgreementEmployeeValue  = newDictionary.AgreementEmployeeValue;
                model.AccountantEmployeeValue = newDictionary.AccountantEmployeeValue;
                model.Id = newDictionary.Id;


                TmcRepository tmcRepo          = new TmcRepository();
                var           dicRepo          = new DictionaryRepository(false);
                var           contractProducts = tmcRepo.GetI1cLimsContractProducts(lc => lc.ContractNumber == tmcIn.ContractNumber);
                foreach (var prod in contractProducts.ToList())
                {
                    var measureId = dicRepo.GetDictionaryIdByTypeAndDisplayName(Dictionary.MeasureType.DicCode, prod.Unit);
                    if (measureId == null || measureId == Guid.Empty)
                    {
                        measureId = dicRepo.GetDictionaryIdByTypeAndName(Dictionary.MeasureType.DicCode, prod.Unit);
                    }

                    var tmc = new Tmc()
                    {
                        Id                      = Guid.NewGuid(),
                        CreatedDate             = DateTime.Now,
                        CreatedEmployeeId       = UserHelper.GetCurrentEmployee().Id,
                        TmcInId                 = tmcIn.Id,
                        StateType               = 0,
                        Number                  = prod.ProductId,
                        Code                    = prod.ProductId,
                        Name                    = prod.Name,
                        Count                   = prod.QuantityVolume.Value,
                        CountActual             = 0, //prod.QuantityVolume.Value,
                        CountFact               = 0, //prod.QuantityVolume.Value,
                        CountConvert            = 0, // prod.QuantityVolume.Value,
                        MeasureTypeDicId        = measureId,
                        MeasureTypeConvertDicId = measureId
                    };


                    var tmcExist = tmcRepo.GetAsQuarable(t => t.Number == tmc.Number && t.StateType != Tmc.TmcStatuses.Writeoff).FirstOrDefault();

                    if (tmcExist == null)
                    {
                        tmcRepo.Insert(tmc);

                        var limsTmc = new LimsTmcTemp()
                        {
                            TmcId        = tmc.Id,
                            TmcInId      = tmc.TmcInId,
                            CreatedDate  = DateTime.Now,
                            CountRequest = tmc.Count,
                            IsSelected   = false
                        };
                        repo.AddLimsTmcTemp(limsTmc);
                    }
                    else if (tmcExist.CountFact < tmcExist.Count)
                    {
                        var limsTmc = new LimsTmcTemp()
                        {
                            TmcId        = tmcExist.Id,
                            TmcInId      = tmcIn.Id,
                            CreatedDate  = DateTime.Now,
                            CountRequest = prod.QuantityVolume.Value - tmcExist.CountFact,
                            IsSelected   = false
                        };
                        if (prod.QuantityVolume.Value - tmcExist.CountFact > 0)
                        {
                            repo.AddLimsTmcTemp(limsTmc);
                        }
                    }
                }
                tmcRepo.Save();

                repo.Save();
            }

            return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
        }
예제 #13
0
        public static byte[]  CreateDocumentFromTmcLayout(IHostingEnvironment environment, Tmc tmc)
        {
            var template = new FileInfo(Path.Combine(environment.WebRootPath, "docs/tmc.dotx"));
            List <Tuple <string, string> > strings = new List <Tuple <string, string> >();

            strings.Add(new Tuple <string, string>("InventoryNumber", tmc.InventoryNumber.ToString()));
            strings.Add(new Tuple <string, string>("Name", tmc.Name));
            strings.Add(new Tuple <string, string>("Description", tmc.Description));
            strings.Add(new Tuple <string, string>("FactoryNumber", tmc.FactoryNumber.ToString()));
            strings.Add(new Tuple <string, string>("PurchaseDate", tmc.PurchaseDate.ToShortDateString()));
            strings.Add(new Tuple <string, string>("WriteOffDate", tmc.WriteOffDate.HasValue ? tmc.WriteOffDate.Value.ToShortDateString() : ""));
            strings.Add(new Tuple <string, string>("WarrantyDate", tmc.WarrantyDate.HasValue ? tmc.WarrantyDate.Value.ToShortDateString() : ""));
            strings.Add(new Tuple <string, string>("LastName", tmc.ResponsiblePerson.LastName));
            strings.Add(new Tuple <string, string>("FirstName", tmc.ResponsiblePerson.FirstName));
            strings.Add(new Tuple <string, string>("PersonnelNumber", tmc.ResponsiblePerson.PersonnelNumber.ToString()));
            strings.Add(new Tuple <string, string>("ActNumber", tmc.Act.ActNumber.ToString()));
            strings.Add(new Tuple <string, string>("Type", tmc.Type.Name));
            strings.Add(new Tuple <string, string>("RoomName", tmc.Room.Name));
            strings.Add(new Tuple <string, string>("ContractNumber", tmc.Act.Contract.ContractNumber.ToString()));
            return(CreateWordDocument(template, strings));
        }
        public async Task <IActionResult> Create([Bind("Id,InventoryNumber,Name,Description,TypeId,PurchaseDate,ResponsiblePersonId,FactoryNumber,WriteOffDate,RoomId,ActId,WarrantyDate")] Tmc tmc)
        {
            await _tmcs.AddAsync(tmc);

            return(RedirectToAction(nameof(Index)));
        }
예제 #15
0
        public ActionResult UpdateApplication([DataSourceRequest] DataSourceRequest request,
                                              TmcInView model)
        {
            if (model.Id == Guid.Empty)
            {
                model.Id = model.TmcInId;
            }

            ApplicationPoaRepository repo = new ApplicationPoaRepository(false);
            TmcIn d = repo.GetAsQuarable(o => o.Id == model.Id).FirstOrDefault();

            bool isContractChange = d.ContractNumber != model.ContractNumber;

            d.StateType            = model.StateType;
            d.ContractDate         = model.ContractDate;
            d.ContractNumber       = model.ContractNumber;
            d.IsFullDelivery       = model.IsFullDelivery;
            d.LastDeliveryDate     = model.LastDeliveryDate;
            d.OwnerEmployeeId      = model.OwnerEmployeeId;
            d.Provider             = model.Provider;
            d.ProviderBin          = model.ProviderBin;
            d.ExecutorEmployeeId   = model.ExecutorEmployeeId;
            d.AgreementEmployeeId  = model.AgreementEmployeeId;
            d.AccountantEmployeeId = model.AccountantEmployeeId;

            repo.Save();
            model = repo.GetTmcInViews(o => o.Id == d.Id).FirstOrDefault();
            if (isContractChange)
            {
                TmcRepository tmcRepo = new TmcRepository();

                tmcRepo.RemoveTmcByPoaId(model.Id);

                var dicRepo          = new DictionaryRepository(false);
                var contractProducts = tmcRepo.GetI1cLimsContractProducts(lc => lc.ContractNumber == d.ContractNumber);
                foreach (var prod in contractProducts.ToList())
                {
                    var measureId = dicRepo.GetDictionaryIdByTypeAndDisplayName(Dictionary.MeasureType.DicCode, prod.Unit);

                    var tmc = new Tmc()
                    {
                        Id                      = Guid.NewGuid(),
                        CreatedDate             = DateTime.Now,
                        CreatedEmployeeId       = UserHelper.GetCurrentEmployee().Id,
                        TmcInId                 = d.Id,
                        StateType               = 0,
                        Number                  = prod.ProductId,
                        Code                    = prod.ProductId,
                        Name                    = prod.Name,
                        Count                   = prod.QuantityVolume.Value,
                        CountActual             = prod.QuantityVolume.Value,
                        CountFact               = prod.QuantityVolume.Value,
                        CountConvert            = prod.QuantityVolume.Value,
                        MeasureTypeDicId        = measureId,
                        MeasureTypeConvertDicId = measureId
                    };
                    var tmcExist = tmcRepo.GetAsQuarable(t => t.Number == tmc.Number && t.CountFact < t.Count).FirstOrDefault();
                    if (tmcExist == null)
                    {
                        tmcRepo.Insert(tmc);

                        var limsTmc = new LimsTmcTemp()
                        {
                            TmcId        = tmc.Id,
                            TmcInId      = tmc.TmcInId,
                            CreatedDate  = DateTime.Now,
                            CountRequest = tmc.Count,
                            IsSelected   = false
                        };
                        repo.AddLimsTmcTemp(limsTmc);
                    }
                    else
                    {
                        var limsTmc = new LimsTmcTemp()
                        {
                            TmcId        = tmc.Id,
                            TmcInId      = tmc.TmcInId,
                            CreatedDate  = DateTime.Now,
                            CountRequest = prod.QuantityVolume.Value - tmcExist.CountFact,
                            IsSelected   = false
                        };
                        if (prod.QuantityVolume.Value - tmcExist.CountFact > 0)
                        {
                            repo.AddLimsTmcTemp(limsTmc);
                        }
                    }
                }
                tmcRepo.Save();

                repo.Save();
            }
            return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
        }
예제 #16
0
        public ActionResult UpdateRequestTake([DataSourceRequest] DataSourceRequest request,
                                              TmcInView dictionary)
        {
            if (dictionary.Id == Guid.Empty)
            {
                dictionary.Id = dictionary.TmcInId;
            }

            TmcIn d = db.TmcIns.First(o => o.Id == dictionary.Id);

            bool isContractChange = d.ContractNumber != dictionary.ContractNumber;

            d.StateType            = dictionary.StateType;
            d.ContractDate         = dictionary.ContractDate;
            d.ContractNumber       = dictionary.ContractNumber;
            d.IsFullDelivery       = dictionary.IsFullDelivery;
            d.LastDeliveryDate     = dictionary.LastDeliveryDate;
            d.OwnerEmployeeId      = dictionary.OwnerEmployeeId;
            d.Provider             = dictionary.Provider;
            d.ProviderBin          = dictionary.ProviderBin;
            d.ExecutorEmployeeId   = dictionary.ExecutorEmployeeId;
            d.AgreementEmployeeId  = dictionary.AgreementEmployeeId;
            d.AccountantEmployeeId = dictionary.AccountantEmployeeId;

            db.SaveChanges();
            dictionary = db.TmcInViews.First(o => o.Id == d.Id);
            if (isContractChange)
            {
                TmcRepository tmcRepo = new TmcRepository();

                tmcRepo.RemoveTmcByPoaId(dictionary.Id);

                var dicRepo          = new DictionaryRepository(false);
                var contractProducts = tmcRepo.GetI1cLimsContractProducts(lc => lc.ContractNumber == d.ContractNumber);
                foreach (var prod in contractProducts.ToList())
                {
                    var measureId = dicRepo.GetDictionaryIdByTypeAndDisplayName(Dictionary.MeasureType.DicCode, prod.Unit);

                    var t = new Tmc()
                    {
                        Id                      = Guid.NewGuid(),
                        CreatedDate             = DateTime.Now,
                        CreatedEmployeeId       = UserHelper.GetCurrentEmployee().Id,
                        TmcInId                 = d.Id,
                        StateType               = 0,
                        Number                  = prod.ProductId,
                        Code                    = prod.ProductId,
                        Name                    = prod.Name,
                        Count                   = prod.QuantityVolume.Value,
                        CountActual             = prod.QuantityVolume.Value,
                        CountFact               = prod.QuantityVolume.Value,
                        CountConvert            = prod.QuantityVolume.Value,
                        MeasureTypeDicId        = measureId,
                        MeasureTypeConvertDicId = measureId
                    };
                    tmcRepo.Insert(t);
                }
                tmcRepo.Save();
            }
            return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState)));
        }
예제 #17
0
        public ActionResult CreateRequestTake([DataSourceRequest] DataSourceRequest request, TmcInViewModel dictionary)
        {
            if (ModelState.IsValid)
            {
                TmcIn tmc = new TmcIn()
                {
                    Id                   = Guid.NewGuid(),
                    StateType            = dictionary.StateType,
                    ContractDate         = dictionary.ContractDate,
                    ContractNumber       = dictionary.ContractNumber,
                    CreatedDate          = DateTime.Now,
                    CreatedEmployeeId    = UserHelper.GetCurrentEmployee().Id,
                    IsFullDelivery       = dictionary.IsFullDelivery,
                    LastDeliveryDate     = dictionary.LastDeliveryDate,
                    OwnerEmployeeId      = dictionary.OwnerEmployeeId,
                    Provider             = dictionary.Provider,
                    ProviderBin          = dictionary.ProviderBin,
                    ExecutorEmployeeId   = dictionary.ExecutorEmployeeId,
                    AgreementEmployeeId  = dictionary.AgreementEmployeeId,
                    AccountantEmployeeId = dictionary.AccountantEmployeeId
                };
                db.TmcIns.Add(tmc);
                db.SaveChanges();
                var newDictionary = db.TmcInViews.First(o => o.Id == tmc.Id);
                dictionary.TmcInId                 = tmc.Id;
                dictionary.OwnerEmployeeValue      = newDictionary.OwnerEmployeeValue;
                dictionary.StateTypeValue          = newDictionary.StateTypeValue;
                dictionary.PowerOfAttorney         = newDictionary.PowerOfAttorney;
                dictionary.IsFullDeliveryValue     = newDictionary.IsFullDeliveryValue;
                dictionary.ExecutorEmployeeValue   = newDictionary.ExecutorEmployeeValue;
                dictionary.AgreementEmployeeValue  = newDictionary.AgreementEmployeeValue;
                dictionary.AccountantEmployeeValue = newDictionary.AccountantEmployeeValue;
                dictionary.Id = newDictionary.Id;


                TmcRepository tmcRepo          = new TmcRepository();
                var           dicRepo          = new DictionaryRepository(false);
                var           contractProducts = tmcRepo.GetI1cLimsContractProducts(lc => lc.ContractNumber == tmc.ContractNumber);
                foreach (var prod in contractProducts.ToList())
                {
                    var measureId = dicRepo.GetDictionaryIdByTypeAndDisplayName(Dictionary.MeasureType.DicCode, prod.Unit);

                    var t = new Tmc()
                    {
                        Id                      = Guid.NewGuid(),
                        CreatedDate             = DateTime.Now,
                        CreatedEmployeeId       = UserHelper.GetCurrentEmployee().Id,
                        TmcInId                 = tmc.Id,
                        StateType               = 0,
                        Number                  = prod.ProductId,
                        Code                    = prod.ProductId,
                        Name                    = prod.Name,
                        Count                   = prod.QuantityVolume.Value,
                        CountActual             = prod.QuantityVolume.Value,
                        CountFact               = prod.QuantityVolume.Value,
                        CountConvert            = prod.QuantityVolume.Value,
                        MeasureTypeDicId        = measureId,
                        MeasureTypeConvertDicId = measureId
                    };
                    tmcRepo.Insert(t);
                }
                tmcRepo.Save();
            }

            return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState)));
        }