Example #1
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);
        }
Example #2
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(), "Ошибка");
         }
     });
 }
Example #3
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");
        }
        /// <summary>
        /// Добавление номенклатуры
        /// </summary>
        private void AddNomenclature()
        {
            var nomenclature = selectedFolder.AddNomenclature("Новая номенклатура");

            Nomenclatures.Add(nomenclature);
        }