Beispiel #1
0
        private void btnGroupStaffSave_Click(object sender, EventArgs e)
        {
            if (dgvGroupList.SelectedRows.Count == 0 || dgvGroupList.SelectedRows[0].Index < 0)
            {
                return;
            }

            var rowIndex = dgvGroupList.SelectedRows[0].Index;
            var row      = dgvGroupList.Rows[rowIndex];
            var groupId  = int.Parse(row.Cells["Id"].Value?.ToString());

            var staffs     = (BindingList <StaffBinding>)dgvGroupStaffList.DataSource;
            var assignment = new List <Assignment>();

            foreach (var staff in staffs)
            {
                assignment.Add(
                    new Assignment
                {
                    StaffId  = staff.Id,
                    GroupId  = groupId,
                    Position = staff.Position
                });
            }

            GroupBLL.SaveListStaffsOfGroup(groupId, assignment);
            Thread loadStaffsThread = new Thread(
                () =>
            {
                LoadStaffsInGroup(groupId);
                LoadStaffsNotInGroup(groupId);
            });

            loadStaffsThread.Start();
            MessageBox.Show("Cập nhật danh sách nhân viên thành công");
        }