Example #1
0
 public StudentsIndexForm()
 {
     InitializeComponent();
     StudentsDataGrid.AutoGenerateColumns = false;
     StudentsDataGrid.Select();
     StudentsDataGrid.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
 }
Example #2
0
        private void CommitChangeClick(object sender, RoutedEventArgs e)
        {
            if (StudentsDataGrid.SelectedItem == null)
            {
                var G = new DataBase.Students();
                G.F      = SurnameTextBox.Text;
                G.I      = NameTextBox.Text;
                G.O      = PatronymicTextBox.Text;
                G.Groups = (DataBase.Groups)GroupsComboBox.SelectedItem;
                Students.Add(G);
                SourceCore.DB.Students.Add(G);

                StudentsDataGrid.ScrollIntoView(G);
                StudentsDataGrid.SelectedIndex = Students.Count - 1;
                DataGridRow row = (DataGridRow)StudentsDataGrid.ItemContainerGenerator.ContainerFromIndex(Students.Count - 1);
                row.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
            }
            SourceCore.DB.SaveChanges();
            CloseChangeFieldClick(sender, e);
        }
Example #3
0
 private void DeleteClick(object sender, RoutedEventArgs e)
 {
     if (MessageBox.Show("Удалить запись?", "Внимание!", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
     {
         var obj = (DataBase.Students)StudentsDataGrid.SelectedItem;
         int i   = StudentsDataGrid.SelectedIndex;
         if (--i < 0)
         {
             i = i + 2;
         }
         if (i < StudentsDataGrid.Items.Count)
         {
             StudentsDataGrid.ScrollIntoView(obj);
             StudentsDataGrid.SelectedIndex = i;
             DataGridRow row = (DataGridRow)StudentsDataGrid.ItemContainerGenerator.ContainerFromIndex(i);
             row.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
         }
         SourceCore.DB.Students.Remove(obj);
         Students.Remove(obj);
         SourceCore.DB.SaveChanges();
     }
 }
Example #4
0
        private void BindGrid()
        {
            if (SearchStudentsInput.Text.Length > 50)
            {
                MessageBox.Show("Error! To much characters!");
            }
            else
            {
                HttpResponseMessage response = studentsServices.GetActionResponse("GetStudentsByName", SearchStudentsInput.Text.Trim());

                if (response.IsSuccessStatusCode)
                {
                    List <Student_Result> employees = response.Content.ReadAsAsync <List <Student_Result> >().Result;
                    StudentsDataGrid.DataSource = employees;
                    StudentsDataGrid.ClearSelection();
                }
                else
                {
                    MessageBox.Show("Error Code" +
                                    response.StatusCode + " : Message - " + response.ReasonPhrase);
                }
            }
        }