Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                try
                {
                    Employee loggedEmployee = (Employee)Session["MY_INFORMATION"];
                    if (!((loggedEmployee.organizationalUnit.Equals("Administración")) && (loggedEmployee.positionName.Equals("Gerente de Talento Humano"))) &&
                        !((loggedEmployee.organizationalUnit.Equals("Contraloría")) && (loggedEmployee.positionName.Equals("Contralor de Gestión"))) &&
                        !((loggedEmployee.organizationalUnit.Equals("Directiva")) && (loggedEmployee.positionName.Equals("Director"))))
                    {
                        Response.Redirect("~/site/employees/dashboard.aspx", false);
                    }
                    if (Session["CONSULTED_EMAIL"] != null)
                    {
                        ouDropList.ClearSelection();
                        positionDropList.ClearSelection();
                        superviseDropList.ClearSelection();
                        ouDropList.Items.Clear();
                        positionDropList.Items.Clear();
                        superviseDropList.Items.Clear();

                        string   employeeEmail = (string)Session["CONSULTED_EMAIL"];
                        Employee employee      = new Employee(employeeEmail);
                        GetEmployeeInformationCommand    cmd          = new GetEmployeeInformationCommand(employee);
                        GetAllPositionsCommand           cmdPositions = new GetAllPositionsCommand();
                        GetAllOrganizationalUnitsCommand cmdUnits     = new GetAllOrganizationalUnitsCommand();
                        cmd.Execute();
                        cmdPositions.Execute();
                        cmdUnits.Execute();
                        consultedEmployee = cmd.GetResult();
                        List <OrganizationalUnit> organizationalUnits = cmdUnits.GetResults();
                        List <Position>           positions           = cmdPositions.GetResults();
                        if (consultedEmployee != null)
                        {
                            id.Value = consultedEmployee.id.ToString();
                            Session["CONSULTED_ID"] = consultedEmployee.id;
                            workerid.Value          = consultedEmployee.workerId;
                            name.Value  = consultedEmployee.firstName + " " + consultedEmployee.lastName;
                            email.Value = consultedEmployee.email;
                            ListItem item;
                            foreach (Position position in positions)
                            {
                                item = new ListItem(position.name, position.id.ToString());
                                positionDropList.Items.Insert(positionDropList.Items.Count, item);
                            }
                            positionDropList.Items.FindByValue(consultedEmployee.idPosition.ToString()).Selected = true;
                            foreach (OrganizationalUnit organizationalUnit in organizationalUnits)
                            {
                                item = new ListItem(organizationalUnit.name, organizationalUnit.id.ToString());
                                ouDropList.Items.Insert(ouDropList.Items.Count, item);
                            }
                            ouDropList.Items.FindByValue(consultedEmployee.idOrganizationalUnit.ToString()).Selected = true;
                            item = new ListItem("No aplica", "-1");
                            superviseDropList.Items.Insert(superviseDropList.Items.Count, item);
                            foreach (OrganizationalUnit organizationalUnit in organizationalUnits)
                            {
                                if (organizationalUnit.id != 1)
                                {
                                    item = new ListItem(organizationalUnit.name, organizationalUnit.id.ToString());
                                    superviseDropList.Items.Insert(superviseDropList.Items.Count, item);
                                    if (organizationalUnit.overseer == consultedEmployee.id)
                                    {
                                        supervisedUnit = organizationalUnit.id;
                                    }
                                }
                            }
                            if (supervisedUnit != 0)
                            {
                                superviseDropList.Items.FindByValue(supervisedUnit.ToString()).Selected = true;
                            }

                            Session["CONSULTED_SUPERVISEDUNIT"] = supervisedUnit;
                        }
                        else
                        {
                            Session.Remove("CONSULTED_EMAIL");
                            Session.Remove("CONSULTED_ID");
                            Session.Remove("CONSULTED_SUPERVISEDUNIT");
                            Response.Redirect("~/site/employees/dashboard.aspx", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Session.Remove("CONSULTED_EMAIL");
                    Session.Remove("CONSULTED_ID");
                    Session.Remove("CONSULTED_SUPERVISEDUNIT");
                    Response.Redirect("~/site/employees/hrm/employeelist.aspx", false);
                }
            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                try
                {
                    if (Session["CONSULTED_ACP"] != null)
                    {
                        string acpId            = (string)Session["CONSULTED_ACP"];
                        GetEmployeesCommand cmd = new GetEmployeesCommand();
                        cmd.Execute();
                        employees = cmd.GetResult();
                        GetAllOrganizationalUnitsCommand cmdOu = new GetAllOrganizationalUnitsCommand();
                        cmdOu.Execute();
                        units = cmdOu.GetResults();
                        List <Employee> activeEmployees = new List <Employee>();
                        Employee        loggedEmployee  = (Employee)Session["MY_INFORMATION"];
                        string          emailExtension  = loggedEmployee.email.Split('@')[1];
                        if ((loggedEmployee.organizationalUnit.Equals("Directiva")) && (loggedEmployee.positionName.Equals("Director")))
                        {
                            foreach (Employee employee in employees)
                            {
                                if ((employee.status == 1))
                                {
                                    activeEmployees.Add(employee);
                                }
                            }
                        }
                        else if (((loggedEmployee.organizationalUnit.Equals("Administración")) && (loggedEmployee.positionName.Equals("Gerente de Talento Humano"))) || ((loggedEmployee.organizationalUnit.Equals("Contraloría")) && (loggedEmployee.positionName.Equals("Contralor de Gestión"))))
                        {
                            foreach (Employee employee in employees)
                            {
                                if ((employee.status == 1) && (!employee.email.Equals(loggedEmployee.email)))
                                {
                                    if (emailExtension.Equals("mt2005.net"))
                                    {
                                        if (employee.email.Contains(emailExtension))
                                        {
                                            activeEmployees.Add(employee);
                                        }
                                    }
                                    else if (emailExtension.Equals("interatec.com"))
                                    {
                                        if (employee.email.Contains(emailExtension))
                                        {
                                            activeEmployees.Add(employee);
                                        }
                                    }
                                    else
                                    {
                                        if ((!employee.email.Contains("mt2005.net")) && (!employee.email.Contains("interatec.com")))
                                        {
                                            activeEmployees.Add(employee);
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            Response.Redirect("~/site/employees/dashboard.aspx", false);
                        }
                        if (activeEmployees.Count != 0)
                        {
                            String options = "";
                            foreach (Employee employee in activeEmployees)
                            {
                                String itemValue = "ID de trebajador: " + employee.workerId + ". Nombre: " + employee.firstName + " " + employee.lastName;
                                options += "<option value=\"" + employee.id + "\" label=\"" + itemValue + "\" >";
                            }
                            employeeList.InnerHtml = options;
                        }
                        foreach (OrganizationalUnit unit in units)
                        {
                            if ((!unit.name.Equals("Sin unidad")) && (!unit.name.Equals("Directiva")))
                            {
                                organizationalUnitsCkl.Items.Add(new ListItem(unit.name, unit.id.ToString()));
                            }
                        }

                        AccountCoursePermit           accountCoursePermit = new AccountCoursePermit(acpId);
                        GetAccountCoursePermitCommand cmdConsult          = new GetAccountCoursePermitCommand(accountCoursePermit);
                        cmdConsult.Execute();
                        accountCoursePermit = cmdConsult.GetResult();

                        id.Value           = accountCoursePermit.id;
                        name.Value         = accountCoursePermit.name;
                        type.SelectedIndex = accountCoursePermit.type - 1;
                        dateinit.Text      = accountCoursePermit.initDate.ToString("yyyy-MM-dd");
                        string endDate = accountCoursePermit.endDate.ToString("yyyy-MM-dd");
                        if (!(endDate.Equals("9999-12-31")))
                        {
                            dateend.Text = accountCoursePermit.endDate.ToString("yyyy-MM-dd");
                        }
                        admin.Value = accountCoursePermit.administrator.id.ToString();

                        foreach (CostCenter unit in accountCoursePermit.associatedUnits)
                        {
                            for (int i = 0; i < organizationalUnitsCkl.Items.Count; i++)
                            {
                                int acp = Int32.Parse(organizationalUnitsCkl.Items[i].Value);
                                if (acp == unit.organizationalUnit.id)
                                {
                                    ListItem listItem = this.organizationalUnitsCkl.Items[i];
                                    listItem.Selected = true;
                                }
                            }
                        }
                    }
                    else
                    {
                    }
                }
                catch (Exception ex)
                {
                    Session.Remove("CONSULTED_ACP");
                    Response.Redirect("~/site/employees/acp/costcenterlist.aspx", false);
                }
            }
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                try
                {
                    GetEmployeesCommand cmd = new GetEmployeesCommand();
                    cmd.Execute();
                    employees = cmd.GetResult();
                    GetAllOrganizationalUnitsCommand cmdOu = new GetAllOrganizationalUnitsCommand();
                    cmdOu.Execute();
                    units = cmdOu.GetResults();
                    List <Employee> activeEmployees = new List <Employee>();
                    Employee        loggedEmployee  = (Employee)Session["MY_INFORMATION"];
                    string          emailExtension  = loggedEmployee.email.Split('@')[1];
                    if ((loggedEmployee.organizationalUnit.Equals("Directiva")) && (loggedEmployee.positionName.Equals("Director")))
                    {
                        foreach (Employee employee in employees)
                        {
                            if ((employee.status == 1))
                            {
                                activeEmployees.Add(employee);
                            }
                        }
                    }
                    else if (((loggedEmployee.organizationalUnit.Equals("Administración")) && (loggedEmployee.positionName.Equals("Gerente de Talento Humano"))) || ((loggedEmployee.organizationalUnit.Equals("Contraloría")) && (loggedEmployee.positionName.Equals("Contralor de Gestión"))))
                    {
                        foreach (Employee employee in employees)
                        {
                            if ((employee.status == 1) && (!employee.email.Equals(loggedEmployee.email)))
                            {
                                if (emailExtension.Equals("mt2005.net"))
                                {
                                    if (employee.email.Contains(emailExtension))
                                    {
                                        activeEmployees.Add(employee);
                                    }
                                }
                                else if (emailExtension.Equals("interatec.com"))
                                {
                                    if (employee.email.Contains(emailExtension))
                                    {
                                        activeEmployees.Add(employee);
                                    }
                                }
                                else
                                {
                                    if ((!employee.email.Contains("mt2005.net")) && (!employee.email.Contains("interatec.com")))
                                    {
                                        activeEmployees.Add(employee);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        Response.Redirect("~/site/employees/dashboard.aspx", false);
                    }
                    if (activeEmployees.Count != 0)
                    {
                        String options = "";
                        foreach (Employee employee in activeEmployees)
                        {
                            String itemValue = "ID de trebajador: " + employee.workerId + ". Nombre: " + employee.firstName + " " + employee.lastName;
                            options += "<option value=\"" + employee.id + "\" label=\"" + itemValue + "\" >";
                        }
                        employeeList.InnerHtml = options;
                    }

                    foreach (OrganizationalUnit unit in units)
                    {
                        if ((!unit.name.Equals("Sin unidad")) && (!unit.name.Equals("Directiva")))
                        {
                            organizationalUnitsCkl.Items.Add(new ListItem(unit.name, unit.id.ToString()));
                        }
                    }
                }
                catch (Exception ex)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "randomText", "errorSweetAlert('Ha ocurrido un error al cargar la información', 'error')", true);
                }
            }
        }