Esempio n. 1
0
        private Storage getStorageForWorkerNorma(NormaContent normaContent, Worker worker)
        //private Storage getStorageForWorkerNorma(NormaContent normaContent, IList<NomBodyPartSize> NomBodyPartSizes)
        {
            //Storage storage = null;
            List <Storage>  storages           = null;
            NomBodyPart     normaBodyPart      = normaContent.NomGroup.NomBodyPart;
            NomBodyPartSize workerBodyPartSize = null;

            foreach (var item in worker.NomBodyPartSizes)
            //foreach (var item in NomBodyPartSizes)
            {
                if (item.NomBodyPart.Id == normaBodyPart.Id)
                {
                    workerBodyPartSize = item;
                    break;
                }
            }

            Dictionary <string, object> query = new Dictionary <string, object>();

            query.Add("StorageName.Organization.Id", int.Parse(getCurrentEnterpriseId()));
            query.Add("Nomenclature.NomGroup.Id", normaContent.NomGroup.Id);
            query.Add("NomBodyPartSize.NomBodyPart.Id", normaBodyPart.Id);
            if (workerBodyPartSize != null && DataGlobals.SIZ_SIZE_ID != normaBodyPart.Id)
            {
                query.Add("NomBodyPartSize.SizeNumber", workerBodyPartSize.SizeNumber);
            }
            if (DataGlobals.CLOTH_SIZE_ID == normaBodyPart.Id)
            {
                query.Add("Growth.SizeNumber", worker.Growth);
            }
            storages = (List <Storage>)storageRepository.GetByCriteria(query);

            if (storages == null || storages.Count == 0)
            {
                query.Clear();
                query.Add("StorageName.Organization.Id", int.Parse(getCurrentEnterpriseId()));
                foreach (var normaNomGroup in normaContent.NormaNomGroups)
                {
                    query.Add("Nomenclature.NomGroup.Id", normaNomGroup.NomGroup.Id);
                    storages.AddRange(storageRepository.GetByLikeCriteria(query));
                    query.Remove("Nomenclature.NomGroup.Id");
                }
            }

            if (storages == null || storages.Count == 0)
            {
                storages.Add(new Storage());
            }

            return(storages[0]);
        }
Esempio n. 2
0
        public ActionResult Copy(string Id)
        {
            Norma norma    = normaRepository.Get(int.Parse(Id));
            Norma newNorma = new Norma();

            newNorma.Organization = norma.Organization;
            newNorma.Name         = norma.Name + " (Копия)";
            newNorma.IsActive     = norma.IsActive;
            newNorma.NormaComment = norma.NormaComment;
            normaRepository.SaveOrUpdate(newNorma);

            Dictionary <string, object> queryParams = new Dictionary <string, object>();

            queryParams.Add("NormaId", int.Parse(Id));
            queryParams.Add("IsActive", true);
            Dictionary <string, object> orderParams = new Dictionary <string, object>();

            orderParams.Add("Id", ASC);
            IEnumerable <NormaContent> normaContents = normaContentRepository.GetByCriteria(queryParams, orderParams);

            foreach (var item in normaContents)
            {
                NormaContent nc = new NormaContent();
                nc.Quantity    = item.Quantity;
                nc.QuantityTON = item.QuantityTON;
                nc.UsePeriod   = item.UsePeriod;
                nc.IsActive    = item.IsActive;
                nc.NormaId     = newNorma.Id;
                nc.NomGroup    = item.NomGroup;
                nc.InShop      = item.InShop;
                normaContentRepository.SaveOrUpdate(nc);
                foreach (var nng in item.NormaNomGroups)
                {
                    NomGroup     nomGroup = new NomGroup(nng.NomGroup.Id, nng.NomGroup.Name);
                    NomBodyPart  nb       = new NomBodyPart(nng.NomGroup.NomBodyPart.Id, nng.NomGroup.NomBodyPart.Name);
                    Organization o        = rebuildOrganization(nng.NomGroup.Organization);
                    nomGroup.Organization = o;
                    nomGroup.NomBodyPart  = nb;
                    NormaNomGroup ng = new NormaNomGroup();
                    ng.NomGroup     = nomGroup;
                    ng.IsBase       = nng.IsBase;
                    ng.NormaContent = nc;

                    normaNomGroupRepository.SaveOrUpdate(ng);
                }
            }
            ;
            return(View(viewName));
//            return _SelectionClientSide_Normas();
        }
Esempio n. 3
0
        private ActionResult getAllAndView()
        {
            IList <NomBodyPart> nomBodyPart = nombodyPartRepository.GetAll();
            IList <NomBodyPart> model       = new List <NomBodyPart>();

            foreach (var item in nomBodyPart)
            {
                NomBodyPart nbp = rebuildNomBodyPart(item);
                model.Add(nbp);
            }
            ;

            return(View(new GridModel(model)));
        }
Esempio n. 4
0
        public static NomBodyPart rebuildNomBodyPart(NomBodyPart inNomBodyPart)
        {
            NomBodyPart nb = new NomBodyPart(inNomBodyPart.Id, inNomBodyPart.Name);

            return(nb);
        }
Esempio n. 5
0
 public ActionResult Delete(NomBodyPart nombodyPart)
 {
     nombodyPartRepository.Delete(nombodyPart);
     return(getAllAndView());
 }
Esempio n. 6
0
 public ActionResult Save(NomBodyPart nombodyPart)
 {
     nombodyPartRepository.SaveOrUpdate(nombodyPart);
     return(getAllAndView());
 }