/// <summary>
        /// Metodo que elimina los centros de costo asociados a una cuenta de la base de datos
        /// </summary>
        /// <returns>Retorna un entero</returns>
        /// <param name="accountCoursePermit">Cuenta/Curso/Permiso del cual se eliminaran los centros de costo asociados</param>
        public int DeleteCostCenter(AccountCoursePermit accountCoursePermit)
        {
            List <ParameterDB> parameters = new List <ParameterDB>();

            try
            {
                parameters.Add(new ParameterDB(ACPResources.id, SqlDbType.VarChar, accountCoursePermit.id, false));
                ExecuteStoredProcedure(ACPResources.DeleteCostCenterStoredProcedure, parameters);
                int result = 200;
                return(result);
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            catch (NullReferenceException ex)
            {
                throw ex;
            }
            catch (ArgumentNullException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// Metodo para obtener la informacion las cuentas, cursos o permisos de la base de datos
        /// </summary>
        /// <returns>Retorna un entero</returns>
        /// <param name="acpToConsult">Cuenta/Curso/Permiso del cual se obtiene la informacion</param>
        public AccountCoursePermit GetAccountCoursePermit(AccountCoursePermit acpToConsult)
        {
            List <ParameterDB>  parameters          = new List <ParameterDB>();
            AccountCoursePermit accountCoursePermit = null;
            DataTable           dataTable           = new DataTable();

            try
            {
                parameters.Add(new ParameterDB(ACPResources.id, SqlDbType.VarChar, acpToConsult.id.ToString(), false));
                dataTable = ExecuteConsultStoredProcedure(ACPResources.GetAccountCoursePermitStoredProcedure, parameters);
                DataRow row = dataTable.Rows[0];
                string  typeStringFormat = "No Facturable";
                int     typeNumeric      = Int32.Parse(row["TYPE"].ToString());
                if (typeNumeric == 1)
                {
                    typeStringFormat = "Facturable";
                }
                Employee employee = new Employee(Int32.Parse(row["EID"].ToString()), row["EFIRSTNAME"].ToString(), row["ELASTNAME"].ToString());
                accountCoursePermit = new AccountCoursePermit(row["ACPID"].ToString(),
                                                              row["NAME"].ToString(),
                                                              typeNumeric,
                                                              typeStringFormat,
                                                              Convert.ToDateTime(row["INITDATE"].ToString()),
                                                              Convert.ToDateTime(row["ENDDATE"].ToString()),
                                                              Int32.Parse(row["STATUS"].ToString()),
                                                              employee);
                List <CostCenter> costCenters = new List <CostCenter>();
                foreach (DataRow unitRow in dataTable.Rows)
                {
                    try
                    {
                        OrganizationalUnit organizationalUnit = new OrganizationalUnit(Int32.Parse(unitRow["OUID"].ToString()), unitRow["OUNAME"].ToString());
                        CostCenter         costCenter         = new CostCenter(organizationalUnit, unitRow["ACPID"].ToString());
                        costCenters.Add(costCenter);
                    }
                    catch (Exception ex)
                    {
                        return(null);
                    }
                }
                accountCoursePermit.associatedUnits = costCenters;
                return(accountCoursePermit);
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            catch (NullReferenceException ex)
            {
                throw ex;
            }
            catch (ArgumentNullException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// Metodo para agregar en la base de datos un nuevo ACP
        /// </summary>
        /// <returns>Retorna un entero</returns>
        /// <param name="acpToInsert">ACP que se va a registrar</param>
        public int AddAccountCoursePermit(AccountCoursePermit acpToInsert)
        {
            List <ParameterDB> parameters = new List <ParameterDB>();

            try
            {
                parameters.Add(new ParameterDB(ACPResources.id, SqlDbType.VarChar, acpToInsert.id.ToString(), false));
                parameters.Add(new ParameterDB(ACPResources.name, SqlDbType.VarChar, acpToInsert.name, false));
                parameters.Add(new ParameterDB(ACPResources.type, SqlDbType.Int, acpToInsert.type.ToString(), false));
                parameters.Add(new ParameterDB(ACPResources.initdate, SqlDbType.Date, acpToInsert.initDate.ToString("yyyy-MM-dd"), false));
                parameters.Add(new ParameterDB(ACPResources.enddate, SqlDbType.Date, acpToInsert.endDate.ToString("yyyy-MM-dd"), false));
                parameters.Add(new ParameterDB(ACPResources.fk_employee, SqlDbType.Int, acpToInsert.administrator.id.ToString(), false));
                parameters.Add(new ParameterDB(ACPResources.exitvalue, SqlDbType.Int, true));
                List <ResultDB> results = ExecuteStoredProcedure(ACPResources.CreateACPStoredProcedure, parameters);
                int             result  = Int32.Parse(results[0].value);
                return(result);
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            catch (NullReferenceException ex)
            {
                throw ex;
            }
            catch (ArgumentNullException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #4
0
        protected void repCostCenter_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            ImageButton action       = (ImageButton)e.CommandSource;
            string      actionString = action.ID;

            if (action.ID.Equals("delete"))
            {
                try
                {
                    string id = ((Label)repCostCenter.Items[e.Item.ItemIndex].FindControl("costCenterId")).Text;
                    AccountCoursePermit acpToDelete = new AccountCoursePermit(id);
                    DeleteACPCommand    cmd         = new DeleteACPCommand(acpToDelete);
                    cmd.Execute();
                    int result = cmd.GetResult();
                    if (result == 200)
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "randomText", "sweetAlert('Se ha eliminado exitosamente', 'success', '/site/employees/acp/costcenterlist.aspx')", true);
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "randomText", "errorSweetAlert('No se ha podido eliminar el elemento seleccionado', 'error')", true);
                    }
                }
                catch (Exception ex)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "randomText", "errorSweetAlert('No se ha podido eliminar el elemento seleccionado', 'error')", true);
                }
            }
            else if (action.ID.Equals("modify"))
            {
                string id = ((Label)repCostCenter.Items[e.Item.ItemIndex].FindControl("costCenterId")).Text;
                Session["CONSULTED_ACP"] = id;
                Response.Redirect("~/site/employees/acp/acpdata.aspx");
            }
        }
        /// <summary>
        /// Metodo para obtener todas las ACP que maneja un empleado
        /// </summary>
        /// <returns>Retorna una lista</returns>
        public List <AccountCoursePermit> GetAllAccountsCoursesPermitsPerEmployee(Employee employee)
        {
            List <ParameterDB>         parameters = new List <ParameterDB>();
            List <AccountCoursePermit> accountsCoursesPermitsList = new List <AccountCoursePermit>();
            DataTable dataTable = new DataTable();

            try
            {
                parameters.Add(new ParameterDB(ACPResources.fk_employee, SqlDbType.Int, employee.id.ToString(), false));
                dataTable = ExecuteConsultStoredProcedure(ACPResources.GetEveryACPPerEmployee, parameters);
                AccountCoursePermit accountCoursePermit = null;
                foreach (DataRow row in dataTable.Rows)
                {
                    try
                    {
                        string typeStringFormat = "No Facturable";
                        int    typeNumeric      = Int32.Parse(row["TYPE"].ToString());
                        if (typeNumeric == 1)
                        {
                            typeStringFormat = "Facturable";
                        }
                        accountCoursePermit = new AccountCoursePermit(row["ID"].ToString(),
                                                                      row["NAME"].ToString(),
                                                                      typeNumeric,
                                                                      typeStringFormat,
                                                                      Convert.ToDateTime(row["INITDATE"].ToString()),
                                                                      Convert.ToDateTime(row["ENDDATE"].ToString()),
                                                                      Int32.Parse(row["STATUS"].ToString()),
                                                                      employee);
                        accountsCoursesPermitsList.Add(accountCoursePermit);
                    }
                    catch (Exception ex)
                    {
                        return(null);
                    }
                }
                return(accountsCoursesPermitsList);
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            catch (NullReferenceException ex)
            {
                throw ex;
            }
            catch (ArgumentNullException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public override void Execute()
 {
     try
     {
         DAOAccountCoursePermit dao = new DAOAccountCoursePermit();
         result = dao.GetAccountCoursePermit(acpToConsult);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #7
0
        /// <summary>
        /// Metodo que obtiene de la base de datos la informacion de una cuenta, curso o permiso por unidad organizacional
        /// </summary>
        /// <returns>Retorna una lista de cuentas,cursos y permisos</returns>
        /// <param name="unit">Unidad Organizacional que maneja las cuentas/cursos/permisos</param>
        public List <AccountCoursePermit> GetAllACPPerOU(OrganizationalUnit unit)
        {
            List <AccountCoursePermit> accountCoursePermits = new List <AccountCoursePermit>();
            DataTable          dataTable  = new DataTable();
            List <ParameterDB> parameters = new List <ParameterDB>();

            try
            {
                parameters.Add(new ParameterDB(TimesheetResources.unit, SqlDbType.Int, unit.id.ToString(), false));
                parameters.Add(new ParameterDB(TimesheetResources.today, SqlDbType.Date, DateTime.Now.ToString("yyyy-MM-dd"), false));
                dataTable = ExecuteConsultStoredProcedure(TimesheetResources.GetAllACPPerOUStoredProcedure, parameters);
                foreach (DataRow row in dataTable.Rows)
                {
                    try
                    {
                        AccountCoursePermit accountCoursePermit = new AccountCoursePermit(row["IDACP"].ToString(), row["NAME"].ToString());
                        accountCoursePermits.Add(accountCoursePermit);
                    }
                    catch (Exception ex)
                    {
                        return(null);
                    }
                }
                return(accountCoursePermits);
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            catch (NullReferenceException ex)
            {
                throw ex;
            }
            catch (ArgumentNullException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// Metodo para obtener todas las ACP de la base de datos
        /// </summary>
        /// <returns>Retorna una lista</returns>
        public List <AccountCoursePermit> GetAllAccountsCoursesPermits()
        {
            List <AccountCoursePermit> accountsCoursesPermitsList = new List <AccountCoursePermit>();
            DataTable dataTable = new DataTable();

            try
            {
                dataTable = ExecuteConsultStoredProcedure(ACPResources.GetAllACPStoredProcedure);
                AccountCoursePermit accountCoursePermit = null;
                foreach (DataRow row in dataTable.Rows)
                {
                    try
                    {
                        string typeStringFormat = "No Facturable";
                        int    typeNumeric      = Int32.Parse(row["TYPE"].ToString());
                        if (typeNumeric == 1)
                        {
                            typeStringFormat = "Facturable";
                        }
                        Employee employee = new Employee(Int32.Parse(row["EID"].ToString()), row["EFIRSTNAME"].ToString(), row["ELASTNAME"].ToString());
                        accountCoursePermit = new AccountCoursePermit(row["ACPID"].ToString(),
                                                                      row["NAME"].ToString(),
                                                                      typeNumeric,
                                                                      typeStringFormat,
                                                                      Convert.ToDateTime(row["INITDATE"].ToString()),
                                                                      Convert.ToDateTime(row["ENDDATE"].ToString()),
                                                                      Int32.Parse(row["STATUS"].ToString()),
                                                                      employee);
                        List <CostCenter>  costCenters        = new List <CostCenter>();
                        OrganizationalUnit organizationalUnit = new OrganizationalUnit(Int32.Parse(row["OUID"].ToString()), row["OUNAME"].ToString());
                        CostCenter         costCenter         = new CostCenter(organizationalUnit, row["ACPID"].ToString());
                        accountCoursePermit.associatedUnits = costCenters;
                        bool existAcp = false;
                        AccountCoursePermit account = new AccountCoursePermit();
                        int position    = 0;
                        int positionAcp = 0;
                        foreach (AccountCoursePermit acp in accountsCoursesPermitsList)
                        {
                            if (acp.id.Equals(accountCoursePermit.id))
                            {
                                acp.associatedUnits.Add(costCenter);
                                existAcp    = true;
                                positionAcp = position;
                                account     = acp;
                            }
                            position++;
                        }
                        if (existAcp)
                        {
                            accountsCoursesPermitsList[positionAcp] = account;
                        }
                        else
                        {
                            accountCoursePermit.associatedUnits.Add(costCenter);
                            accountsCoursesPermitsList.Add(accountCoursePermit);
                        }
                    }
                    catch (Exception ex)
                    {
                        return(null);
                    }
                }
                return(accountsCoursesPermitsList);
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            catch (NullReferenceException ex)
            {
                throw ex;
            }
            catch (ArgumentNullException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #9
0
 public DeleteACPCommand(AccountCoursePermit acpToDelete)
 {
     this.acpToDelete = acpToDelete;
 }
Beispiel #10
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);
                }
            }
        }
 public GetAccountCoursePermitCommand(AccountCoursePermit acpToConsult)
 {
     this.acpToConsult = acpToConsult;
 }
Beispiel #12
0
 public CreateNewACPCommand(AccountCoursePermit acpToInsert)
 {
     this.acpToInsert = acpToInsert;
 }
Beispiel #13
0
        /// <summary>
        /// Metodo que obtiene de la base de datos la informacion de una carga de trabajo dada una hoja de tiempo
        /// </summary>
        /// <returns>Retorna una hoja de tiempo</returns>
        /// <param name="timesheet">Hoja de tiempo en donde se encuentran las cargas de trabajo</param>
        public Timesheet GetAllWorkloadsByTimesheet(Timesheet timesheet)
        {
            List <Workload>    workloads  = new List <Workload>();
            DataTable          dataTable  = new DataTable();
            List <ParameterDB> parameters = new List <ParameterDB>();

            try
            {
                parameters.Add(new ParameterDB(TimesheetResources.id, SqlDbType.BigInt, timesheet.id.ToString(), false));
                dataTable = ExecuteConsultStoredProcedure(TimesheetResources.GetAllWorkloadsByTimesheet, parameters);
                Workload workload = null;
                foreach (DataRow row in dataTable.Rows)
                {
                    try
                    {
                        AccountCoursePermit accountCoursePermit = new AccountCoursePermit(row["IDACP"].ToString(), row["NAME"].ToString());
                        timesheet.initDate = Convert.ToDateTime(row["INITDATE"].ToString());
                        timesheet.endDate  = Convert.ToDateTime(row["ENDDATE"].ToString());
                        workload           = new Workload(Int32.Parse(row["ID"].ToString()),
                                                          Int32.Parse(row["DAY1"].ToString()),
                                                          Int32.Parse(row["DAY2"].ToString()),
                                                          Int32.Parse(row["DAY3"].ToString()),
                                                          Int32.Parse(row["DAY4"].ToString()),
                                                          Int32.Parse(row["DAY5"].ToString()),
                                                          Int32.Parse(row["DAY6"].ToString()),
                                                          Int32.Parse(row["DAY7"].ToString()),
                                                          Int32.Parse(row["DAY8"].ToString()),
                                                          Int32.Parse(row["DAY9"].ToString()),
                                                          Int32.Parse(row["DAY10"].ToString()),
                                                          Int32.Parse(row["DAY11"].ToString()),
                                                          Int32.Parse(row["DAY12"].ToString()),
                                                          Int32.Parse(row["DAY13"].ToString()),
                                                          Int32.Parse(row["DAY14"].ToString()),
                                                          Int32.Parse(row["DAY15"].ToString()),
                                                          Int32.Parse(row["DAY16"].ToString()),
                                                          row["STATUS"].ToString(),
                                                          timesheet,
                                                          accountCoursePermit);
                        workloads.Add(workload);
                    }
                    catch (Exception ex)
                    {
                        return(null);
                    }
                }
                timesheet.workloads = workloads;
                dataTable           = ExecuteConsultStoredProcedure(TimesheetResources.GetTimesheetByIDStoredProcedure, parameters);
                foreach (DataRow row in dataTable.Rows)
                {
                    try
                    {
                        timesheet.initDate = Convert.ToDateTime(row["INITDATE"].ToString());
                        timesheet.endDate  = Convert.ToDateTime(row["ENDDATE"].ToString());
                        timesheet.comment  = row["COMMENT"].ToString();
                        timesheet.status   = row["STATUS"].ToString();
                    }
                    catch (Exception ex)
                    {
                        return(null);
                    }
                }
                return(timesheet);
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            catch (NullReferenceException ex)
            {
                throw ex;
            }
            catch (ArgumentNullException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// Metodo que obtiene de la base de datos la informacion de la carga de trabajo por cuenta/curso/permiso
        /// </summary>
        /// <returns>Retorna una lista de cargas de trabajo</returns>
        /// <param name="id">Id de la cuenta/curso/permiso</param>
        /// <param name="initDate">Fecha de inicio</param>
        /// <param name="endDate">Fecha de fin</param>
        public List <Workload> GetAllWorkloadsByACP(string id, DateTime initDate, DateTime endDate)
        {
            List <Workload>    workloads  = new List <Workload>();
            DataTable          dataTable  = new DataTable();
            List <ParameterDB> parameters = new List <ParameterDB>();

            try
            {
                parameters.Add(new ParameterDB(ACPManagementResources.id, SqlDbType.VarChar, id, false));
                parameters.Add(new ParameterDB(ACPManagementResources.initdate, SqlDbType.Date, initDate.ToString("yyyy-MM-dd"), false));
                parameters.Add(new ParameterDB(ACPManagementResources.enddate, SqlDbType.Date, endDate.ToString("yyyy-MM-dd"), false));
                dataTable = ExecuteConsultStoredProcedure(ACPManagementResources.GetWorkloadPerACPStoredProcedure, parameters);
                Workload workload = null;
                foreach (DataRow row in dataTable.Rows)
                {
                    try
                    {
                        AccountCoursePermit accountCoursePermit = new AccountCoursePermit(id);
                        Timesheet           timesheet           = new Timesheet(Int64.Parse(row["TID"].ToString()));
                        Employee            employee            = new Employee(Int32.Parse(row["EID"].ToString()), row["EFIRSTNAME"].ToString(), row["ELASTNAME"].ToString());
                        timesheet.initDate = Convert.ToDateTime(initDate);
                        timesheet.endDate  = Convert.ToDateTime(endDate);
                        timesheet.employee = employee;
                        workload           = new Workload(Int32.Parse(row["ID"].ToString()),
                                                          Int32.Parse(row["DAY1"].ToString()),
                                                          Int32.Parse(row["DAY2"].ToString()),
                                                          Int32.Parse(row["DAY3"].ToString()),
                                                          Int32.Parse(row["DAY4"].ToString()),
                                                          Int32.Parse(row["DAY5"].ToString()),
                                                          Int32.Parse(row["DAY6"].ToString()),
                                                          Int32.Parse(row["DAY7"].ToString()),
                                                          Int32.Parse(row["DAY8"].ToString()),
                                                          Int32.Parse(row["DAY9"].ToString()),
                                                          Int32.Parse(row["DAY10"].ToString()),
                                                          Int32.Parse(row["DAY11"].ToString()),
                                                          Int32.Parse(row["DAY12"].ToString()),
                                                          Int32.Parse(row["DAY13"].ToString()),
                                                          Int32.Parse(row["DAY14"].ToString()),
                                                          Int32.Parse(row["DAY15"].ToString()),
                                                          Int32.Parse(row["DAY16"].ToString()),
                                                          row["STATUS"].ToString(),
                                                          timesheet,
                                                          accountCoursePermit);
                        workloads.Add(workload);
                    }
                    catch (Exception ex)
                    {
                        return(null);
                    }
                }
                return(workloads);
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            catch (NullReferenceException ex)
            {
                throw ex;
            }
            catch (ArgumentNullException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #15
0
 public DeleteCostCenterCommand(AccountCoursePermit accountCoursePermit)
 {
     this.accountCoursePermit = accountCoursePermit;
 }
Beispiel #16
0
        protected void acceptBtn_Click(object sender, EventArgs e)
        {
            string        acpId         = id.Value;
            string        acpName       = name.Value;
            string        acpType       = type.SelectedValue;
            String        init          = dateinit.Text;
            String        end           = dateend.Text;
            string        administrator = admin.Value;
            List <string> selectedUnits = organizationalUnitsCkl.Items.Cast <ListItem>()
                                          .Where(li => li.Selected)
                                          .Select(li => li.Value)
                                          .ToList();

            if ((!acpId.Equals("")) && (!acpName.Equals("")) && (!init.Equals("")) && (!administrator.Equals("")) && (selectedUnits.Count != 0))
            {
                if (end.Equals(""))
                {
                    end = "9999-12-31";
                }
                double admin    = 0;
                bool   isNumber = double.TryParse(administrator, out admin);
                if (isNumber)
                {
                    int adminInt = Convert.ToInt32(admin);
                    try
                    {
                        GetEmployeesCommand cmd = new GetEmployeesCommand();
                        cmd.Execute();
                        employees = cmd.GetResult();
                        bool adminExist = false;
                        foreach (Employee employee in employees)
                        {
                            if (employee.id == adminInt)
                            {
                                adminExist = true;
                            }
                        }
                        if (adminExist)
                        {
                            try
                            {
                                Employee            employee    = new Employee(adminInt);
                                AccountCoursePermit acpToUpdate = new AccountCoursePermit(acpId, acpName, Int32.Parse(acpType), Convert.ToDateTime(init),
                                                                                          Convert.ToDateTime(end), employee);
                                DeleteCostCenterCommand command = new DeleteCostCenterCommand(acpToUpdate);
                                command.Execute();
                                int response = command.GetResult();
                                if (response == 200)
                                {
                                    UpdateAccountCoursePermitCommand _cmd = new UpdateAccountCoursePermitCommand(acpToUpdate);
                                    _cmd.Execute();
                                    int result = _cmd.GetResult();
                                    if (result == 200)
                                    {
                                        foreach (string unit in selectedUnits)
                                        {
                                            int        unitId     = Int32.Parse(unit);
                                            CostCenter costCenter = new CostCenter(unitId, acpToUpdate.id);
                                            CreateNewCostCenterCommand cmdCostCenter = new CreateNewCostCenterCommand(costCenter);
                                            cmdCostCenter.Execute();
                                        }
                                        ScriptManager.RegisterStartupScript(this, this.GetType(), "randomText", "sweetAlert('Se ha modificado exitosamente', 'success', '/site/employees/acp/acpdata.aspx')", true);
                                    }
                                    else
                                    {
                                        ScriptManager.RegisterStartupScript(this, this.GetType(), "randomText", "errorSweetAlert('Se ha generado un error procesando su solicitud', 'error')", true);
                                    }
                                }
                                else
                                {
                                    ScriptManager.RegisterStartupScript(this, this.GetType(), "randomText", "errorSweetAlert('El código ingresado ya se encuentra registrado en el sistema', 'error')", true);
                                }
                            }
                            catch (Exception ex)
                            {
                                ScriptManager.RegisterStartupScript(this, this.GetType(), "randomText", "errorSweetAlert('Se ha generado un error procesando su solicitud', 'error')", true);
                            }
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "randomText", "errorSweetAlert('El empleado seleccionado no se encuentra registrado en el sistema', 'error')", true);
                        }
                    }
                    catch (Exception ex)
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "randomText", "errorSweetAlert('Se ha generado un error procesando su solicitud, 'error'')", true);
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "randomText", "errorSweetAlert('El campo de administrador no tiene formato númerico', 'error')", true);
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "randomText", "errorSweetAlert('Existen campos vacíos en el formulario', 'error')", true);
            }
        }
 public UpdateAccountCoursePermitCommand(AccountCoursePermit acpToModify)
 {
     this.acpToModify = acpToModify;
 }