示例#1
0
        //Кнопка редактирования записи
        private void button5_Click(object sender, EventArgs e)
        {
            Add.AddOrEditFlag = false;

            if (catalog == "Department")
            {
                Department depart = new Department();
                depart.ID   = dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[0].Value.ToString();
                depart.Name = dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[1].Value.ToString();
                depart.Code = dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[2].Value.ToString();
                depart.ParentDepartmentID = dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[3].Value.ToString();

                DepartmentForm dp = new DepartmentForm(depart);
                dp.ShowDialog();
                Refresh();
            }
            else if (catalog == "Empoyee")
            {
                Employee empl = new Employee();
                empl.FirstName        = dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[1].Value.ToString();
                empl.SurName          = dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[2].Value.ToString();
                empl.Patronymic       = dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[3].Value.ToString();
                empl.DataOfBirth      = (DateTime)dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[4].Value;
                empl.DocSeries        = dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[5].Value.ToString();
                empl.DocNumber        = dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[6].Value.ToString();
                empl.Position         = dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[7].Value.ToString();
                empl.ParentDepartment = dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[8].Value.ToString();

                string       ID  = dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[0].Value.ToString();
                EmployeeForm emp = new EmployeeForm(empl, ID);
                emp.ShowDialog();
                Refresh();
            }
        }
示例#2
0
 //Кнопка добавления новой записи
 private void button3_Click(object sender, EventArgs e)
 {
     //В зависимости от каталога вызывается соответствующая форма
     if (catalog == "Department")
     {
         Department depart = new Department();
         Add.AddOrEditFlag = true;
         DepartmentForm add = new DepartmentForm(depart);
         add.ShowDialog();
         Refresh();
     }
     if (catalog == "Empoyee")
     {
         Add.AddOrEditFlag = true;
         Employee     empl = new Employee();
         EmployeeForm add  = new EmployeeForm(empl, "");
         add.ShowDialog();
         Refresh();
     }
 }