Пример #1
0
        private bool addCellToTable(string imei, string phoneNumber, int typeOfTest)
        {
            ItemTable itemForAdd = new ItemTable
            {
                IMEI        = imei,
                PhoneNumber = phoneNumber,
                TypeOfTest  = typeOfTest
            };

            dataGridView.Items.Add(itemForAdd);

            return(true);
        }
Пример #2
0
        private void doButton_Click(object sender, RoutedEventArgs e)
        {
            int itemsCount = dataGridView.Items.Count;

            if (itemsCount > 0)
            {
                var resultXmlFile   = File.OpenText(string.Format(pathToTemplateFile, 0));
                var textFromXmlFile = resultXmlFile.ReadToEnd();

                XmlDocument resultXmlDocument = new XmlDocument();
                resultXmlDocument.LoadXml(textFromXmlFile);

                XmlNode uilogNodeOriginal = resultXmlDocument.LastChild;
                XmlNode uilogNodeChanged  = resultXmlDocument.LastChild.Clone();

                string imei;
                string numPhone;
                int    typeOfTest;
                for (int i = 0; i < itemsCount; i++)
                {
                    ItemTable item = (ItemTable)dataGridView.Items[i];

                    imei       = item.IMEI;
                    numPhone   = item.PhoneNumber;
                    typeOfTest = item.TypeOfTest;

                    XmlComment comment = resultXmlDocument.CreateComment(i + 1 + " CHILD BEGIN | IMEI: " + imei + "; Phone Number: " + numPhone + "; Type Of Test: " + typeOfTest + ";");
                    uilogNodeChanged.InsertAfter(comment, uilogNodeChanged.LastChild);

                    getChildrenFromItemTable(ref resultXmlDocument, ref uilogNodeChanged, imei, numPhone, typeOfTest);

                    comment = resultXmlDocument.CreateComment(i + 1 + " CHILD END | IMEI: " + imei + "; Phone Number: " + numPhone + "; Type Of Test: " + typeOfTest + ";");
                    uilogNodeChanged.InsertAfter(comment, uilogNodeChanged.LastChild);
                }

                resultXmlDocument.ReplaceChild(uilogNodeChanged, uilogNodeOriginal);

                string pathToResultFile = System.Reflection.Assembly.GetExecutingAssembly().Location + "/../" + "/xmlOut/" + DateTime.Now.ToString("dd.MM.yyyy_HH.mm.ss") + ".txt";
                string outerXml         = resultXmlDocument.FirstChild.OuterXml + "\n" + XDocument.Parse(resultXmlDocument.OuterXml).ToString();

                File.WriteAllText(pathToResultFile, outerXml, Encoding.UTF8);

                ShowMetroMessageBox("Information", "Операция выполнена успешно.");
            }
            else
            {
                ShowMetroMessageBox("Error", "Пустая таблица. Введите данные в таблицу.");
            }
        }
Пример #3
0
        private void dataGridView_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            ItemTable selectedItem = (ItemTable)dataGridView.SelectedItem;

            if (selectedItem != null)
            {
                imei_textBox.Text     = selectedItem.IMEI.Clone().ToString();
                numPhone_textBox.Text = selectedItem.PhoneNumber.Clone().ToString();

                int typeOfTest = selectedItem.TypeOfTest;
                if (typeOfTest == 1)
                {
                    radioButton1.IsChecked = true;
                }
                else if (typeOfTest == 2)
                {
                    radioButton2.IsChecked = true;
                }
                else if (typeOfTest == 3)
                {
                    radioButton3.IsChecked = true;
                }
                else if (typeOfTest == 4)
                {
                    radioButton4.IsChecked = true;
                }
                else if (typeOfTest == 5)
                {
                    radioButton5.IsChecked = true;
                }
                else if (typeOfTest == 6)
                {
                    radioButton6.IsChecked = true;
                }
                else if (typeOfTest == 7)
                {
                    radioButton7.IsChecked = true;
                }
            }
        }
Пример #4
0
        private bool updateCellToTable(string imei, string phoneNumber, int typeOfTest)
        {
            ItemTable itemForAdd = new ItemTable
            {
                IMEI        = imei,
                PhoneNumber = phoneNumber,
                TypeOfTest  = typeOfTest
            };

            ItemTable selectedCell = (ItemTable)dataGridView.SelectedItem;

            if (selectedCell != null)
            {
                int index = dataGridView.Items.IndexOf(selectedCell);
                dataGridView.Items.RemoveAt(index);
                dataGridView.Items.Insert(index, itemForAdd);

                return(true);
            }

            return(false);
        }
Пример #5
0
        private bool isRepeatCells(string imei, string phoneNumber, int typeOfTest)
        {
            ItemTable itemForAdd = new ItemTable
            {
                IMEI        = imei,
                PhoneNumber = phoneNumber,
                TypeOfTest  = typeOfTest
            };

            foreach (ItemTable item in dataGridView.Items)
            {
                if (itemForAdd.IMEI.Contains(item.IMEI))
                {
                    return(true);
                }
                else if (itemForAdd.PhoneNumber.Contains(item.PhoneNumber))
                {
                    return(true);
                }
            }

            return(false);
        }