示例#1
0
        private async void dataGridViewEmp_DoubleClick(object sender, EventArgs e)
        {
            var emp = (Employee)dataGridViewEmp.CurrentRow.DataBoundItem;

            Data.employee = emp;
            Data.deptList = depts;
            EmpForm empForm = new EmpForm();

            if (empForm.ShowDialog() == DialogResult.OK)
            {
                if (Data.employee != null)
                {
                    if (Data.employee.Id == -1)
                    {
                        await DeleteEmp(emp.Id);
                    }
                    else
                    {
                        await EditEmp(Data.employee);
                    }
                }
                FillEmps(emp.Dept_Id);
            }
            depts = await deptController.GetAsync();

            Data.employee = null;
        }
示例#2
0
        private async void AddEmp_Click(object sender, EventArgs e)
        {
            Data.employee = new Employee()
            {
                Id = 0, Dept_Id = ((Dept)listBoxDept.SelectedItem).Id
            };
            Data.deptList = depts;
            EmpForm empForm = new EmpForm();

            if (empForm.ShowDialog() == DialogResult.OK)
            {
                if (Data.employee != null)
                {
                    await CreateEmp(Data.employee);
                }
                FillEmps(Data.employee.Dept_Id);
            }
            Data.employee = null;
        }