예제 #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            tickets f6 = new tickets();

            this.Hide();
            f6.Show();
        }
예제 #2
0
 private void delete()
 {
     if (MessageBox.Show("Вы уверены что хотите удалить этот рейс?", "Удаление", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
     {
         int k = 0;
         Database.TrainData[] copy = new Database.TrainData[Database.rase.Length - 1];
         for (int i = 0; i < Database.rase.Length; i++)
         {
             if (Database.rase[i].number == numbertxt.Text)
             {
                 k = i;
                 break;
             }
             copy[i] = Database.rase[i];
         }
         for (int i = k, j = k + 1; j < Database.rase.Length; i++, j++)
         {
             copy[i] = Database.rase[j];
         }
         Database.m--;
         Database.rase = new Database.TrainData[Database.m];
         Database.rase = copy;
         StreamWriter wr = new StreamWriter("train.txt", false);
         for (int i = 0; i < Database.rase.Length; i++)
         {
             wr.WriteLine(Database.rase[i].number + ";" + Database.rase[i].pn + ";" + Database.rase[i].data + ";" + Database.rase[i].to + ";" + Database.rase[i].tp + ";" + Database.rase[i].s + ";" + Database.rase[i].ob + ";" + Database.rase[i].pb);
         }
         wr.Close();
         this.Close();
         tickets t = new tickets();
         t.Show();
         MessageBox.Show("Рейс удален", "", MessageBoxButtons.OK);
     }
     numbertxt.Text      = "";
     cb.Text             = "";
     datatxt.Text        = "";
     maskedTextBox1.Text = "";
     tptxt.Text          = "";
     stxt.Text           = "";
     obtxt.Text          = "";
     pbtxt.Text          = "";
 }
예제 #3
0
        private void Uupdate()
        {
            if (numbertxt.Text == "" || maskedTextBox1.Text == "" || cb.Text == "" || datatxt.Text == "" || obtxt.Text == "" || stxt.Text == "" || pbtxt.Text == "" || tptxt.Text == "")
            {
                MessageBox.Show("Введите данные!", "Ошибка", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
            }
            else
            {
                bool         f      = false;
                StreamReader reader = new StreamReader("train.txt");
                while (true)
                {
                    string strin = reader.ReadLine();
                    if (strin == null)
                    {
                        break;
                    }
                    string[] accdata = new string[Database.rase.Length];
                    accdata = strin.Split(';');

                    if (numbertxt.Text == accdata[0] && accdata[0] != listView2.FocusedItem.SubItems[0].Text)
                    {
                        f = true;
                        break;
                    }
                }
                reader.Close();
                if (f == true)
                {
                    MessageBox.Show("Поезд с таким номером уже существует");
                }
                else
                {
                    string       numberr = numbertxt.Text;
                    string       pnn     = cb.Text;
                    string       dataa   = datatxt.Text;
                    string       too     = maskedTextBox1.Text;
                    string       tpp     = tptxt.Text;
                    string       ss      = stxt.Text;
                    string       obb     = obtxt.Text;
                    string       pbb     = pbtxt.Text;
                    StreamReader str     = new StreamReader("train.txt");
                    string       text;
                    while ((text = str.ReadLine()) != null)
                    {
                        string[] mystring = text.Split(';');
                    }

                    str.Close();



                    for (int i = 0; i < Database.rase.Length; i++)
                    {
                        if (Database.rase[i].number == listView2.FocusedItem.SubItems[0].Text)
                        {
                            Database.rase[i].number = numbertxt.Text;
                            Database.rase[i].pn     = cb.Text;
                            Database.rase[i].data   = datatxt.Text;
                            Database.rase[i].to     = maskedTextBox1.Text;
                            Database.rase[i].tp     = tptxt.Text;
                            Database.rase[i].s      = stxt.Text;
                            Database.rase[i].ob     = obtxt.Text;
                            Database.rase[i].pb     = pbtxt.Text;
                        }
                    }
                    StreamWriter wr = new StreamWriter("train.txt", false);

                    for (int i = 0; i < Database.rase.Length; i++)
                    {
                        wr.WriteLine(Database.rase[i].number + ";" + Database.rase[i].pn + ";" + Database.rase[i].data + ";" + Database.rase[i].to + ";" + Database.rase[i].tp + ";" + Database.rase[i].s + ";" + Database.rase[i].ob + ";" + Database.rase[i].pb);
                    }
                    wr.Close();
                    this.Close();
                    tickets p = new tickets();
                    p.Show();
                    MessageBox.Show("Рейс изменен.");
                }
                numbertxt.Text      = "";
                cb.Text             = "";
                datatxt.Text        = "";
                maskedTextBox1.Text = "";
                tptxt.Text          = "";
                stxt.Text           = "";
                obtxt.Text          = "";
                pbtxt.Text          = "";
            }
        }