Example #1
0
        private void FillSelectedEmployees()
        {
            if (sheduler != null)
            {
                StaffShedulerEmployeesLogic shedulerEmployees = new StaffShedulerEmployeesLogic(manager);

                var employees = shedulerEmployees.GetBySheduler(sheduler.ID).Select(a => new { a.StaffEmployee.ID, Name = a.StaffEmployee.LastName + " "
                                                                                                                          + a.StaffEmployee.FirstName + " "
                                                                                                                          + a.StaffEmployee.MiddleName });
                foreach (var employee in employees)
                {
                    ItemIntValue item = new ItemIntValue();
                    item.ID   = employee.ID;
                    item.Name = employee.Name;
                    SelectedEmployeesLB.Items.Add(item);
                }
            }
        }
Example #2
0
        private void DataGV_SelectionChanged(object sender, EventArgs e)
        {
            if (DataGV.SelectedRows.Count > 0)
            {
                StaffShedulerEmployeesLogic shedulerEmployees = new StaffShedulerEmployeesLogic(manager);

                int shedulerId = Convert.ToInt32(DataGV.SelectedRows[0].Cells["ID"].Value);
                var employees = shedulerEmployees.GetBySheduler(shedulerId).Select(a => new
                {
                    a.StaffEmployee.ID,
                    Name = a.StaffEmployee.LastName + " "
                        + a.StaffEmployee.FirstName + " "
                        + a.StaffEmployee.MiddleName
                });
                SelectedEmployeesLB.ValueMember = "ID";
                SelectedEmployeesLB.DisplayMember = "Name";
                SelectedEmployeesLB.DataSource = employees.ToList();
            }
        }
Example #3
0
        private void DataGV_SelectionChanged(object sender, EventArgs e)
        {
            if (DataGV.SelectedRows.Count > 0)
            {
                StaffShedulerEmployeesLogic shedulerEmployees = new StaffShedulerEmployeesLogic(manager);

                int shedulerId = Convert.ToInt32(DataGV.SelectedRows[0].Cells["ID"].Value);
                var employees  = shedulerEmployees.GetBySheduler(shedulerId).Select(a => new
                {
                    a.StaffEmployee.ID,
                    Name = a.StaffEmployee.LastName + " "
                           + a.StaffEmployee.FirstName + " "
                           + a.StaffEmployee.MiddleName
                });
                SelectedEmployeesLB.ValueMember   = "ID";
                SelectedEmployeesLB.DisplayMember = "Name";
                SelectedEmployeesLB.DataSource    = employees.ToList();
            }
        }
Example #4
0
        private void SaveBt_Click(object sender, EventArgs e)
        {
            StaffShedulersLogic         shedulers         = new StaffShedulersLogic(manager);
            StaffShedulerEmployeesLogic shedulersEmployee = new StaffShedulerEmployeesLogic(manager);

            int?     StructureObjectId = null;
            int?     teamId            = null;
            int?     shiftId           = null;
            int?     workPlaceId       = null;
            DateTime startDate         = StartDateDTP.Value.Add(StartTimeDTP.Value.TimeOfDay);
            DateTime endDate           = EndDateDTP.Value.Add(EndTimeDTP.Value.TimeOfDay);
            string   description       = DescriptionTB.Text;

            if (StructureObjectsCB.SelectedIndex > 0)
            {
                StructureObjectId = Convert.ToInt32(StructureObjectsCB.SelectedValue);
            }

            if (TeamsCB.SelectedIndex > 0)
            {
                teamId = Convert.ToInt32(TeamsCB.SelectedValue);
            }

            if (ShiftsCB.SelectedIndex > 0)
            {
                shiftId = Convert.ToInt32(ShiftsCB.SelectedValue);
            }


            if (mode == "new" || mode == "copy")
            {
                int userId = Compas.Logic.Security.CurrentSecurityContext.Identity.ID;
                // Define a transaction scope for the operations.
                using (TransactionScope transaction = new TransactionScope())
                {
                    try
                    {
                        StaffSheduler sheduler = shedulers.Create(StructureObjectId, shiftId, teamId,
                                                                  startDate, endDate, userId, DateTime.Now, description);
                        //додаємо працівників
                        foreach (object item in SelectedEmployeesLB.Items)
                        {
                            ItemIntValue i          = (ItemIntValue)item;
                            int          employeeId = i.ID;
                            shedulersEmployee.Create(sheduler, employeeId);
                        }
                    }
                    catch (Exception ex)
                    {
                        // Handle errors and deadlocks here and retry if needed.
                        // Allow an UpdateException to pass through and
                        // retry, otherwise stop the execution.
                        if (ex.GetType() != typeof(UpdateException))
                        {
                            MessageBox.Show("An error occured. "
                                            + "The operation cannot be retried."
                                            + ex.Message);
                        }
                        // If we get to this point, the operation will be retried.
                    }
                }
            }
            if (mode == "edit")
            {
                // Define a transaction scope for the operations.
                using (TransactionScope transaction = new TransactionScope())
                {
                    try
                    {
                        shedulers.Update(Convert.ToInt32(id), StructureObjectId, shiftId, teamId,
                                         startDate, endDate, description);
                        //додаємо працівників
                        shedulersEmployee.DeleteBySheduler(Convert.ToInt32(id));
                        foreach (object item in SelectedEmployeesLB.Items)
                        {
                            ItemIntValue i          = (ItemIntValue)item;
                            int          employeeId = i.ID;
                            shedulersEmployee.Create(sheduler, employeeId);
                        }
                    }
                    catch (Exception ex)
                    {
                        // Handle errors and deadlocks here and retry if needed.
                        // Allow an UpdateException to pass through and
                        // retry, otherwise stop the execution.
                        if (ex.GetType() != typeof(UpdateException))
                        {
                            MessageBox.Show("An error occured. "
                                            + "The operation cannot be retried."
                                            + ex.Message);
                        }
                        // If we get to this point, the operation will be retried.
                    }
                }
            }

            manager.Save();

            this.Close();
        }
