Esempio n. 1
0
        public bool CheckHarmony()
        {
            bool check = true;

            foreach (Time time in Times)
            {
                if (!MachineTools.Exists((tool => tool.Id == time.MachineToolId)))
                {
                    Console.WriteLine($"MachineTool ID not exist: {time.MachineToolId}");

                    check = false;
                }

                if (!Nomenclatures.Exists((nomenclature => nomenclature.Id == time.NomenclatureId)))
                {
                    Console.WriteLine($"Nomenclature ID not exist: {time.NomenclatureId}");

                    check = false;
                }
            }

            foreach (Party party in Parties)
            {
                if (!Nomenclatures.Exists((nomenclature => nomenclature.Id == party.NomenclatureId)))
                {
                    Console.WriteLine($"Nomenclature ID not exist: {party.NomenclatureId}");

                    check = false;
                }
            }

            return(check);
        }
Esempio n. 2
0
        public static Nomenclatures Convert(this NomenclatureDTO nomenclatureDto)
        {
            var nom = new Nomenclatures
            {
                ItemId      = nomenclatureDto.ItemId,
                IsDeleted   = nomenclatureDto.IsDeleted,
                Updated     = nomenclatureDto.Updated,
                CorrectorId = nomenclatureDto.CorrectorId,
                ShortName   = nomenclatureDto.Name,
                FullName    = nomenclatureDto.FullName,
            };

            var department = nomenclatureDto.Department?.Convert();

            if (department != null)
            {
                nom.Department = department.IsDeleted ? Department.Unknown : department;
            }
            else
            {
                nom.Department = Department.Unknown;
            }

            return(nom);
        }
Esempio n. 3
0
        private bool ReadDataNomenclatures()
        {
            using (ExcelPackage xlPackage = new ExcelPackage(new FileInfo(PathData.Nomenclatures)))
            {
                ExcelWorksheet myWorksheet  = xlPackage.Workbook.Worksheets.First();
                int            totalRows    = myWorksheet.Dimension.End.Row;
                int            totalColumns = myWorksheet.Dimension.End.Column;

                for (int row = Nomenclature.StartDataRow; row <= totalRows; row++)
                {
                    string strId           = myWorksheet.GetValue(row, 1).ToString();
                    string strNomenclature = myWorksheet.GetValue(row, 2).ToString();

                    if (!CheckId(strId))
                    {
                        return(false);
                    }

                    int    id           = int.Parse(strId);
                    string nomenclature = strNomenclature;

                    if (Nomenclatures.Exists((n => n.Id == id)))
                    {
                        return(false);
                    }

                    Nomenclatures.Add(new Nomenclature(id, nomenclature));
                }
            }

            return(true);
        }
Esempio n. 4
0
        /// <summary>
        /// Поиск номенклатур по имени
        /// </summary>
        /// <param name="name">Искомое имя</param>
        /// <param name="option">Опции поиска</param>
        /// <returns>Коллекция найденных номенклатур</returns>
        public IEnumerable <Nomenclature> GetNomenclaturesByName(string name, CatalogSearchOption option)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            var nomenclatures = Enumerable.Empty <Nomenclature>();

            switch (option)
            {
            case CatalogSearchOption.Equals:
                nomenclatures = Nomenclatures.Where(n => n.Name.Equals(name));
                break;

            case CatalogSearchOption.Contains:
                nomenclatures = Nomenclatures.Where(n => n.Name.Contains(name));
                break;

            case CatalogSearchOption.StartsWith:
                nomenclatures = Nomenclatures.Where(n => n.Name.StartsWith(name));
                break;

            case CatalogSearchOption.EndsWith:
                nomenclatures = Nomenclatures.Where(n => n.Name.EndsWith(name));
                break;

            default:
                break;
            }

            return(nomenclatures);
        }
        public NomenclaturesResponse Post(Nomenclatures request)
        {
            if (request.Nomenclature.Id > 0)
              {
            Bm2s.Data.Common.BLL.Article.Nomenclature item = Datas.Instance.DataStorage.Nomenclatures[request.Nomenclature.Id];
            item.ArticleChildId = request.Nomenclature.ArticleChild.Id;
            item.ArticleParentId = request.Nomenclature.ArticleParent.Id;
            item.BuyPrice = Convert.ToDouble(request.Nomenclature.BuyPrice);
            item.EndingDate = request.Nomenclature.EndingDate;
            item.QuantityChild = request.Nomenclature.QuantityChild;
            item.StartingDate = request.Nomenclature.StartingDate;
            Datas.Instance.DataStorage.Nomenclatures[request.Nomenclature.Id] = item;
              }
              else
              {
            Bm2s.Data.Common.BLL.Article.Nomenclature item = new Data.Common.BLL.Article.Nomenclature()
            {
              ArticleChildId = request.Nomenclature.ArticleChild.Id,
              ArticleParentId = request.Nomenclature.ArticleParent.Id,
              BuyPrice = Convert.ToDouble(request.Nomenclature.BuyPrice),
              EndingDate = request.Nomenclature.EndingDate,
              QuantityChild = request.Nomenclature.QuantityChild,
              StartingDate = request.Nomenclature.StartingDate
            };

            Datas.Instance.DataStorage.Nomenclatures.Add(item);
            request.Nomenclature.Id = item.Id;
              }

              NomenclaturesResponse response = new NomenclaturesResponse();
              response.Nomenclatures.Add(request.Nomenclature);
              return response;
        }
Esempio n. 6
0
        public void DeleteNomenclature()
        {
            var firstNomenclature = new Nomenclatures
            {
                FullName   = "firstNomenclature",
                ShortName  = "firstNomenclature",
                Department = new Department
                {
                    FullName  = "firstDepartment",
                    ShortName = "firstDepartment"
                }
            };

            var enviroment = GetEnviroment();

            enviroment.NewKeeper.Save(firstNomenclature);

            var res = enviroment.NewLoader.GetObjectListAll <NomenclatureDTO, Nomenclatures>(new Filter("FullName", firstNomenclature.FullName));

            enviroment.NewKeeper.Delete(firstNomenclature);
            Assert.AreEqual(1, res.Count);

            res = enviroment.NewLoader.GetObjectListAll <NomenclatureDTO, Nomenclatures>(new Filter("FullName", firstNomenclature.FullName));
            Assert.AreEqual(0, res.Count);
        }
 public virtual void AddNomeclature(Nomenclature nomenclature)
 {
     if (Nomenclatures.Any(p => DomainHelper.EqualDomainObjects(p, nomenclature)))
     {
         logger.Warn("Номеклатура уже добавлена. Пропускаем...");
         return;
     }
     ObservableNomenclatures.Add(nomenclature);
 }
        public NomenclaturesResponse Delete(Nomenclatures request)
        {
            Bm2s.Data.Common.BLL.Article.Nomenclature item = Datas.Instance.DataStorage.Nomenclatures[request.Nomenclature.Id];
              item.EndingDate = DateTime.Now;
              Datas.Instance.DataStorage.Nomenclatures[item.Id] = item;

              NomenclaturesResponse response = new NomenclaturesResponse();
              response.Nomenclatures.Add(request.Nomenclature);
              return response;
        }
Esempio n. 9
0
    //Создает описание машины из полученых данных для удобства пользователя
    protected string createDiscription(string ovenId)
    {
        string str = "Печь обрабатывает: ";

        for (int i = 0; i < this.materialsTimes.Count; i++)
        {
            str += $" {Nomenclatures.viewMaterialById(materialsTimes[i][1])} за {materialsTimes[i][2]} минут";
        }
        if (str != "Печь обрабатывает: ")
        {
            return(str);
        }
        throw new NomenclaturesException("Не удалось составить описания для печи!");
    }
Esempio n. 10
0
 public static NomenclatureDTO Convert(this Nomenclatures nomenclature)
 {
     return(new NomenclatureDTO
     {
         ItemId = nomenclature.ItemId,
         IsDeleted = nomenclature.IsDeleted,
         Updated = nomenclature.Updated,
         CorrectorId = nomenclature.CorrectorId,
         Name = nomenclature.ShortName,
         FullName = nomenclature.FullName,
         DepartmentId = nomenclature.Department?.ItemId ?? -1,
         Department = nomenclature.Department?.Convert()
     });
 }
