Esempio n. 1
0
File: Form1.cs Progetto: IchPOch/PPO
 private void sbros_Click(object sender, EventArgs e)
 {
     button_off();
     foreach (DataGridViewRow row in Table.SelectedRows)
     {
         row.Selected = false;
     }
     NM.Clear(); PAG.Clear(); BO.Clear(); OPI.Clear();
     JA.Clear(); CO.Clear();
 }
Esempio n. 2
0
File: Form1.cs Progetto: IchPOch/PPO
 private void AddBut_Click(object sender, EventArgs e)
 {
     if (NM.Text != "" && BO.Text != "" && OPI.Text != "" && JA.Text != "" && PAG.Text != "")
     {
         DialogResult dr = MessageBox.Show("Добавить запись?",
                                           "Добавление",
                                           MessageBoxButtons.OKCancel,
                                           MessageBoxIcon.Question,
                                           MessageBoxDefaultButton.Button2);
         if (dr == DialogResult.OK)
         {
             bool flag = false;
             for (int i = 0; i < Objects.Count; i++)
             {
                 if (NM.Text == Objects[i].Name &&
                     BO.Text == Objects[i].bookname &&
                     JA.Text == Objects[i].Janr &&
                     OPI.Text == Objects[i].opis ||
                     CO.Text == Objects[i].index.ToString())
                 {
                     flag = true;
                 }
             }
             if (!flag)
             {
                 this.Validate();
                 this.biblBindingSource.EndEdit();
                 DataRow nRow = kursDataSet.Tables[0].NewRow();
                 nRow["Код"]      = CO.Text.ToString();
                 nRow["Имя"]      = NM.Text.ToString();
                 nRow["Книга"]    = BO.Text.ToString();
                 nRow["Жанр"]     = JA.Text.ToString();
                 nRow["Страницы"] = PAG.Text.ToString();
                 nRow["Описание"] = OPI.Text.ToString();
                 kursDataSet.Tables[0].Rows.Add(nRow);
                 biblTableAdapter2.Update(kursDataSet.Bibl);
                 kursDataSet.Tables[0].AcceptChanges();
                 Table.Refresh();
                 Bibl.data_update(this.Table, this.Objects);
                 NM.Clear();
                 BO.Clear();
                 JA.Clear();
                 PAG.Clear();
                 OPI.Clear();
                 CO.Clear();
             }
             if (flag)
             {
                 DialogResult er = MessageBox.Show("Такая запись уже существует!",
                                                   "Добавление",
                                                   MessageBoxButtons.OK,
                                                   MessageBoxIcon.Warning,
                                                   MessageBoxDefaultButton.Button1);
             }
         }
     }
     else
     {
         DialogResult dr = MessageBox.Show("Некорректный ввод! Поля пусты.",
                                           "Добавление",
                                           MessageBoxButtons.OK,
                                           MessageBoxIcon.Information,
                                           MessageBoxDefaultButton.Button1);
     }
 }