Beispiel #1
0
        private void Delete_Click(object sender, EventArgs e)
        {
            string SelectedName = "";

            foreach (DataGridViewRow row in DG_Disc.SelectedRows)
            {
                DataRow Row = ((DataRowView)row.DataBoundItem).Row;
                SelectedName += (string)Row["Fullname"] + ", ";
            }
            if (SelectedName.Length > 2)
            {
                SelectedName = SelectedName.Remove(SelectedName.Length - 2);
            }
            DialogResult dr = MessageBox.Show("Удалить дисциплину - " + SelectedName + "?", "Подтверждение", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (DG_Disc.SelectedRows.Count > 0 && dr == DialogResult.OK)
            {
                int countSelected = DG_Disc.SelectedRows.Count;

                MDiscipline mDiscipline;
                foreach (DataGridViewRow row in DG_Disc.SelectedRows)
                {
                    DataRow Row = ((DataRowView)row.DataBoundItem).Row;
                    mDiscipline = new MDiscipline((string)Row["Fullname"], (string)Row["Shortname"], (string)Row["CycleofDiscipline"]);
                    Program.refData.CDiscipline.Delete(mDiscipline);
                }
            }
        }
 private void btCreateAndClose_Click(object sender, EventArgs e)
 {
     if (String.IsNullOrWhiteSpace(tbFullName.Text) || String.IsNullOrWhiteSpace(tbShortName.Text) || String.IsNullOrWhiteSpace(tbCycleOfDis.Text))
     {
         MessageBox.Show("Заполните все поля");
     }
     else
     {
         MDiscipline mDiscipline = new MDiscipline(tbFullName.Text, tbShortName.Text, tbCycleOfDis.Text);
         try
         {
             if (!itsupdate)
             {
                 if (!Program.refData.CDiscipline.Insert(mDiscipline))
                 {
                     MessageBox.Show("Невозможно добавить дисциплину");
                     return;
                 }
             }
             else
             {
                 Program.refData.CDiscipline.Update(mDiscipline);
             }
             Close();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Beispiel #3
0
 private void btCreateAndClose_Click(object sender, EventArgs e)
 {
     if (String.IsNullOrWhiteSpace(tbFullName.Text) || String.IsNullOrWhiteSpace(tbShortName.Text) || String.IsNullOrWhiteSpace(tbCycleOfDis.Text))
     {
         MessageBox.Show("Заполните все поля");
     }
     else
     {
         MDiscipline mDiscipline = new MDiscipline(tbFullName.Text, tbShortName.Text, tbCycleOfDis.Text);
         try
         {
             if (!itsupdate)
             {
                 Controllers.CDiscipline.Insert(mDiscipline);
             }
             else
             {
                 Controllers.CDiscipline.Update(mDiscipline);
             }
             Close();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
 public AddDiscipline(MDiscipline mDiscipline)
 {
     InitializeComponent();
     Text = "Изменение дисциплины";
     btCreateAndClean.Visible = false;
     btCreateAndClose.Text    = "Сохранить";
     tbFullName.Text          = mDiscipline.Fullname;
     tbFullName.Enabled       = false;
     tbShortName.Text         = mDiscipline.Shortname;
     tbCycleOfDis.Text        = mDiscipline.CycleofDiscipline;
     itsupdate = true;
 }
 private void btChange_Click(object sender, EventArgs e)
 {
     if (DG_Disc.SelectedRows.Count == 1)
     {
         DataRow       Row         = ((DataRowView)DG_Disc.SelectedRows[0].DataBoundItem).Row;
         MDiscipline   mDiscipline = new MDiscipline((string)Row["Fullname"], (string)Row["Shortname"], (string)Row["CycleofDiscipline"]);
         AddDiscipline add         = new AddDiscipline(mDiscipline);
         add.Owner = this;
         add.ShowDialog();
     }
     else
     {
         MessageBox.Show("Для изменения выделите только одну строку!");
     }
 }