Example #1
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     try
     {
         PointsSet pointset = new PointsSet();
         if (comboBoxStudent.SelectedItem != null)
         {
             pointset.IdStudent = Convert.ToInt32(comboBoxStudent.SelectedItem.ToString().Split('.')[0]);
         }
         if (comboBoxLesson.SelectedItem != null)
         {
             pointset.IdLesson = Convert.ToInt32(comboBoxLesson.SelectedItem.ToString().Split('.')[0]);
         }
         if (textBoxPoint.Text != "")
         {
             pointset.Point = Convert.ToDouble(textBoxPoint.Text);
         }
         Program.EduDb.PointsSet.Add(pointset);
         Program.EduDb.SaveChanges();
     }
     catch
     {
         { MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); }
     }
     ShowPoints();
 }
Example #2
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if ((comboBoxStudent.SelectedItem != null) && (comboBoxLesson.SelectedItem != null) &&
         (textBoxPoint.Text != ""))
     {
         if (listViewPoint.SelectedItems.Count == 1)
         {
             PointsSet pointset = listViewPoint.SelectedItems[0].Tag as PointsSet;
             if (comboBoxStudent.SelectedItem != null)
             {
                 pointset.IdStudent = Convert.ToInt32(comboBoxStudent.SelectedItem.ToString().Split('.')[0]);
             }
             if (comboBoxLesson.SelectedItem != null)
             {
                 pointset.IdLesson = Convert.ToInt32(comboBoxLesson.SelectedItem.ToString().Split('.')[0]);
             }
             if (textBoxPoint.Text != "")
             {
                 pointset.Point = Convert.ToDouble(textBoxPoint.Text);
             }
             Program.EduDb.SaveChanges();
             ShowPoints();
         }
     }
     else
     {
         MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #3
0
 private void listViewPoint_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewPoint.SelectedItems.Count == 1)
     {
         PointsSet pointset = listViewPoint.SelectedItems[0].Tag as PointsSet;
         comboBoxStudent.SelectedIndex = comboBoxStudent.FindString(pointset.IdStudent.ToString());
         comboBoxLesson.SelectedIndex  = comboBoxLesson.FindString(pointset.IdLesson.ToString());
         textBoxPoint.Text             = pointset.Point.ToString();
     }
     else
     {
         textBoxPoint.Text            = "";
         comboBoxStudent.SelectedItem = null;
         comboBoxLesson.SelectedItem  = null;
     }
 }
Example #4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewPoint.SelectedItems.Count == 1)
         {
             PointsSet pointset = listViewPoint.SelectedItems[0].Tag as PointsSet;
             Program.EduDb.PointsSet.Remove(pointset);
             Program.EduDb.SaveChanges();
             ShowPoints();
         }
         textBoxPoint.Text            = "";
         comboBoxStudent.SelectedItem = null;
         comboBoxLesson.SelectedItem  = null;
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }