Пример #1
0
 /// <summary>
 /// добавляем элемент в выходные данные, что бы в будущем их сохранить
 /// </summary>
 /// <param name="item"> добавляемый объект</param>
 public static bool AddToOutput(WorkTypeClass item)
 {
     if (!JSONSerializeService.Contains(item))
     {
         OutputItems.Add(item);
         return(true);
     }
     return(false);
 }
        private void AddWorkType(object sender, EventArgs e)
        {
            WorkTypeClass work = new WorkTypeClass();

            work.Article = WorkTypeNameInp.Text;
            work.setPriceFunc(formula.TextBox.Text);
            var numer = Listofparams.Items.GetEnumerator();

            while (numer.MoveNext())
            {
                work.parametrs.Add(numer.Current.ToString());
            }
            work.ParametersValue = new double[work.parametrs.Count];
            if (Category.SelectedIndex == -1)
            {
                MessageBox.Show("Выберите категорию!");
                return;
            }
            work.category = (WorkTypeClass.Category)(Category.SelectedIndex);
            if (DelegateAssemblyService.isCreatedCorrect(work))
            {
                if (RedactedItemIndex != null)
                {
                    JSONSerializeService.OutputItems.Remove(JSONSerializeService.OutputItems.Find(w => w.FullEquals(RedactedWork)));
                    JSONSerializeService.AddToOutput(work);
                    JSONSerializeService.Save();
                    WorksTypeTree.Edit(RedactedWork, work);
                    RedactedWork = null;
                }
                else
                {
                    JSONSerializeService.AddToOutput(work);
                    JSONSerializeService.Save();
                    work = JSONSerializeService.OutputItems.Find(w => w.FullEquals(work));
                    WorksTypeTree.AddtoList(work);
                }

                this.Hide();
            }
            else
            {
                MessageBox.Show("Параметры обьекта заданны некоректно.");
            }
        }
Пример #3
0
        public static Project LoadProject(string Path)
        {
            string  text = File.ReadAllText(Path);
            Project ret  = JsonConvert.DeserializeObject <Project>(text);

            foreach (Room r in ret.Rooms)
            {
                WorkTypeClass[] ar = r.CheckedWorks.ToArray();
                for (int i = 0; i < ar.Length; i++)
                {
                    if (!JSONSerializeService.getAlternate(ar[i]))
                    {
                        r.CheckedWorks.Remove(ar[i]);
                        ret.compatibility = false;
                    }
                }
            }
            ret.compatibility = true;
            return(ret);
        }