private void button1_Click(object sender, EventArgs e) { if ((textBox1.Text == "") || (textBox2.Text == "") || (textBox4.Text == "")) { MessageBox.Show("Заполните все поля!!!!", "Ошибка", MessageBoxButtons.OKCancel); } else { Zakaz v = new Zakaz(textBox1.Text, textBox2.Text, Convert.ToString(dateTimePicker1.Value), maskedTextBox1.Text, textBox4.Text, maskedTextBox2.Text); if (!(textBox1.Text == "") && !(textBox2.Text == "") && !(textBox4.Text == "")) { FileStream file1 = new FileStream("Zak.txt", FileMode.Append); StreamWriter zap1 = new StreamWriter(file1); zap1.WriteLine(textBox1.Text); zap1.WriteLine(textBox2.Text); zap1.WriteLine(dateTimePicker1.Value); zap1.WriteLine(maskedTextBox1.Text); zap1.WriteLine(textBox4.Text); zap1.WriteLine(maskedTextBox2.Text); zap1.Close(); DataTable dt = new DataTable(); dt.Columns.Add("Фамилия клиента"); dt.Columns.Add("Фамилия врача"); dt.Columns.Add("Дата"); dt.Columns.Add("Время"); dt.Columns.Add("Услуга"); dt.Columns.Add("Контактный телефон"); z[] user = new z[100]; StreamReader zap = new StreamReader("Zak.txt"); // Поток на чтение с файла int i = 0; while (zap.Peek() != -1) // Считывание с файла { i++; user[i].famk = zap.ReadLine(); user[i].famv = zap.ReadLine(); user[i].data = zap.ReadLine(); user[i].time = zap.ReadLine(); user[i].service = zap.ReadLine(); user[i].namber = zap.ReadLine(); } zap.Close(); for (int j = 1; j <= i; j++) { dt.Rows.Add(user[j].famk, user[j].famv, user[j].data, user[j].time, user[j].service, user[j].namber); } Form10 f10 = new Form10(); f10.dataGridView1.DataSource = dt; } MessageBox.Show("Спасибо за ваш заказ", "Заказы", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); Form2 f2 = new Form2(); f2.Show(); this.Close(); } }
private void pictureBox1_Click(object sender, EventArgs e) { if (textBox1.Text == "") { Form2 f2 = new Form2(); f2.Show(); this.Hide(); Form3 f3 = new Form3(); f3.pictureBox2.Visible = false; f3.pictureBox3.Visible = false; f3.pictureBox4.Visible = false; Form4 f4 = new Form4(); f4.pictureBox2.Visible = false; f4.pictureBox3.Visible = false; f4.pictureBox4.Visible = false; Form10 f10 = new Form10(); f10.pictureBox2.Visible = false; f10.pictureBox3.Visible = false; } else if (textBox1.Text == "admin") { Form2 f2 = new Form2(); f2.списокЗаказовToolStripMenuItem.Visible = true; f2.Show(); this.Hide(); Form3 f3 = new Form3(); f3.pictureBox2.Visible = true; f3.pictureBox3.Visible = true; f3.pictureBox4.Visible = true; Form4 f4 = new Form4(); f4.pictureBox2.Visible = true; f4.pictureBox3.Visible = true; f4.pictureBox4.Visible = true; Form10 f10 = new Form10(); f10.pictureBox2.Visible = true; f10.pictureBox3.Visible = true; } }