Esempio n. 11
0
        public void UpdateNomenclature()
        {
            var firstDepartment = new Department
            {
                FullName  = "firstDepartment",
                ShortName = "firstDepartment"
            };

            var firstNomenclature = new Nomenclatures
            {
                FullName   = "firstNomenclature",
                ShortName  = "firstNomenclature",
                Department = firstDepartment
            };

            var enviroment = GetEnviroment();

            enviroment.NewKeeper.Save(firstDepartment);
            enviroment.NewKeeper.Save(firstNomenclature);

            var res = enviroment.NewLoader.GetObjectListAll <NomenclatureDTO, Nomenclatures>(new Filter("FullName", firstNomenclature.FullName));

            Assert.AreEqual(1, res.Count);

            var forCheckFirst = res[0];

            Assert.IsTrue(forCheckFirst.ItemId > 0, "Id не может быть меньше нуля");
            Assert.IsFalse(forCheckFirst.IsDeleted, "IsDelete не должен быть true");
            Assert.AreEqual("firstNomenclature", forCheckFirst.FullName);
            Assert.AreEqual("firstNomenclature", forCheckFirst.ShortName);


            firstNomenclature.FullName = "Updated";
            enviroment.NewKeeper.Save(firstNomenclature);

            res = enviroment.NewLoader.GetObjectListAll <NomenclatureDTO, Nomenclatures>(new Filter("ItemId", forCheckFirst.ItemId));

            enviroment.NewKeeper.Delete(firstNomenclature);
            enviroment.NewKeeper.Delete(firstDepartment);

            Assert.AreEqual(1, res.Count);

            forCheckFirst = res[0];

            Assert.IsTrue(forCheckFirst.ItemId > 0, "Id не может быть меньше нуля");
            Assert.IsFalse(forCheckFirst.IsDeleted, "IsDelete не должен быть true");
            Assert.AreEqual("Updated", forCheckFirst.FullName);
            Assert.AreEqual("firstNomenclature", forCheckFirst.ShortName);
        }
        public NomenclaturesResponse Get(Nomenclatures request)
        {
            NomenclaturesResponse response = new NomenclaturesResponse();
              List<Bm2s.Data.Common.BLL.Article.Nomenclature> items = new List<Data.Common.BLL.Article.Nomenclature>();
              if (!request.Ids.Any())
              {
            items.AddRange(Datas.Instance.DataStorage.Nomenclatures.Where(item =>
              (request.ArticleId == 0 || item.ArticleChildId == request.ArticleId || item.ArticleParentId == request.ArticleId) &&
              (!request.Date.HasValue || (request.Date >= item.StartingDate && (!item.EndingDate.HasValue || request.Date < item.EndingDate.Value)))
              ));
              }
              else
              {
            items.AddRange(Datas.Instance.DataStorage.Nomenclatures.Where(item => request.Ids.Contains(item.Id)));
              }

              var collection = (from item in items
                        select new Bm2s.Poco.Common.Article.Nomenclature()
                        {
                          ArticleChild = new ArticlesService().Get(new Articles() { Ids = new List<int>() { item.ArticleChildId } }).Articles.FirstOrDefault(),
                          ArticleParent = new ArticlesService().Get(new Articles() { Ids = new List<int>() { item.ArticleParentId } }).Articles.FirstOrDefault(),
                          BuyPrice = Convert.ToDecimal(item.BuyPrice),
                          Id = item.Id,
                          QuantityChild = item.QuantityChild,
                        }).AsQueryable().OrderBy(request.Order, !request.DescendingOrder);

              response.ItemsCount = collection.Count();
              if (request.PageSize > 0)
              {
            response.Nomenclatures.AddRange(collection.Skip((request.CurrentPage - 1) * request.PageSize).Take(request.PageSize));
              }
              else
              {
            response.Nomenclatures.AddRange(collection);
              }

              try
              {
            response.PagesCount = collection.Count() / response.Nomenclatures.Count + (collection.Count() % response.Nomenclatures.Count > 0 ? 1 : 0);
              }
              catch
              {
            response.PagesCount = 1;
              }

              return response;
        }
Esempio n. 13
0
        public void DeleteNomenclature(Nomenclature nomenclature)
        {
            Dictionary <string, string> param = new Dictionary <string, string>();

            param.Add("id", nomenclature.id_nomenclature.ToString());
            ApiHelper.APIRequest(ValuesHelper.API_URL, ValuesHelper.API_NOMENCLATURE, ValuesHelper.API_DELETE, t =>
            {
                var d = JsonConvert.DeserializeObject <Message <Nomenclature> >(t);
                if (d.status.Contains("success"))
                {
                    Nomenclatures.Remove(nomenclature);
                }
                else
                {
                    MessageBox.Show(d.reason.ToString(), "Ошибка");
                }
            }, param, "post");
        }
Esempio n. 14
0
 public void GetNomenctlatures()
 {
     ApiHelper.APIRequest(ValuesHelper.API_URL, ValuesHelper.API_NOMENCLATURE, null, t =>
     {
         var d = JsonConvert.DeserializeObject <Message <Nomenclature> >(t);
         if (d.status.Contains("success"))
         {
             if (d.data != null)
             {
                 foreach (var nomenclature in d.data)
                 {
                     Nomenclatures.Add((Nomenclature)nomenclature.Clone());
                 }
             }
         }
         else
         {
             MessageBox.Show(d.reason.ToString(), "Ошибка");
         }
     });
 }
Esempio n. 15
0
        public void AddOrUpdateNomenclature(Nomenclature nomenclature, Mode mode)
        {
            Dictionary <string, string> param = new Dictionary <string, string>();
            int pos = 0;

            if (mode == Mode.Update)
            {
                pos = Nomenclatures.IndexOf(SelectedNomenclature);
                param.Add("id", nomenclature.id_nomenclature.ToString());
            }

            param.Add("name", nomenclature.name);
            param.Add("price", nomenclature.price.ToString("0.##"));
            param.Add("from_date", nomenclature.fromDate.ToString("yyyy-MM-dd HH:mm",
                                                                  System.Globalization.CultureInfo.InvariantCulture));
            param.Add("to_date", nomenclature.toDate.ToString("yyyy-MM-dd HH:mm",
                                                              System.Globalization.CultureInfo.InvariantCulture));
            ApiHelper.APIRequest(ValuesHelper.API_URL, ValuesHelper.API_NOMENCLATURE, mode == Mode.Add ? ValuesHelper.API_ADD : ValuesHelper.API_UPDATE, t =>
            {
                var d = JsonConvert.DeserializeObject <Message <Nomenclature> >(t);
                if (d.status.Contains("success"))
                {
                    if (mode == Mode.Add)
                    {
                        Nomenclatures.Add((Nomenclature)d.data.FirstOrDefault()?.Clone());
                    }
                    else
                    {
                        Nomenclatures.RemoveAt(pos);
                        Nomenclatures.Insert(pos, (Nomenclature)d.data.FirstOrDefault()?.Clone());
                    }
                }
                else
                {
                    MessageBox.Show(d.reason.ToString(), "Ошибка");
                }
            }, param, "post");
        }
Esempio n. 16
0
        /// <summary>
        /// Поиск номенклатуры по имени
        /// </summary>
        /// <param name="name">Искомое имя</param>
        /// <returns>Найденная номенклатура</returns>
        public Nomenclature GetNomenclatureByName(string name)
        {
            var nomenclature = Nomenclatures.SingleOrDefault(n => n.Name.Equals(name));

            return(nomenclature);
        }
Esempio n. 17
0
 public void AddPriceList(PriceList priceList)
 {
     Nomenclatures.AddRange(priceList.Nomenclature);
 }
Esempio n. 18
0
 /// <summary>
 /// Получение номенклатуры по идентификатору
 /// </summary>
 /// <param name="id">Искомый идентификатор номенклатуры</param>
 /// <returns></returns>
 public Nomenclature GetNomenclatureById(int id)
 {
     return(Nomenclatures.SingleOrDefault(n => n.Id == id));
 }
Esempio n. 19
0
 /// <summary>
 /// Проверки наименования номенклатуры на дубликат
 /// </summary>
 /// <param name="name">Проверяемое имя</param>
 /// <returns></returns>
 internal bool IsNomenclatureNameExists(string name)
 {
     return(Nomenclatures.Any(n => n.Name.Equals(name)));
 }
Esempio n. 20
0
        /// <summary>
        /// Добавление номенклатуры
        /// </summary>
        private void AddNomenclature()
        {
            var nomenclature = selectedFolder.AddNomenclature("Новая номенклатура");

            Nomenclatures.Add(nomenclature);
        }
Esempio n. 21
0
        public void InsertAndLoadDocument()
        {
            var aboard                = true;
            var issueDateValidFrom    = new DateTime(2013, 11, 11);
            var issueDateValidTo      = new DateTime(2013, 12, 12);
            var issueNotify           = 5;
            var issueValidTo          = true;
            var revisionDateValidFrom = new DateTime(2014, 11, 11);
            var revisionDateValidTo   = new DateTime(2014, 12, 12);
            var revisioNotify         = 1;
            var revisioValidTo        = false;
            var prolongationWay       = ProlongationWay.Manually;



            var nomenclature = new Nomenclatures
            {
                FullName   = "TestDocument",
                Department = Department.Unknown
            };

            var department = new Department
            {
                FullName = "TestDocument"
            };

            var serciceType = new ServiceType
            {
                FullName  = "TestDocument",
                ShortName = "TestDocument"
            };

            var document = new Document
            {
                Aboard              = aboard,
                IssueDateValidFrom  = issueDateValidFrom,
                IssueDateValidTo    = issueDateValidTo,
                IssueNotify         = issueNotify,
                IssueValidTo        = issueValidTo,
                RevisionDateFrom    = revisionDateValidFrom,
                RevisionDateValidTo = revisionDateValidTo,
                RevisionNotify      = revisioNotify,
                RevisionValidTo     = revisioValidTo,
                Nomenсlature        = nomenclature,
                Department          = department,
                ServiceType         = serciceType,
                ProlongationWay     = prolongationWay,
                DocumentSubType     = DocumentSubType.Unknown
            };

            var enviroment = GetEnviroment();

            enviroment.NewKeeper.Save(nomenclature);
            enviroment.NewKeeper.Save(department);
            enviroment.NewKeeper.Save(serciceType);
            enviroment.NewKeeper.Save(document);

            var forCheckDocument = enviroment.NewLoader.GetObjectListAll <DocumentDTO, Document>(new Filter("ItemId", document.ItemId), true).SingleOrDefault();

            enviroment.NewKeeper.Delete(nomenclature);
            enviroment.NewKeeper.Delete(department);
            enviroment.NewKeeper.Delete(serciceType);
            enviroment.NewKeeper.Delete(document);

            Assert.IsTrue(forCheckDocument != null, "forCheckDocument не должен быть пустым");
            Assert.AreEqual(aboard, forCheckDocument.Aboard);
            Assert.AreEqual(issueDateValidFrom, forCheckDocument.IssueDateValidFrom);
            Assert.AreEqual(issueDateValidTo, forCheckDocument.IssueDateValidTo);
            Assert.AreEqual(issueNotify, forCheckDocument.IssueNotify);
            Assert.AreEqual(issueValidTo, forCheckDocument.IssueValidTo);
            Assert.AreEqual(revisionDateValidFrom, forCheckDocument.RevisionDateFrom);
            Assert.AreEqual(revisionDateValidTo, forCheckDocument.RevisionDateValidTo);
            Assert.AreEqual(revisioNotify, forCheckDocument.RevisionNotify);
            Assert.AreEqual(revisioValidTo, forCheckDocument.RevisionValidTo);
            Assert.AreEqual(prolongationWay, forCheckDocument.ProlongationWay);

            Assert.IsTrue(forCheckDocument.Nomenсlature != null, "Nomenсlature не должен быть пустым");
            Assert.AreEqual("TestDocument", forCheckDocument.Nomenсlature.FullName);

            Assert.IsTrue(forCheckDocument.Department != null, "Department не должен быть пустым");
            Assert.AreEqual("TestDocument", forCheckDocument.Department.FullName);

            Assert.IsTrue(forCheckDocument.ServiceType != null, "ServiceType не должен быть пустым");
            Assert.AreEqual("TestDocument", forCheckDocument.ServiceType.FullName);
        }