Example #1
0
        /// <summary>
        /// Сохранение данных из формы
        /// </summary>
        private void Save()
        {
            for (int i = 0; i < dataGridView.Rows.Count; i++)
            {
                //Проверка на наличие данных
                if (dataGridView.Rows[i].Cells[0].Value == null ||
                    dataGridView.Rows[i].Cells[1].Value == null ||
                    dataGridView.Rows[i].Cells[2].Value == null ||
                    dataGridView.Rows[i].Cells[4].Value == null)
                {
                    MessageBox.Show("Заполнены не все поля пользователей");
                    return;
                }
                //Проверка на корректность
                int checkInt;
                if (!int.TryParse(dataGridView.Rows[i].Cells[2].Value.ToString(), out checkInt) ||
                    !int.TryParse(dataGridView.Rows[i].Cells[4].Value.ToString(), out checkInt))
                {
                    MessageBox.Show("В полях с цифровыми значениями указаны иные символы");
                    return;
                }
            }

            department.localSave(department, TreeDepartments.SelectedNode.Name, dataGridView, nameDepartment.Text, dateTimeDepartment.Value);
            RefreshTreeDepartment(TreeDepartments.SelectedNode.Name);
        }