Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Xml;
- using System.Xml.Linq;
- using System.IO;
- using iTextSharp.text;
- using iTextSharp.text.pdf;
- using Excel = Microsoft.Office.Interop.Excel;
- using Word = Microsoft.Office.Interop.Word;
- namespace Labo5NIKITA_2
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- XDocument mydoc = new XDocument(new XElement("Labo5NIKITA"));
- mydoc.Save("Labo5NIKITA.xml");
- загрузитьДанныеИзXmlФайлаToolStripMenuItem.Enabled = false;
- загрузитьДанныеИзXmlФайлаToolStripMenuItem.ToolTipText = "Кнопка будет разблокирована после сохранения txt в xml!";
- listBox1.Focus();
- textBox1.ReadOnly = true;
- textBox2.ReadOnly = true;
- textBox3.ReadOnly = true;
- textBox4.ReadOnly = true;
- textBox5.Visible = false;
- label6.Visible = false;
- button1.Visible = false;
- }
- //Сохраняет данные из txt в xml
- private void СохранениеДанныхИзТекстовогоФайлаВXmlФайлToolStripMenuItem_Click(object sender, EventArgs e)
- {
- XDocument mydoc = new XDocument(new XElement("Labo5NIKITA"));
- mydoc.Save("Labo5NIKITA.xml");
- XElement myelement = mydoc.Element("Labo5NIKITA");
- try
- {
- string text = "";
- string[] print = File.ReadAllLines("Sickleave.txt", Encoding.GetEncoding(1251));
- bool number = false;
- for (int i = 0; i < print.Count(); i++)
- {
- text = print[i];
- string[] wd = text.Split(' ');
- if (wd.Count() > 6)
- {
- //Проверка фамилии на содержание только букв
- try
- {
- foreach (char ch in wd[0])
- {
- if (ch >= '0' && ch <= '9')
- {
- number = true;
- }
- }
- if (number)
- {
- wd[0] = "Неверные данные";
- }
- }
- catch
- {
- wd[0] = "Неверные данные";
- }
- //Проверка имени на содержание только букв
- try
- {
- foreach (char ch in wd[1])
- {
- if (ch >= '0' && ch <= '9')
- {
- number = true;
- }
- }
- if (number)
- {
- wd[1] = "Неверные данные";
- }
- }
- catch
- {
- wd[1] = "Неверные данные";
- }
- //Проверка отчества на содержание только букв
- try
- {
- foreach (char ch in wd[2])
- {
- if (ch >= '0' && ch <= '9')
- {
- number = true;
- }
- }
- if (number)
- {
- wd[2] = "Неверные данные";
- }
- }
- catch
- {
- wd[2] = "Неверные данные";
- }
- //Проверка сопоставления дат(дата посещения врача не может быть ранее даты рождения)
- try
- {
- if (Convert.ToDateTime(wd[4]) < Convert.ToDateTime(wd[3]))
- {
- wd[3] = "Неверные данные";
- wd[4] = "Неверные данные";
- }
- }
- catch
- {
- wd[3] = "Неверные данные";
- wd[4] = "Неверные данные";
- }
- //Проверка диагноза на содержание только букв
- try
- {
- foreach (char ch in wd[5])
- {
- if (ch >= '0' && ch <= '9')
- {
- number = true;
- }
- }
- if (number)
- {
- wd[5] = "Неверные данные";
- }
- }
- catch
- {
- wd[5] = "Неверные данные";
- }
- //Проверка пола на содержание только букв
- try
- {
- foreach (char ch in wd[6])
- {
- if (ch >= '0' && ch <= '9')
- {
- number = true;
- }
- }
- if (number)
- {
- wd[6] = "Неверные данные";
- }
- }
- catch
- {
- wd[6] = "Неверные данные";
- }
- myelement.Add(new XElement("Больничная_запись", new XAttribute("ФИО", wd[0] + "_" + wd[1] + "_" + wd[2]), new XElement("Дата_рождения", wd[3]), new XElement("Дата_обращения_к_доктору", wd[4]), new XElement("Диагноз", wd[5]), new XElement("Пол", wd[6])));
- mydoc.Save("Labo5NIKITA.xml");
- }
- else
- {
- MessageBox.Show("Одна из строк документа содержит неверные данные! Эта строка не будет сохранена!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- MessageBox.Show("Сохранение прошло успешно!", "Выполнено!", MessageBoxButtons.OK, MessageBoxIcon.Information);
- загрузитьДанныеИзXmlФайлаToolStripMenuItem.Enabled = true;
- загрузитьДанныеИзXmlФайлаToolStripMenuItem.ToolTipText = "Загружает xml на форму";
- }
- catch (Exception error)
- {
- MessageBox.Show("Ошибка:\n" + error.Message, "Ошибка записи", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- //Загрузка данных из xml на форму
- private void ЗагрузитьДанныеИзXmlФайлаToolStripMenuItem_Click(object sender, EventArgs e)
- {
- try
- {
- XDocument mydoc = XDocument.Load("Labo5NIKITA.xml");
- XElement myelement = mydoc.Element("Labo5NIKITA");
- foreach (XElement elements in myelement.Elements("Больничная_запись").ToList())
- {
- listBox1.Items.Add(elements.Attribute("ФИО").Value);
- }
- listBox1.SelectedIndex = 0;
- MessageBox.Show("Запись прошла успешно!", "Выполнено!", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- catch (Exception error)
- {
- MessageBox.Show("Ошибка:\n" + error.Message, "Ошибка записи!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- //Отображение данных из xml в textbox`ы
- private void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- try
- {
- XDocument mydoc = XDocument.Load("Labo5NIKITA.xml");
- XElement myelement = mydoc.Element("Labo5NIKITA");
- int count = -1;
- foreach (XElement elements in myelement.Elements("Больничная_запись").ToList())
- {
- count++;
- if (count == listBox1.SelectedIndex)
- {
- textBox1.Text = elements.Element("Дата_рождения").Value;
- textBox2.Text = elements.Element("Дата_обращения_к_доктору").Value;
- textBox3.Text = elements.Element("Диагноз").Value;
- textBox4.Text = elements.Element("Пол").Value;
- textBox5.Text = elements.Attribute("ФИО").Value;
- break;
- }
- }
- }
- catch (Exception error)
- {
- MessageBox.Show("Ошибка:\n" + error.Message, "Ошибка чтения файла!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- //Удаление элемента через contextmenustrip
- private void УдалитьToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if (File.Exists("Labo5NIKITA.xml"))
- {
- XDocument mydoc = XDocument.Load("Labo5NIKITA.xml");
- XElement myelement = mydoc.Element("Labo5NIKITA");
- int count = -1;
- try
- {
- if (listBox1.Items.Count != 0)
- {
- foreach (XElement elements in myelement.Elements("Больничная_запись").ToList())
- {
- count++;
- if (count != listBox1.SelectedIndex)
- {
- elements.Remove();
- listBox1.Items.RemoveAt(listBox1.SelectedIndices[0]);
- textBox1.Text = "";
- textBox2.Text = "";
- textBox3.Text = "";
- textBox4.Text = "";
- mydoc.Save("Labo5NIKITA.xml");
- MessageBox.Show("Удаление элемента прошло успешно!", "Выполнено!", MessageBoxButtons.OK, MessageBoxIcon.Information);
- break;
- }
- }
- }
- else
- {
- MessageBox.Show("Нет элементов!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- catch (Exception error)
- {
- MessageBox.Show("Ошибка:" + error.Message, "Ошибка чтения файла!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- else
- {
- MessageBox.Show("Файл - Labo5NIKITA.xml - не существует!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- //Добавление элемента через contextmenustrip
- private void ToolStripTextBox1_KeyPress(object sender, KeyPressEventArgs e)
- {
- bool number = false;
- if (e.KeyChar == (char)Keys.Enter)
- {
- if (toolStripTextBox1.TextLength != 0)
- {
- string[] wd = toolStripTextBox1.Text.Split(' ');
- if (wd.Count() > 4)
- {
- try
- {
- if (wd.Count() > 6)
- {
- try
- {
- //Проверка первого слова на содержание только букв
- foreach (char ch in wd[0])
- {
- if (ch >= '0' && ch <= '9')
- {
- number = true;
- }
- }
- if (number)
- {
- wd[0] = "Неверные данные";
- }
- }
- catch
- {
- wd[0] = "Неверные данные";
- }
- //Проверка имени на содержание только букв
- try
- {
- foreach (char ch in wd[1])
- {
- if (ch >= '0' && ch <= '9')
- {
- number = true;
- }
- }
- if (number)
- {
- wd[1] = "Неверные данные";
- }
- }
- catch
- {
- wd[1] = "Неверные данные";
- }
- //Проверка отчества на содержание только букв
- try
- {
- foreach (char ch in wd[2])
- {
- if (ch >= '0' && ch <= '9')
- {
- number = true;
- }
- }
- if (number)
- {
- wd[2] = "Неверные данные";
- }
- }
- catch
- {
- wd[2] = "Неверные данные";
- }
- //Проверка сопоставления дат(дата посещения врача не может быть ранее даты рождения)
- try
- {
- if (Convert.ToDateTime(wd[4]) < Convert.ToDateTime(wd[3]))
- {
- wd[3] = "Неверные данные";
- wd[4] = "Неверные данные";
- }
- }
- catch
- {
- wd[3] = "Неверные данные";
- wd[4] = "Неверные данные";
- }
- //Проверка диагноза на содержание только букв
- try
- {
- foreach (char ch in wd[5])
- {
- if (ch >= '0' && ch <= '9')
- {
- number = true;
- }
- }
- if (number)
- {
- wd[5] = "Неверные данные";
- }
- }
- catch
- {
- wd[5] = "Неверные данные";
- }
- //Проверка пола на содержание только букв
- try
- {
- foreach (char ch in wd[6])
- {
- if (ch >= '0' && ch <= '9')
- {
- number = true;
- }
- }
- if (number)
- {
- wd[6] = "Неверные данные";
- }
- }
- catch
- {
- wd[6] = "Неверные данные";
- }
- if (wd[0] != "Неверные данные" && wd[1] != "Неверные данные" && wd[2] != "Неверные данные" && wd[3] != "Неверные данные" && wd[4] != "Неверные данные" && wd[5] != "Неверные данные" && wd[6] != "Неверные данные")
- {
- XDocument mydoc = XDocument.Load("Labo5NIKITA.xml");
- XElement myelement = mydoc.Element("Labo5NIKITA");
- myelement.Add(new XElement("Больничная_запись", new XAttribute("ФИО", wd[0] + "_" + wd[1] + "_" + wd[2]), new XElement("Дата_рождения", wd[3]), new XElement("Дата_обращения_к_доктору", wd[4]), new XElement("Диагноз", wd[5]), new XElement("Пол", wd[6])));
- mydoc.Save("Labo5NIKITA.xml");
- listBox1.Items.Add(wd[0] + "_" + wd[1] + "_" + wd[2]);
- toolStripTextBox1.Text = "";
- contextMenuStrip1.Hide();
- MessageBox.Show("Сохранение прошло успешно!", "Выполнено!", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- else
- {
- MessageBox.Show("Ошибка: вы ввели неверные данные!\n Проверьте правильность и повторите ввод!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- else
- {
- MessageBox.Show("Файл не содержит достаточной информации о больном! Проверьте данные и повторите попытку!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- catch (Exception error)
- {
- MessageBox.Show("Ошибка: " + error.Message, "Ошибка записи файла!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- else
- {
- MessageBox.Show("Ошибка: вы ввели неверные данные!\n Проверьте правильность и повторите ввод!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- else
- {
- MessageBox.Show("Ошибка: данные не могут быть пустыми!\n Проверьте правильность и повторите ввод!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- }
- //Редактирование данных
- private void РедактироватьToolStripMenuItem_Click(object sender, EventArgs e)
- {
- textBox1.ReadOnly = false;
- textBox1.ReadOnly = false;
- textBox2.ReadOnly = false;
- textBox3.ReadOnly = false;
- textBox4.ReadOnly = false;
- textBox5.Visible = true;
- label6.Visible = true;
- button1.Visible = true;
- listBox1.Enabled = false;
- }
- private void ОпределитьКоличесвтоПациентовСУказаннымДиагназомToolStripMenuItem_Click(object sender, EventArgs e)
- {
- try
- {
- if (listBox1.SelectedIndices.Count != 0)
- {
- Form2 Dialog = new Form2();
- String diagnosis;
- int counter = 0;
- var result = Dialog.ShowDialog();
- XDocument mydoc = XDocument.Load("Labo5NIKITA.xml");
- XElement myelement = mydoc.Element("Labo5NIKITA");
- if (result == DialogResult.OK && Dialog.Text != "" && Dialog.Text != " ")
- {
- diagnosis = Dialog.Text;
- Dialog.Close();
- foreach (XElement xe in myelement.Elements("Больничная_запись").ToList())
- {
- if (xe.Element("Диагноз").Value == diagnosis)
- {
- counter++;
- }
- }
- MessageBox.Show("Количество людей с диагнозом " + diagnosis + " : " + counter, "Поиск осуществлен!", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- else
- {
- Dialog.Close();
- MessageBox.Show("Данные не были введены!", "Поиск не осуществлен!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- else
- {
- MessageBox.Show("Данные не были загружены на форму!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- catch (Exception error)
- {
- MessageBox.Show("Ошибка: " + error.Message, "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- private void ВPdfToolStripMenuItem_Click(object sender, EventArgs e)
- {
- try
- {
- if (listBox1.SelectedIndices.Count != 0)
- {
- if (listBox1.SelectedIndex > -1)
- {
- var document = new Document();
- PdfWriter PDFWrite = PdfWriter.GetInstance(document, new FileStream(Application.StartupPath + @"\Labo5NIKITA.pdf", FileMode.Create));
- document.Open();
- try
- {
- BaseFont baseFont = BaseFont.CreateFont(@"C:\Users\nikit\Desktop\Labo5NIKITA_2\Labo5NIKITA_2\bin\Debug\arial.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
- iTextSharp.text.Font myfont = new iTextSharp.text.Font(baseFont, 10);
- PdfPTable table = new PdfPTable(5);
- PdfPCell cell = new PdfPCell(new Phrase("Больничный лист", myfont));
- table.AddCell(new Paragraph(label1.Text, myfont));
- table.AddCell(new Paragraph(label2.Text, myfont));
- table.AddCell(new Paragraph(label3.Text, myfont));
- table.AddCell(new Paragraph(label4.Text, myfont));
- table.AddCell(new Paragraph(label5.Text, myfont));
- string recording = listBox1.SelectedItem.ToString();
- table.AddCell(new Paragraph(recording, myfont));
- table.AddCell(new Paragraph(textBox1.Text, myfont));
- table.AddCell(new Paragraph(textBox2.Text, myfont));
- table.AddCell(new Paragraph(textBox3.Text, myfont));
- table.AddCell(new Paragraph(textBox4.Text, myfont));
- document.Add(table);
- document.Close();
- MessageBox.Show("Формирование карточки в PDF выполнено!", "Выполнено!", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- catch (Exception error)
- {
- MessageBox.Show("Ошибка: " + error.Message, "Ошибка записи файла!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- else
- {
- MessageBox.Show("Ошибка: нет выделенных элементов!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- else
- {
- MessageBox.Show("Ошибка: данные не загружены!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- catch (Exception error)
- {
- MessageBox.Show("Ошибка: " + error.Message, "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- private void ВExcelToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if (listBox1.SelectedIndices.Count != 0)
- {
- if (listBox1.SelectedIndex > -1)
- {
- Excel.Application myExcel = new Excel.Application();
- try
- {
- Excel.Workbook myBook;
- Excel.Worksheet myList;
- myBook = myExcel.Workbooks.Add();//добавление книги
- string FIO = listBox1.SelectedItem.ToString();
- myList = (Excel.Worksheet)myBook.Sheets[1];//добавление листа
- myList.Cells[1, 1] = label1.Text;//1-ая строка 1-ый столбец
- myList.Cells[1, 2] = label2.Text;//1-ая строка 2-ой столбец
- myList.Cells[1, 3] = label3.Text;
- myList.Cells[1, 4] = label4.Text;
- myList.Cells[1, 5] = label5.Text;
- myList.Cells[2, 1] = FIO;//2-ая строка 1-ый столбец
- myList.Cells[2, 2] = textBox1.Text;//2-ая строка 2-ой столбец
- myList.Cells[2, 3] = textBox2.Text;
- myList.Cells[2, 4] = textBox3.Text;
- myList.Cells[2, 5] = textBox4.Text;
- myList.Columns[1].Autofit();
- myList.Columns[2].Autofit();
- myList.Columns[3].Autofit();
- myList.Columns[4].Autofit();
- myList.Columns[5].Autofit();
- myBook.SaveAs(@"C:\Users\nikit\Desktop\Labo5NIKITA_2\Labo5NIKITA_2\bin\Debug\Labo5NIKITA.xlsx");
- MessageBox.Show("Формирование карточки в EXCEL выполнено!", "Выполнено!", MessageBoxButtons.OK, MessageBoxIcon.Information);
- myExcel.Quit();
- }
- catch (Exception error)
- {
- MessageBox.Show("Ошибка: " + error.Message, "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- else
- {
- MessageBox.Show("Ошибка: нет выделенных элементов!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- else
- {
- MessageBox.Show("Ошибка: данные не загружены!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- private void ВWordToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if (listBox1.SelectedIndices.Count != 0)
- {
- if (listBox1.SelectedIndex > -1)
- {
- Word._Document wrdDoc;
- Word.Selection wrdSelection;
- Word.MailMerge wrdMailMerge;
- Word.Table wrdTable;
- Word.Application wrdApp = new Word.Application();
- wrdDoc = wrdApp.Documents.Add();
- wrdDoc.Select();
- wrdSelection = wrdApp.Selection;
- wrdMailMerge = wrdDoc.MailMerge;
- string FIO = listBox1.SelectedItem.ToString();
- wrdTable = wrdDoc.Tables.Add(wrdSelection.Range, 9, 5);
- wrdTable.Columns[1].SetWidth(100, Word.WdRulerStyle.wdAdjustNone);
- wrdTable.Columns[2].SetWidth(100, Word.WdRulerStyle.wdAdjustNone);
- wrdTable.Columns[3].SetWidth(100, Word.WdRulerStyle.wdAdjustNone);
- wrdTable.Columns[4].SetWidth(100, Word.WdRulerStyle.wdAdjustNone);
- wrdTable.Columns[5].SetWidth(100, Word.WdRulerStyle.wdAdjustNone);
- wrdTable.Cell(1, 1).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
- wrdDoc.Tables[1].Cell(1, 1).Range.InsertAfter(label1.Text);
- wrdDoc.Tables[1].Cell(1, 2).Range.InsertAfter(label2.Text);
- wrdDoc.Tables[1].Cell(1, 3).Range.InsertAfter(label3.Text);
- wrdDoc.Tables[1].Cell(1, 4).Range.InsertAfter(label4.Text);
- wrdDoc.Tables[1].Cell(1, 5).Range.InsertAfter(label5.Text);
- wrdDoc.Tables[1].Cell(2, 1).Range.InsertAfter(FIO);
- wrdDoc.Tables[1].Cell(2, 2).Range.InsertAfter(textBox1.Text);
- wrdDoc.Tables[1].Cell(2, 3).Range.InsertAfter(textBox2.Text);
- wrdDoc.Tables[1].Cell(2, 4).Range.InsertAfter(textBox3.Text);
- wrdDoc.Tables[1].Cell(2, 5).Range.InsertAfter(textBox4.Text);
- wrdDoc.Saved = true;
- wrdDoc.SaveAs(@"C:\Users\nikit\Desktop\Labo5NIKITA_2\Labo5NIKITA_2\bin\Debug\Lab05NIKITA.docx");
- wrdDoc.Close();
- wrdApp.Quit();
- wrdSelection = null;
- wrdMailMerge = null;
- wrdDoc = null;
- wrdApp = null;
- }
- else
- {
- MessageBox.Show("Ошибка: нет выделенных элементов!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- else
- {
- MessageBox.Show("Ошибка: данные не загружены!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- private void Button1_Click(object sender, EventArgs e)
- {
- if (listBox1.SelectedIndices.Count != 0)
- {
- if (listBox1.SelectedIndex > -1)
- {
- bool number = false;
- bool check = true;
- //Проверка сопоставления дат(дата посещения врача не может быть ранее даты рождения)
- try
- {
- if (Convert.ToDateTime(textBox2.Text) < Convert.ToDateTime(textBox1.Text))
- {
- check = false;
- }
- }
- catch
- {
- check = false;
- }
- //Проверка диагноза на содержание только букв
- try
- {
- foreach (char ch in textBox3.Text)
- {
- if (ch >= '0' && ch <= '9')
- {
- number = true;
- }
- }
- if (number)
- {
- check = false;
- }
- }
- catch
- {
- check = false;
- }
- //Проверка пола на содержание только букв
- try
- {
- foreach (char ch in textBox4.Text)
- {
- if (ch >= '0' && ch <= '9')
- {
- number = true;
- }
- }
- if (number)
- {
- check = false;
- }
- }
- catch
- {
- check = false;
- }
- if (check)
- {
- XDocument mydoc = XDocument.Load("Labo5NIKITA.xml");
- XElement myelement = mydoc.Element("Labo5NIKITA");
- int i = -1;
- foreach (XElement xe in myelement.Elements("Больничная_запись").ToList())
- {
- i++;
- if (i == listBox1.SelectedIndex)
- {
- xe.Attribute("ФИО").Value = textBox5.Text;
- xe.Element("Дата_рождения").Value = textBox1.Text;
- xe.Element("Дата_обращения_к_доктору").Value = textBox2.Text;
- xe.Element("Диагноз").Value = textBox3.Text;
- xe.Element("Пол").Value = textBox4.Text;
- mydoc.Save("Labo5NIKITA.xml");
- listBox1.Items[i] = textBox5.Text;
- MessageBox.Show("Изменение прошло успешно", "Выполнено", MessageBoxButtons.OK, MessageBoxIcon.Information);
- listBox1.Focus();
- textBox1.ReadOnly = true;
- textBox2.ReadOnly = true;
- textBox3.ReadOnly = true;
- textBox4.ReadOnly = true;
- textBox5.Visible = false;
- label6.Visible = false;
- button1.Visible = false;
- listBox1.Enabled = true;
- break;
- }
- }
- }
- else
- MessageBox.Show("Ошибка: вы ввели неверные данные!\n Проверьте правильность и повторите ввод!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- else
- {
- MessageBox.Show("Ошибка: элемент не выделен!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- else
- MessageBox.Show("Ошибка: нет элементов для редактирования!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement