Пример #1
0
        //удаляет выбранный объект учета
        public static void ToDeliteObject(string name, Main main, Customize customize, int e)
        {
            string[][] desposed    = WriteAndRead.GetArrayDll(name);
            string[][] newDesposed = new string[desposed.Length - 1][];

            //удаляем выбранный день
            for (int i = 0, j = 0; i < desposed.Length; i++)
            {
                if (i != e)
                {
                    newDesposed[j++] = desposed[i];
                }
                else
                {
                    j++;
                }
            }

            WriteAndRead.WriteDll(name, newDesposed);

            MessageBox.Show("Элемент успешно удален", "Сообщение", MessageBoxButton.OK, MessageBoxImage.Information);
            customize.Close();
        }
Пример #2
0
        //сохроняет измененные данные
        public static void ToCorrectOfData(string name, Main main, Customize customize, int e)
        {
            //инициализация данных
            string[][] desposed    = WriteAndRead.GetArrayDll(name);
            string     GS          = customize.tbGS.Text;
            string     type        = customize.cbType.Text;
            string     volume      = customize.tbVolume.Text;
            string     cost        = customize.tbCost.Text;
            string     consumption = customize.tbConsumption.Text;
            string     date        = customize.dpChooiceDate.DataContext.ToString();

            if (customize.dpChooiceDate.Text != DateTime.Parse(customize.dpChooiceDate.DataContext.ToString()).ToShortDateString())
            {
                date = customize.dpChooiceDate.Text + " 12:30";
            }
            string costLitr = null;
            string transit  = null;

            if (GS == "" || GS == null || GS == Resources.Get(Resources.Names.textGS))
            {
                GS = "Не указано";
            }


            else if (!Exam.NumericValidation(volume))
            {
                ;
            }
            else if (!Exam.NumericValidation(cost))
            {
                ;
            }
            else if (!Exam.NumericValidation(consumption))
            {
                ;
            }
            else if (!Exam.NamedExam(GS, "наименование АЗС", Resources.Get(Resources.Names.textGS)))
            {
                ;
            }

            else
            {
                customize.Close();

                if (
                    GS != customize.tbGS.DataContext.ToString() ||
                    volume != customize.tbVolume.DataContext.ToString() ||
                    cost != customize.tbCost.DataContext.ToString() ||
                    consumption != customize.tbConsumption.DataContext.ToString() ||
                    type != customize.cbType.DataContext.ToString() ||
                    date != DateTime.Parse(customize.dpChooiceDate.DataContext.ToString()).ToShortDateString() + " 12:30"
                    )
                {
                    costLitr = Calculate.GetCostLitr(volume, cost);
                    transit  = Calculate.GetTransit(consumption, volume);

                    //инициализируем массив данных
                    desposed[e] = new string[] { date, GS.Trim(' '), type, Formate(volume), Formate(cost, 2), Formate(consumption), Formate(costLitr), Formate(transit) };

                    //запись данных
                    desposed = Calculate.DesposedSort(desposed);
                    WriteAndRead.WriteDll(name, desposed);

                    DataUpdate(main);

                    MessageBox.Show("Данные успешно изменены", "Сообщение", MessageBoxButton.OK, MessageBoxImage.Information);
                }


                else
                {
                    MessageBox.Show("Были сохранены исходные данные", "Сообщение", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }

            customize.Close();
        }