Beispiel #1
0
        private void save_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("Сохранить изменения?",
                                              "Сохранение",
                                              MessageBoxButtons.OKCancel,
                                              MessageBoxIcon.Question,
                                              MessageBoxDefaultButton.Button2);

            if (dr == DialogResult.OK)
            {
                this.Validate();
                this.toursBindingSource.EndEdit();
                this.toursTableAdapter.Update(this.tiuDataSet2.Tours);
                tiuDataSet2.Tables[0].AcceptChanges();
                TuiTour.Refresh();
                Fn.update(this.TuiTour, this.tour);
            }
        }
Beispiel #2
0
        private void save_change_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("Изменить запись?",
                                              "Изменение",
                                              MessageBoxButtons.OKCancel,
                                              MessageBoxIcon.Question,
                                              MessageBoxDefaultButton.Button2);

            if (dr == DialogResult.OK)
            {
                foreach (DataGridViewRow row in TuiTour.SelectedRows)
                {
                    Fn.edit(List_Text_Box, row);
                }
                this.Validate();
                this.toursBindingSource.EndEdit();
                this.toursTableAdapter.Update(this.tiuDataSet2.Tours);
                tiuDataSet2.Tables[0].AcceptChanges();
                TuiTour.Refresh();
                Fn.update(this.TuiTour, this.tour);
            }
        }
Beispiel #3
0
 private void reset_Click(object sender, EventArgs e)
 {
     TuiTour.BringToFront();
     Search.Clear();
 }
Beispiel #4
0
        private void add_Click(object sender, EventArgs e)
        {
            if (City_dpt.Text != "" && Country.Text != "" && Name.Text != "" && Price.Text != "" && Date.Text != "" && Night.Text != "")
            {
                DialogResult dr = MessageBox.Show("Добавить запись?",
                                                  "Добавление",
                                                  MessageBoxButtons.OKCancel,
                                                  MessageBoxIcon.Question,
                                                  MessageBoxDefaultButton.Button2);
                if (dr == DialogResult.OK)
                {
                    bool flag = false;
                    for (int i = 0; i < tour.Count; i++)
                    {
                        if (City_dpt.Text == tour[i].City && Country.Text == tour[i].Country1 && Name.Text == tour[i].Name1 && Price.Text == tour[i].Price1 && Date.Text == tour[i].dateofdep.ToString() && Night.Text == tour[i].numberofnights)
                        {
                            flag = true;
                        }
                    }
                    if (!flag)
                    {
                        this.Validate();
                        this.toursBindingSource.EndEdit();
                        DataRow nRow = tiuDataSet2.Tables[0].NewRow();
                        nRow["Город  отправления"] = City_dpt.Text.ToString();
                        nRow["Страна назначения"]  = Country.Text.ToString();
                        nRow["Название тура"]      = Name.Text.ToString();
                        CultureInfo MyCultureInfo = new CultureInfo("en-US");
                        nRow["Стоимость"]        = Price.Text.ToString();
                        nRow["Дата вылета"]      = DateTime.ParseExact(Date.Text.ToString(), "dd.M.yyyy", MyCultureInfo);
                        nRow["Количество ночей"] = Night.Text.ToString();

                        tiuDataSet2.Tables[0].Rows.Add(nRow);
                        toursTableAdapter.Update(tiuDataSet2.Tours);
                        tiuDataSet2.Tables[0].AcceptChanges();
                        TuiTour.Refresh();
                        Fn.update(this.TuiTour, this.tour);

                        City_dpt.Clear();
                        Country.Clear();
                        Name.Clear();
                        Price.Clear();
                        Date.Clear();
                        Night.Clear();
                    }
                    if (flag)
                    {
                        DialogResult er = MessageBox.Show("Такая запись уже существует!",
                                                          "Добавление",
                                                          MessageBoxButtons.OK,
                                                          MessageBoxIcon.Warning,
                                                          MessageBoxDefaultButton.Button1);
                    }
                }
            }
            else
            {
                DialogResult dr = MessageBox.Show("Некорректный ввод! Поля пусты.",
                                                  "Добавление",
                                                  MessageBoxButtons.OK,
                                                  MessageBoxIcon.Information,
                                                  MessageBoxDefaultButton.Button1);
            }
        }