Example #5
0
        private void SaveBt_Click(object sender, EventArgs e)
        {
            StaffShedulersLogic shedulers = new StaffShedulersLogic(manager);
            StaffShedulerEmployeesLogic shedulersEmployee = new StaffShedulerEmployeesLogic(manager);

            int? StructureObjectId = null;
            int? teamId = null;
            int? shiftId = null;
            int? workPlaceId = null;
            DateTime startDate = StartDateDTP.Value.Add(StartTimeDTP.Value.TimeOfDay);
            DateTime endDate = EndDateDTP.Value.Add(EndTimeDTP.Value.TimeOfDay);
            string description = DescriptionTB.Text;

            if (StructureObjectsCB.SelectedIndex > 0)
            {
                StructureObjectId = Convert.ToInt32(StructureObjectsCB.SelectedValue);
            }

            if (TeamsCB.SelectedIndex > 0)
            {
                teamId = Convert.ToInt32(TeamsCB.SelectedValue);
            }

            if (ShiftsCB.SelectedIndex > 0)
            {
                shiftId = Convert.ToInt32(ShiftsCB.SelectedValue);
            }

            if (mode == "new" || mode == "copy")
            {
                int userId = Compas.Logic.Security.CurrentSecurityContext.Identity.ID;
                // Define a transaction scope for the operations.
                using (TransactionScope transaction = new TransactionScope())
                {
                    try
                    {
                        StaffSheduler sheduler = shedulers.Create( StructureObjectId, shiftId, teamId,
                            startDate, endDate, userId, DateTime.Now, description);
                        //додаємо працівників
                        foreach (object item in SelectedEmployeesLB.Items)
                        {
                            ItemIntValue i = (ItemIntValue)item;
                            int employeeId = i.ID;
                            shedulersEmployee.Create(sheduler, employeeId);
                        }

                    }
                    catch (Exception ex)
                    {
                        // Handle errors and deadlocks here and retry if needed.
                        // Allow an UpdateException to pass through and
                        // retry, otherwise stop the execution.
                        if (ex.GetType() != typeof(UpdateException))
                        {
                            MessageBox.Show("An error occured. "
                                + "The operation cannot be retried."
                                + ex.Message);

                        }
                        // If we get to this point, the operation will be retried.
                    }
                }

            }
            if (mode == "edit")
            {

                // Define a transaction scope for the operations.
                using (TransactionScope transaction = new TransactionScope())
                {
                    try
                    {
                        shedulers.Update(Convert.ToInt32(id),  StructureObjectId, shiftId, teamId,
                            startDate, endDate, description);
                        //додаємо працівників
                        shedulersEmployee.DeleteBySheduler(Convert.ToInt32(id));
                        foreach (object item in SelectedEmployeesLB.Items)
                        {
                            ItemIntValue i = (ItemIntValue)item;
                            int employeeId = i.ID;
                            shedulersEmployee.Create(sheduler, employeeId);
                        }

                    }
                    catch (Exception ex)
                    {
                        // Handle errors and deadlocks here and retry if needed.
                        // Allow an UpdateException to pass through and
                        // retry, otherwise stop the execution.
                        if (ex.GetType() != typeof(UpdateException))
                        {
                            MessageBox.Show("An error occured. "
                                + "The operation cannot be retried."
                                + ex.Message);

                        }
                        // If we get to this point, the operation will be retried.
                    }
                }
            }

            manager.Save();

            this.Close();
        }
Example #6
0
        private void FillSelectedEmployees()
        {
            if (sheduler != null)
            {
                StaffShedulerEmployeesLogic shedulerEmployees = new StaffShedulerEmployeesLogic(manager);

                var employees = shedulerEmployees.GetBySheduler(sheduler.ID).Select(a => new { a.StaffEmployee.ID, Name = a.StaffEmployee.LastName + " "
                    + a.StaffEmployee.FirstName + " "
                    + a.StaffEmployee.MiddleName });
                foreach (var employee in employees)
                {
                    ItemIntValue item = new ItemIntValue();
                    item.ID = employee.ID;
                    item.Name = employee.Name;
                    SelectedEmployeesLB.Items.Add(item);
                }
            }
        }