//Listing 7-7. Performing screen-level validation
 partial void Issue_Validate(ScreenValidationResultsBuilder results)
 {
     if (this.Issue.Priority == null)
     {
         results.AddPropertyError("Priority must be entered");
     }
 }
        partial void Orders_Validate(ScreenValidationResultsBuilder results)
        {
            /*
             * This is where the business logic would have gone
             * Compare this code to the code in OrderScreenValidationController.ValidateOrders
             *
             * foreach (var o in this.Orders)
             * {
             *  if (o.Customer == null)
             *      results.AddPropertyError("An order requires a customer.");
             *
             *  if (o.Customer == null)
             *      results.AddPropertyError("An order requires a product.");
             *
             *  if (o.Product != null && !o.Product.Available)
             *      results.AddPropertyError(o.Product.Name + " is not available to order.");
             * }
             */
            var controller = new OrderScreenValidationController(this);

            IEnumerable <string> errorMessages;

            if (!controller.ValidateOrders(out errorMessages))
            {
                foreach (var error in errorMessages)
                {
                    results.AddPropertyError(error);
                }
            }
        }
Ejemplo n.º 3
0
		partial void ArtikellisteCollection_Validate(ScreenValidationResultsBuilder results)
		{
			if (this.DataWorkspace.ApplicationData.Details.HasChanges)
			{
				EntityChangeSet changeSet = this.DataWorkspace.ApplicationData.Details.GetChanges();

				foreach (Rechnungen entity in changeSet.AddedEntities.OfType<Rechnungen>())
				{
					if (entity.ArtikellisteCollection.Count() == 0)
					{
						//entity.Details.DiscardChanges(); 
						//results.AddScreenResult("Eine Bestellung muß mindestens eine Position beinhalten.", ValidationSeverity.Warning);
						//results.AddPropertyError("Eine Bestellung muß mindestens eine Position beinhalten.");//, entity.Details.Properties.ArtikellisteCollection);
					}
				}
				foreach (Rechnungen entity in changeSet.ModifiedEntities.OfType<Rechnungen>())
				{
					if (entity.ArtikellisteCollection.Count() == 0)
					{
						entity.Details.DiscardChanges();
						results.AddScreenResult("Eine Bestellung muß mindestens eine Position beinhalten.", ValidationSeverity.Error);
						//results.AddPropertyError("<Fehlermeldung>");
					}
				}
			}
		}
Ejemplo n.º 4
0
        partial void ArtikellisteCollection_Validate(ScreenValidationResultsBuilder results)
        {
            if (this.DataWorkspace.ApplicationData.Details.HasChanges)
            {
                EntityChangeSet changeSet = this.DataWorkspace.ApplicationData.Details.GetChanges();

                foreach (Rechnungen entity in changeSet.AddedEntities.OfType <Rechnungen>())
                {
                    if (entity.ArtikellisteCollection.Count() == 0)
                    {
                        //entity.Details.DiscardChanges();
                        //results.AddScreenResult("Eine Bestellung muß mindestens eine Position beinhalten.", ValidationSeverity.Warning);
                        //results.AddPropertyError("Eine Bestellung muß mindestens eine Position beinhalten.");//, entity.Details.Properties.ArtikellisteCollection);
                    }
                }
                foreach (Rechnungen entity in changeSet.ModifiedEntities.OfType <Rechnungen>())
                {
                    if (entity.ArtikellisteCollection.Count() == 0)
                    {
                        entity.Details.DiscardChanges();
                        results.AddScreenResult("Eine Bestellung muß mindestens eine Position beinhalten.", ValidationSeverity.Error);
                        //results.AddPropertyError("<Fehlermeldung>");
                    }
                }
            }
        }
 partial void IDGERENCIA_Validate(ScreenValidationResultsBuilder results)
 {
     try
     {
         this.IDGERENCIA = this.Gerencia.Id_Gerencia;//Actualizar el parámetro de búsqueda
     }
     catch { }
 }
 partial void IDAREA_Validate(ScreenValidationResultsBuilder results)
 {
     try
     {
         this.IDAREA = this.Área.Id_Area;//Actualizar el parámetro de búsqueda
     }
     catch { }
 }
Ejemplo n.º 7
0
 //<Snippet1>
 partial void CityCode_Validate
     (ScreenValidationResultsBuilder results)
 {
     if (this.CityCode.Length < 3)
     {
         results.AddPropertyError("This string must have at least 3 letters.");
     }
 }
Ejemplo n.º 8
0
 partial void sumOfActivities_Validate(ScreenValidationResultsBuilder results)
 {
     sumOfActivities = 0;
     List<Activity> list = this.SchoolPart.Activities.ToList();
     foreach (Activity activity in list)
     {
         if (activity.ActivityDate >= fromDate && activity.ActivityDate <= toDate)
             sumOfActivities = sumOfActivities + 1;
     }
 }
Ejemplo n.º 9
0
        partial void sumOfClasses_Validate(ScreenValidationResultsBuilder results)
        {
            int sum = 0;
            List<Activity> list = this.SchoolPart.Activities.ToList();
            foreach (Activity activity in list)
            {
                if (activity.ActivityDate >= fromDate && activity.ActivityDate <= toDate)
                    sum = sum + activity.TotalNumberOfClasses;

            }
            sumOfClasses = sum;

        }
 partial void Division_Area_Validate(ScreenValidationResultsBuilder results)
 {
     // results.AddPropertyError("<Mensaje de error>");
     /*
     try
     {
         Id_Area = this.Área.Id_Area;
         Id_SubGerencia = -1;
         Id_Gerencia = -1;
         //this.NúmeroDeSolicitudesArea = this.SOLICITUDES.Count();
     }
     catch { }
      * */
 }
Ejemplo n.º 11
0
        partial void sumOfCounselors_Validate(ScreenValidationResultsBuilder results)
        {
            int sum = 0;
            DateTime timeNow = this.fromDate;
            DateTime timeEnd = this.toDate;
            List<Activity> list = this.SchoolPart.Activities.ToList();
            foreach (Activity activity in list)
            {
                if (activity.ActivityDate >= fromDate && activity.ActivityDate <= toDate)
                    sum = sum + activity.NumberOfCounselor;

            }
            sumOfCounselors = sum;

        }
Ejemplo n.º 12
0
        partial void Issue_Validate(ScreenValidationResultsBuilder results)
        {
            //Listing 5-8. Performing Screen-Level Validation
            if (this.Issue.Priority == null)
            {
                results.AddScreenError("Priority must be entered");
            }

            //Listing 5-9. Validating Deletions
            if (Issue.Details.EntityState == EntityState.Deleted &&
                Issue.IssueStatus != null &&
                Issue.IssueStatus.StatusDescription == "Open")
            {
                Issue.Details.DiscardChanges();
                results.AddScreenError("Unable to delete open issue");
            }
        }
Ejemplo n.º 13
0
 //<Snippet3>
 partial void Customers_Validate(ScreenValidationResultsBuilder results)
 {
     if (this.DataWorkspace.NorthwindData.Details.HasChanges)
     {
         EntityChangeSet changeSet =
             this.DataWorkspace.NorthwindData.Details.GetChanges();
         foreach (IEntityObject entity in changeSet.DeletedEntities.OfType <Customer>())
         {
             Customer cust = (Customer)entity;
             if (cust.Country == "USA")
             {
                 entity.Details.DiscardChanges();
                 results.AddScreenResult("Unable to remove this customer. " +
                                         "Cannot delete customers that are located in the USA.",
                                         ValidationSeverity.Informational);
             }
         }
     }
 }
        partial void Área_Validate(ScreenValidationResultsBuilder results)
        {
            try
            {
                if (this.CargoRolPrivadoItemProperty.EsGerente == false && this.CargoRolPrivadoItemProperty.EsSubgerente == false && this.CargoRolPrivadoItemProperty.EsJefeDeArea == false)
                {
                    this.FindControl("CargoRolPrivadoItemProperty_EsGerente").IsEnabled = true;
                    this.FindControl("CargoRolPrivadoItemProperty_EsSubgerente").IsEnabled = true;
                    this.FindControl("CargoRolPrivadoItemProperty_EsJefeDeArea").IsEnabled = true;
                    this.FindControl("Gerencia").IsEnabled = false;
                    this.FindControl("Subgerencia").IsEnabled = false;
                    this.FindControl("Área").IsEnabled = true;
                    this.Subgerencia = null;//Limpia el campo subgerencia
                    this.Gerencia = null;//Limpia el campo subgerencia
                }

                if (this.Área.Division_SubGerenciaItem == null)
                {
                    this.Subgerencia = null;

                    if (this.Área.Division_GerenciaItem != null)//Muestra a que gerencia pertenece el área
                    {
                        this.Gerencia = this.Área.Division_GerenciaItem;
                    }
                }
                else
                {
                    this.Subgerencia = this.Área.Division_SubGerenciaItem;//Muestra a que subgerencia pertenece el área

                    if (this.Área.Division_SubGerenciaItem.Division_GerenciaItem != null)//Muestra a que gerencia pertenece el área
                    {
                        this.Gerencia = this.Área.Division_SubGerenciaItem.Division_GerenciaItem;
                    }
                }
            }catch { }
        }
        partial void Dig_Verificador_Validate(ScreenValidationResultsBuilder results) // validador de run
        {
            try
            {
                string rutAux = this.RUN; //control que contenga rut
                int suma = 0;
                try
                {
                    for (int x = rutAux.Length - 1; x >= 0; x--)
                        suma += int.Parse(char.IsDigit(rutAux[x]) ? rutAux[x].ToString() : "0") * (((rutAux.Length - (x + 1)) % 6) + 2);
                }
                catch { }
                int numericDigito = (11 - suma % 11);
                string digito = numericDigito == 11 ? "0" : numericDigito == 10 ? "K" : numericDigito.ToString();
                string Dig = digito;
                Regex expresion = new Regex("^([0-9]+-[0-9K])$");
                string dv = this.Dig_Verificador.ToUpper(); //control que contenga DV

                if (!expresion.IsMatch(rutAux) && dv != Dig)
                {
                    results.AddPropertyError("Run invalido");
                }
            }
            catch { }
        }
Ejemplo n.º 16
0
 //Valida que la justificacion(Observaciones) para Horas extras y permiso no sean vacias
 partial void OBSERVACIONES_Validate(ScreenValidationResultsBuilder results)
 {
     if (TIPOSOLICITUD == 3 || TIPOSOLICITUD == 4)
     {
         if (this.OBSERVACIONES == null) { results.AddPropertyError("La justificación no puede quedar vacía"); }
     }
 }
Ejemplo n.º 17
0
 //Guarda en el campo el valor del choice list de la pantalla
 partial void AdministrativoHasta_Validate(ScreenValidationResultsBuilder results)
 {
     // results.AddPropertyError("<Mensaje de error>");
     this.SOLICITUD.AdministrativoHasta = this.AdministrativoHasta;
 }
        partial void Solicitud_Detalle_OtroPermiso_Validate(ScreenValidationResultsBuilder results)
        {
            // results.AddPropertyError("<Mensaje de error>");

            if (TIPOSOLICITUD == 4)// si la solicitud es del tipo horas extras
            {

                if (this.Solicitud_Detalle_OtroPermiso.Inicio.Day <= DateTime.Today.Day)
                {

                    results.AddPropertyError("La fecha de inicio debe ser después de hoy");

                }

                if (this.Solicitud_Detalle_OtroPermiso.Termino < this.Solicitud_Detalle_OtroPermiso.Inicio)
                {

                    results.AddPropertyError("La fecha de término debe ser después de la fecha de inicio");

                }
            }
        }
Ejemplo n.º 19
0
        //Validaciones para el campo requiere prestamo en las solicitudes de vacaciones
        partial void RequierePrestamo_Validate(ScreenValidationResultsBuilder results)
        {
            if (this.RequierePrestamo == false)
            {
                try
                {
                    this.FindControl("SOLICITUDESItemProperty_Prestamo1").IsEnabled = false;
                }
                catch { }

                if (TIPOSOLICITUD == 2)// si la solicitud es del tipo vacaciones
                {
                    this.SOLICITUD.Prestamo = null; //Limpiar el valor del campo prestamo
                }
            }
            else if (this.RequierePrestamo == true)
            {
                try
                {
                    this.FindControl("SOLICITUDESItemProperty_Prestamo1").IsEnabled = true;

                    if (this.SOLICITUD.Prestamo == null)
                    {
                        //Si la casilla es verdadera, el campo debe tener algún valor
                        results.AddPropertyError("El préstamo a solicitar no puede ser vacío"); 
                    }
                }
                catch { }
            }
        }
 partial void NuevoComentarioRechazar_Validate(ScreenValidationResultsBuilder results)
 {
     // results.AddPropertyError("<Mensaje de error>");
     if (this.NuevoComentarioRechazar != null)
     {
         if (this.NuevoComentarioRechazar.Length > 100) { results.AddPropertyError("<El comentario no debe pasar los 100 caracteres>"); }
     }
 }
        partial void SOLICITUDES_Validate(ScreenValidationResultsBuilder results)
        {
            // results.AddPropertyError("<Mensaje de error>");
            this.NumDeSolicitudes = this.SOLICITUDES.Count();
            this.HorasExtrasTotal = (from s in this.SOLICITUDES where s.HorasExtras == true select s).Count();
            this.PermisosTotal = (from s in this.SOLICITUDES where s.OtroPermiso == true select s).Count();
            this.VacacionesTotal = (from s in this.SOLICITUDES where s.Vacaciones == true select s).Count();
            this.DíasAdministrativosTotal = (from s in this.SOLICITUDES where s.Administrativo == true select s).Count();

            try
            {
                this.HorasExtrasHoras = (from s in this.SOLICITUDES where s.HorasExtras == true select s.HorasTrabajadas).Sum().Value;
                this.PermisosDías = (from s in this.SOLICITUDES where s.OtroPermiso == true select s.DiasSolicitados).Sum().Value;
                this.VacacionesDias = (from s in this.SOLICITUDES where s.Vacaciones == true select s.DiasSolicitados).Sum().Value;
                this.DíasAdministrativosDías = (from s in this.SOLICITUDES where s.Administrativo == true select s.DiasSolicitados).Sum().Value;
            }
            catch { }

        }
        partial void FechaSolicitudDesde_Validate(ScreenValidationResultsBuilder results)
        {
            // results.AddPropertyError("<Mensaje de error>");
            /*
            if(this.FechaSolicitudDesde > this.FechaSolicitudHasta)
            {
                results.AddPropertyError("Las fechas deben ser en orden cronológico.");
            }

            if (this.FechaSolicitudDesde == null &&  this.FechaSolicitudHasta == null)
            {
                results.AddPropertyError("Las fechas no pueden estar en blanco");
            }
            */
        }
        partial void FiltroEstados_Validate(ScreenValidationResultsBuilder results)
        {
            //Si se escoge alguna de las tres opciones de búsqueda, no aplicar los filtros FALSAS ni VERDADERAS
            //if (FiltroEstados != null) { this.FALSAS = null; this.VERDADERAS = null; } 
            //Al cambiar la opción se cambian los filtros
            if (FiltroEstados == "Rechazada") {

                this.Completada = false;
                this.Rechazada = true;
                this.Cancelada = false;
                this.Caducada = false;
                this.Rebajada = false; 
            }
            else
                if (FiltroEstados == "Aprobada") {

                    this.Completada = true;
                    this.Rechazada = false;
                    this.Cancelada = false;
                    this.Caducada = false;
                    this.Rebajada = false; 
                }
                else
                    if (FiltroEstados == "En aprobacion") {

                        this.Completada = false;
                        this.Rechazada = false;
                        this.Cancelada = false;
                        this.Caducada = false;
                        this.Rebajada = false; 
                    }
                    else
                        if (FiltroEstados == "Cancelada") {

                            this.Completada = false;
                            this.Rechazada = false;
                            this.Cancelada = true;
                            this.Caducada = false;
                            this.Rebajada = false; 
                        }
                        else
                            if (FiltroEstados == "Anulada") {

                                this.Completada = false;
                                this.Rechazada = false;
                                this.Cancelada = false;
                                this.Caducada = true;
                                this.Rebajada = false; 
                            }
                            else
                                if (FiltroEstados == "Rebajada") {

                                    this.Completada = false;
                                    this.Rechazada = false;
                                    this.Cancelada = false;
                                    this.Caducada = false;
                                    this.Rebajada = true; 
                                }
                                else
                            if (FiltroEstados == "Todas")
                            {
                                this.Cancelada = null;

                                //this.FechaSolicitudDesde = null;
                                //this.FechaSolicitudHasta = null;
                                
                                this.Administrativo = true;
                                this.Vacaciones = true;
                                this.OtroPermiso = true;
                                this.HorasExtras = true;
                                this.FiltroEstados = null;

                                this.Completada = null;
                                this.Rechazada = null;
                                this.Cancelada = null;
                                this.Caducada = null;
                                this.Rebajada = null; 
                                //this.Solicitud_Header.Load();
                            }
        }
 partial void Área_Validate(ScreenValidationResultsBuilder results)
 {
     // results.AddPropertyError("<Mensaje de error>");
     try
     {
         Id_Area = this.Área.Id_Area;
         Id_SubGerencia = -1;
         Id_Gerencia = -1;
         this.SubGerencia = null;
         this.Gerencia = null;
     }
     catch { }
 }
 partial void SolicitudesConFiltro_Validate(ScreenValidationResultsBuilder results)
 {
     // results.AddPropertyError("<Mensaje de error>");
     try
     {
         this.EmpleadoFiltroSolicitudes = this.PersonalBajoMiSupervision.SelectedItem.Rut_Persona;
         this.NombreEmpleadoSeleccionado = this.PersonalBajoMiSupervision.SelectedItem.NombreAD;
     }
     catch { }
 }
        partial void Solicitud_Detalle_Vacaciones_Validate(ScreenValidationResultsBuilder results)
        {
            if (TIPOSOLICITUD == 2)// si la solicitud es del tipo vacaciones
            {

                if (InvocarSaldoVacaciones == true) { this.ConsultarSaldo_Execute(); }
                InvocarSaldoVacaciones = false;

                if (TIPOSOLICITUD == 2)// si la solicitud es del tipo vacaciones
                {
                    if (this.Solicitud_Detalle_Vacaciones.Prestamo.HasValue)
                    {
                        if (this.Solicitud_Detalle_Vacaciones.Prestamo.Value < 0 || this.Solicitud_Detalle_Vacaciones.Prestamo.Value > 50)
                        {
                            results.AddPropertyError("El prestamo debe ser entre 0 y 50");
                        }
                    }
                }

                //GUARDAR LOS REGISTROS DE FERIADOS EN UN ARREGLO

                DateTime[] FERIADOS = new DateTime[50];//DateTime[] FERIADOS = new DateTime[] { };
                int dia; int mes; int i = 0;

                foreach( FeriadosItem feriado in this.Feriados ){

                    dia = feriado.Feriado.Day;
                    mes = feriado.Feriado.Month;
                    DateTime DiaAux = new DateTime(DateTime.Today.Year, mes, dia);//Cambia el año del registro al año actual
                    FERIADOS[i] = DiaAux;
                
                    i++;
            
                }

                this.Solicitud_Detalle_Vacaciones.NumeroDias = BusinessDaysUntil(this.Solicitud_Detalle_Vacaciones.Inicio,this.Solicitud_Detalle_Vacaciones.Termino,FERIADOS);
            }
        }
Ejemplo n.º 27
0
 //<Snippet2>
 partial void ApprovedCheckBox_Validate
     (ScreenValidationResultsBuilder results)
 {
     ApprovedCheckBox = false;
 }
        partial void HORASTRABAJADAS_Validate(ScreenValidationResultsBuilder results)
        {
            
            // results.AddPropertyError("<Mensaje de error>");
            if (this.HORASTRABAJADAS <= 0 || this.HORASTRABAJADAS == null)
            {

                results.AddPropertyError("Horas trabajadas debe ser mayor a 0");
            }
            
        }
 partial void InvocarEmailAD_Validate(ScreenValidationResultsBuilder results) //Invocador para la consulta del email del usuario en active directory
 {
     if (InvocarEmailAD == true)
     {
         this.ConsultarEmailUsuarioAD_Execute();
         InvocarEmailAD = false;
     }
 }
        partial void CargoRolPrivadoItemProperty_Validate(ScreenValidationResultsBuilder results)
        {
            try
            {
                // results.AddPropertyError("<Mensaje de error>");
                if (this.CargoRolPrivadoItemProperty.EsGerente == true)
                {
                    //Desabilita los campos
                    this.FindControl("CargoRolPrivadoItemProperty_EsSubgerente").IsEnabled = false;
                    this.FindControl("CargoRolPrivadoItemProperty_EsJefeDeArea").IsEnabled = false;

                    this.FindControl("Subgerencia").IsEnabled = false;
                    this.FindControl("Área").IsEnabled = false;

                    this.FindControl("Gerencia").IsEnabled = true;

                    this.Área = null;//Limpia el campo área
                    this.Subgerencia = null;//Limpia el campo subgerencia

                    if (this.Gerencia == null)
                    {
                        results.AddPropertyError("Debe escoger una gerencia");
                    }

                    if (this.CargoRolPrivadoGerente.First() != this.CargoRolPrivadoItemProperty)//Error si ya existe otro cargo con la misma asignación de supervisión
                    {
                        if (this.CargoRolPrivadoGerente.Count() != 0)
                        {
                            results.AddPropertyError("Ya existe el cargo ' " + CargoRolPrivadoGerente.First().Nombre + " ' el cual tiene asignado 'es gerente' para ' " + this.Gerencia.Nombre + " '. No puede haber más de un cargo con la asignación de gerente para la misma gerencia.");
                        }
                    }
                }
                else

                    if (this.CargoRolPrivadoItemProperty.EsSubgerente == true)
                    {

                        //Desabilita los campos
                        this.FindControl("CargoRolPrivadoItemProperty_EsGerente").IsEnabled = false;
                        this.FindControl("CargoRolPrivadoItemProperty_EsJefeDeArea").IsEnabled = false;

                        this.FindControl("Gerencia").IsEnabled = false;
                        this.FindControl("Área").IsEnabled = false;

                        this.FindControl("Subgerencia").IsEnabled = true;

                        if (this.Subgerencia == null)
                        {
                            results.AddPropertyError("Debe escoger una subgerencia");
                        }

                        if (this.CargoRolPrivadoSubgerente.First() != this.CargoRolPrivadoItemProperty)//Error si ya existe otro cargo con la misma asignación de supervisión
                        {
                            if (this.CargoRolPrivadoSubgerente.Count() != 0)
                            {
                                results.AddPropertyError("Ya existe el cargo ' " + CargoRolPrivadoSubgerente.First().Nombre + " ' el cual tiene asignado 'es subgerente' para ' " + this.Subgerencia.Nombre + " '. No puede haber más de un cargo con la asignación de subgerente para la misma subgerencia.");
                            }
                        }

                        this.Área = null;//Limpia el campo área
                        this.Gerencia = this.Subgerencia.Division_GerenciaItem;//Muestra a que gerencia pertenece el área
                    }
                    else

                        if (this.CargoRolPrivadoItemProperty.EsJefeDeArea == true)
                        {
                            //Desabilita los campos
                            this.FindControl("CargoRolPrivadoItemProperty_EsGerente").IsEnabled = false;
                            this.FindControl("CargoRolPrivadoItemProperty_EsSubgerente").IsEnabled = false;

                            this.FindControl("Gerencia").IsEnabled = false;
                            this.FindControl("Subgerencia").IsEnabled = false;

                            this.FindControl("Área").IsEnabled = true;

                            if (this.Área == null)
                            {
                                results.AddPropertyError("Debe escoger una área");
                            }

                            if (this.CargoRolPrivadoJefedearea.First() != this.CargoRolPrivadoItemProperty)//Error si ya existe otro cargo con la misma asignación de supervisión
                            {
                                if (this.CargoRolPrivadoJefedearea.Count() != 0)
                                {
                                    results.AddPropertyError("Ya existe el cargo ' " + CargoRolPrivadoJefedearea.First().Nombre + " ' el cual tiene asignado 'es Jefe de área' para ' " + this.Área.Nombre + " '. No puede haber más de un cargo con la asignación de jefe de área para la misma área.");
                                }
                            }
                        }
            }
            catch { }
        }
        partial void Persona_Validate(ScreenValidationResultsBuilder results)
        {
            try
            {
                this.Persona.Rut_Persona = this.RUN + '-' + this.Dig_Verificador;
                this.Persona.Email = this.Email;
            
                if (this.Persona.CargoRolPrivadoItem == null)
                {
                    this.IDAREA = null;
                    this.IDSUBGERENCIA = null;
                    this.IDGERENCIA = null;

                    this.ES_JEFE_DE_AREA = false;
                    this.ES_SUBGERENTE = false;
                    this.ES_GERENTE = false;
                }
                else
                {
                    if (this.Persona.CargoRolPrivadoItem.IDArea != null)
                    {
                        this.IDAREA = this.Persona.CargoRolPrivadoItem.IDArea;

                        if (this.Division_AreaItem.Division_SubGerenciaItem != null)
                        {
                            this.IDSUBGERENCIA = this.Division_AreaItem.Division_SubGerenciaItem.Id_SubGerencia;
                        }
                        else
                        {
                            this.IDSUBGERENCIA = null;
                        }

                        if (this.Division_AreaItem.Division_GerenciaItem != null)
                        {
                            this.IDGERENCIA = this.Division_AreaItem.Division_GerenciaItem.Id_Gerencia;
                        }
                        else

                            if (this.Division_AreaItem.Division_SubGerenciaItem.Division_GerenciaItem != null)
                            {
                                this.IDGERENCIA = this.Division_AreaItem.Division_SubGerenciaItem.Division_GerenciaItem.Id_Gerencia;
                            }

                        if (this.Persona.CargoRolPrivadoItem.EsJefeDeArea != true)
                        {
                            this.ES_JEFE_DE_AREA = false;
                            this.ES_SUBGERENTE = false;
                            this.ES_GERENTE = false;
                        }
                        else

                            if (this.Persona.CargoRolPrivadoItem.EsJefeDeArea == true)
                            {
                                this.ES_JEFE_DE_AREA = true;
                                this.ES_SUBGERENTE = false;
                                this.ES_GERENTE = false;

                                if (this.Division_AreaItem.Superior_JefeDirecto.First() != null)
                                {
                                    if (this.Division_AreaItem.Superior_JefeDirecto.First().PersonaItem1 != this.Persona)
                                    {
                                        results.AddPropertyError("No puede haber más de un jefe de área por área. " + this.Division_AreaItem.Superior_JefeDirecto.First().PersonaItem1.NombreAD + " es el actual jefe de área de " + this.Division_AreaItem.Nombre);
                                    }
                                }
                            }

                    }
                    else

                        if (this.Persona.CargoRolPrivadoItem.IDSubgerencia != null)
                        {
                            this.IDSUBGERENCIA = this.Persona.CargoRolPrivadoItem.IDSubgerencia;

                            this.IDGERENCIA = this.Division_SubGerenciaItem.Division_GerenciaItem.Id_Gerencia;

                            this.IDAREA = null;

                            if (this.Persona.CargoRolPrivadoItem.EsSubgerente == true)
                            {
                                this.ES_JEFE_DE_AREA = false;
                                this.ES_SUBGERENTE = true;
                                this.ES_GERENTE = false;

                                if (this.Division_SubGerenciaItem.Superior_SubGerente.First() != null)
                                {
                                    if (this.Division_SubGerenciaItem.Superior_SubGerente.First().PersonaItem1 != this.Persona)
                                    {
                                        results.AddPropertyError("No puede haber más de un subgerente por subgerencia. " + this.Division_SubGerenciaItem.Superior_SubGerente.First().PersonaItem1.NombreAD + " es el actual subgerente de " + this.Division_SubGerenciaItem.Nombre);
                                    }
                                }
                            }

                        }
                        else

                            if (this.Persona.CargoRolPrivadoItem.IDGerencia != null)
                            {
                                this.IDGERENCIA = this.Persona.CargoRolPrivadoItem.IDGerencia;

                                this.IDSUBGERENCIA = null;

                                this.IDAREA = null;

                                if (this.Persona.CargoRolPrivadoItem.EsGerente == true)
                                {
                                    this.ES_JEFE_DE_AREA = false;
                                    this.ES_SUBGERENTE = false;
                                    this.ES_GERENTE = true;

                                    if (this.Division_GerenciaItem.Superior_Gerente.First() != null)
                                    {
                                        if (this.Division_GerenciaItem.Superior_Gerente.First().PersonaItem1 != this.Persona)
                                        {
                                            results.AddPropertyError("No puede haber más de un gerente por gerencia. " + this.Division_GerenciaItem.Superior_Gerente.First().PersonaItem1.NombreAD + " es el actual gerente de " + this.Division_GerenciaItem.Nombre);
                                        }
                                    }
                                }
                            }
                }
            }
            catch { }
        }
        partial void FiltroEstados_Validate(ScreenValidationResultsBuilder results)
        {
            // results.AddPropertyError("<Mensaje de error>");
            if (FiltroEstados == "Rechazada")
            {

                this.Completada = false;
                this.Rechazada = true;
                this.Cancelada = false;
                this.Caducada = false;
                this.Rebajada = false;
            }
            else
                if (FiltroEstados == "Aprobada")
                {

                    this.Completada = true;
                    this.Rechazada = false;
                    this.Cancelada = false;
                    this.Caducada = false;
                    this.Rebajada = false;
                }
                else
                    if (FiltroEstados == "En aprobacion")
                    {

                        this.Completada = false;
                        this.Rechazada = false;
                        this.Cancelada = false;
                        this.Caducada = false;
                        this.Rebajada = false;
                    }
                    else
                        if (FiltroEstados == "Cancelada")
                        {

                            this.Completada = false;
                            this.Rechazada = false;
                            this.Cancelada = true;
                            this.Caducada = false;
                            this.Rebajada = false;
                        }
                        else
                            if (FiltroEstados == "Anulada")
                            {

                                this.Completada = false;
                                this.Rechazada = false;
                                this.Cancelada = false;
                                this.Caducada = true;
                                this.Rebajada = false;
                            }
                            else
                                if (FiltroEstados == "Rebajada")
                                {

                                    this.Completada = false;
                                    this.Rechazada = false;
                                    this.Cancelada = false;
                                    this.Caducada = false;
                                    this.Rebajada = true;
                                }
                                else
                                    if (FiltroEstados == "Todas")
                                    {
                                        //this.Cancelada = null;

                                        //this.FechaSolicitudDesde = null;
                                        //this.FechaSolicitudHasta = null;

                                        this.Administrativo = true;
                                        this.Vacaciones = true;
                                        this.OtroPermiso = true;
                                        this.HorasExtras = true;
                                        this.FiltroEstados = null;

                                        this.Completada = false;
                                        this.Rechazada = false;
                                        this.Cancelada = false;
                                        this.Caducada = null;
                                        this.Rebajada = null;
                                        //this.Solicitud_Header.Load();
                                    }
        }
Ejemplo n.º 33
0
        partial void FirmendatenProperty_Validate(ScreenValidationResultsBuilder results)
        {
            // results.AddPropertyError("<Fehlermeldung>");

        }
Ejemplo n.º 34
0
        partial void SOLICITUD_Validate(ScreenValidationResultsBuilder results)
        {
            if (InvocarSaldoVacaciones == true) 
            { 
                this.ConsultarSaldo_Execute();
                InvocarSaldoVacaciones = false;
            }
                
            if (TIPOSOLICITUD == 2)// si la solicitud es del tipo vacaciones
            {
                this.NUEVOESTADO.Observaciones = this.OBSERVACIONES;

                //Valida el campo solo si se le ha ingresado un valor
                if (this.SOLICITUD.Prestamo.HasValue)
                {
                    if (this.SOLICITUD.Prestamo.Value < 0 || this.SOLICITUD.Prestamo.Value > 50)
                    {
                        results.AddPropertyError("El prestamo debe ser entre 0 y 50");
                    }
                }

                
                //GUARDAR LOS REGISTROS DE FERIADOS EN UN ARREGLO

                DateTime[] FERIADOS = new DateTime[100];//DateTime[] FERIADOS = new DateTime[] { };
                int dia; int mes; int año; int i = 0;

                foreach (FeriadosItem feriado in this.Feriados)
                {
                    dia = feriado.Feriado.Day;
                    mes = feriado.Feriado.Month;
                    año = feriado.Feriado.Year;
                    //DateTime DiaAux = new DateTime(DateTime.Today.Year, mes, dia);//Cambia el año del registro al año actual
                    DateTime DiaAux = new DateTime(año, mes, dia);
                    FERIADOS[i] = DiaAux;
                    i++;
                }

                //Validar que las fechas de inicio y terminio no sean feriados ni fin de semanas
                foreach (DateTime feriado in FERIADOS)
                {
                    if (this.SOLICITUD.Inicio.Value == feriado)
                    {
                        results.AddPropertyError("La fecha de inicio no puede ser un día feriado ");
                    }

                    if (this.SOLICITUD.Termino.Value == feriado)
                    {

                        results.AddPropertyError("La fecha de término no puede ser un día feriado ");
                    }
                }

                if (this.SOLICITUD.Inicio.Value.DayOfWeek == DayOfWeek.Saturday || this.SOLICITUD.Inicio.Value.DayOfWeek == DayOfWeek.Sunday)
                {
                    results.AddPropertyError("La fecha de inicio no puede ser fin de semana ");
                }

                if (this.SOLICITUD.Termino.Value.DayOfWeek == DayOfWeek.Saturday || this.SOLICITUD.Termino.Value.DayOfWeek == DayOfWeek.Sunday)
                {
                    results.AddPropertyError("La fecha de término no puede ser fin de semana ");
                }

                if(this.SOLICITUD.Inicio > this.SOLICITUD.Termino){
                    results.AddPropertyError("Día de Término debe ser después o igual al día de Inicio ");
                }else{ 
                    this.SOLICITUD.DiasSolicitados = BusinessDaysUntil(this.SOLICITUD.Inicio.Value, this.SOLICITUD.Termino.Value, FERIADOS);
                }

                if (this.SOLICITUD.Inicio <= DateTime.Today)
                {
                    results.AddPropertyError("Día de Inicio debe ser después hoy");
                }

                if (this.SOLICITUD.DiasSolicitados > this.SOLICITUD.SaldoDias)
                {
                    results.AddPropertyError("El número de días a solicitar debe ser menor o igual a tu SALDO DE DÍAS");
                }

            }

            if (TIPOSOLICITUD == 3)// si la solicitud es del tipo horas extras
            {
                if (this.SOLICITUD.TaxiBoolean == true)
                {
                    this.SOLICITUD.Taxi = "Sí";
                }
                else
                {
                    this.SOLICITUD.Taxi = "No";
                }

                if (this.SOLICITUD.ColacionBoolean == true)
                {
                    this.SOLICITUD.Colacion = "Sí";
                }
                else
                {
                    this.SOLICITUD.Colacion = "No";
                }

                this.NUEVOESTADO.Observaciones = this.OBSERVACIONES;
                this.SOLICITUD.ColacionBoolean = this.COLACION;
                this.SOLICITUD.TaxiBoolean = this.TAXI;

                if (this.SOLICITUD.HorasAutorizadas > 2)
                {
                    results.AddPropertyError("El máximo de horas extras a trabajar es 2");

                }
                else { this.SOLICITUD.HorasAutorizadas = this.SOLICITUD.HorasAutorizadas; }

                if (this.SOLICITUD.HorasAutorizadas <= 0 || this.SOLICITUD.HorasAutorizadas == null)
                {
                    results.AddPropertyError("Las horas autorizadas deben ser mayor a 0");
                }
                else { this.SOLICITUD.HorasAutorizadas = this.SOLICITUD.HorasAutorizadas; }

                if (this.SOLICITUD.Inicio < DateTime.Today)
                {
                    results.AddPropertyError("La fecha de realización no puede ser antes de hoy");
                }

                if (this.SOLICITUD.PersonaItem1 == null)
                {
                    results.AddPropertyError("Debe seleccionar un empleado");
                }

                //if (COLACION == true) { this.SOLICITUDESItemProperty.Colacion = true; } else { this.SOLICITUDESItemProperty.Colacion = false; }
                //if (TAXI == true) { this.SOLICITUDESItemProperty.Taxi = true; } else { this.SOLICITUDESItemProperty.Taxi = false; }

            }

            if (TIPOSOLICITUD == 4)// si la solicitud es del tipo permiso
            {
                if (this.SOLICITUD.ConDescuentoBoolean == true)
                {
                    this.SOLICITUD.ConDescuento = "Sí";
                }
                else
                {
                    this.SOLICITUD.ConDescuento = "No";
                }

                this.NUEVOESTADO.Observaciones = this.OBSERVACIONES;

                //GUARDAR LOS REGISTROS DE FERIADOS EN UN ARREGLO

                DateTime[] FERIADOS = new DateTime[50];//DateTime[] FERIADOS = new DateTime[] { };
                int dia; int mes; int año; int i = 0;

                foreach (FeriadosItem feriado in this.Feriados)
                {
                    dia = feriado.Feriado.Day;
                    mes = feriado.Feriado.Month;
                    año = feriado.Feriado.Year;
                    //DateTime DiaAux = new DateTime(DateTime.Today.Year, mes, dia);//Cambia el año del registro al año actual
                    DateTime DiaAux = new DateTime(año, mes, dia);
                    FERIADOS[i] = DiaAux;

                    i++;

                }

                //Validar que las fechas de inicio y terminio no sean feriados ni fin de semanas
                foreach (DateTime feriado in FERIADOS)
                {
                    if (this.SOLICITUD.Inicio.Value == feriado)
                    {
                        results.AddPropertyError("La fecha de inicio no puede ser un día feriado ");
                    }

                    if (this.SOLICITUD.Termino.Value == feriado)
                    {

                        results.AddPropertyError("La fecha de término no puede ser un día feriado ");
                    }
                }

                if (this.SOLICITUD.Inicio.Value.DayOfWeek == DayOfWeek.Saturday || this.SOLICITUD.Inicio.Value.DayOfWeek == DayOfWeek.Sunday)
                {
                    results.AddPropertyError("La fecha de inicio no puede ser fin de semana ");
                }

                if (this.SOLICITUD.Termino.Value.DayOfWeek == DayOfWeek.Saturday || this.SOLICITUD.Termino.Value.DayOfWeek == DayOfWeek.Sunday)
                {
                    results.AddPropertyError("La fecha de término no puede ser fin de semana ");
                }

                if (this.SOLICITUD.Inicio < DateTime.Today)
                {

                    results.AddPropertyError("La fecha de inicio no puede ser antes de hoy");
                }


                if (this.SOLICITUD.Termino < this.SOLICITUD.Inicio)
                {

                    results.AddPropertyError("La fecha de término debe ser después de la fecha de inicio");

                }else
                    {
                        //this.SOLICITUD.DiasSolicitados = BusinessDaysUntil(this.SOLICITUD.Inicio.Value, this.SOLICITUD.Termino.Value, FERIADOS);

                        this.SOLICITUD.DiasSolicitados = Math.Round((BusinessDaysUntil(this.SOLICITUD.Inicio.Value, this.SOLICITUD.Termino.Value, FERIADOS) - 1) + (ConvertHoursToTotalDays(this.SOLICITUD.Termino.Value.Hour - this.SOLICITUD.Inicio.Value.Hour)) + (ConvertMinutesToTotalDays(this.SOLICITUD.Termino.Value.Minute - this.SOLICITUD.Inicio.Value.Minute)), 2);

                        this.SOLICITUD.ddhhmmOTROPERMISO = "(" + (BusinessDaysUntil(this.SOLICITUD.Inicio.Value, this.SOLICITUD.Termino.Value, FERIADOS) - 1).ToString() + " Días, " + (this.SOLICITUD.Termino.Value.Hour - this.SOLICITUD.Inicio.Value.Hour).ToString() + " Horas, " + (this.SOLICITUD.Termino.Value.Minute - this.SOLICITUD.Inicio.Value.Minute).ToString() + " Minutos )";
                    }
            }

            if (TIPOSOLICITUD == 1)// si la solicitud es del tipo dia administrativo
            {
                //GUARDAR LOS REGISTROS DE FERIADOS EN UN ARREGLO

                DateTime[] FERIADOS = new DateTime[50];//DateTime[] FERIADOS = new DateTime[] { };
                int dia; int mes; int año; int i = 0;

                foreach (FeriadosItem feriado in this.Feriados)
                {
                    dia = feriado.Feriado.Day;
                    mes = feriado.Feriado.Month;
                    año = feriado.Feriado.Year;
                    //DateTime DiaAux = new DateTime(DateTime.Today.Year, mes, dia);//Cambia el año del registro al año actual
                    DateTime DiaAux = new DateTime(año, mes, dia);
                    FERIADOS[i] = DiaAux;
                    i++;
                }

                this.NUEVOESTADO.Observaciones = this.OBSERVACIONES;

                this.SOLICITUD.ConDescuentoBoolean = this.CONDESCUENTO;

                //Validar que las fechas de inicio y terminio no sean feriados ni fin de semanas
                foreach (DateTime feriado in FERIADOS)
                {
                    if (this.SOLICITUD.Inicio.Value == feriado)
                    { 
                        results.AddPropertyError("La fecha de inicio no puede ser un día feriado "); 
                    }

                    if (this.SOLICITUD.Termino.Value == feriado)
                    {
                        results.AddPropertyError("La fecha de término no puede ser un día feriado ");
                    }    
                }

                if (this.SOLICITUD.Inicio.Value.DayOfWeek == DayOfWeek.Saturday || this.SOLICITUD.Inicio.Value.DayOfWeek == DayOfWeek.Sunday)
                {
                    results.AddPropertyError("La fecha de inicio no puede ser fin de semana ");
                }

                if (this.SOLICITUD.Termino.Value.DayOfWeek == DayOfWeek.Saturday || this.SOLICITUD.Termino.Value.DayOfWeek == DayOfWeek.Sunday)
                {
                    results.AddPropertyError("La fecha de término no puede ser fin de semana ");
                }

                if (this.SOLICITUD.Inicio < DateTime.Today)
                {
                    results.AddPropertyError("La fecha de inicio no puede ser antes de hoy");
                }

                if (this.SOLICITUD.Termino < this.SOLICITUD.Inicio)
                {
                    results.AddPropertyError("Día de Término debe ser después o igual al día de Inicio ");
                }
                else
                {
                    if (this.AdministrativoDesde == "La tarde (Medio día)" && this.AdministrativoHasta == "La mañana (Medio día)")
                    {
                        this.SOLICITUD.DiasSolicitados = BusinessDaysUntil(this.SOLICITUD.Inicio.Value, this.SOLICITUD.Termino.Value, FERIADOS) - 1;
                    }
                    else if (this.AdministrativoDesde == "La mañana (Todo el día)" && this.AdministrativoHasta == "La tarde (Todo el día)")//ok
                    {
                        this.SOLICITUD.DiasSolicitados = BusinessDaysUntil(this.SOLICITUD.Inicio.Value, this.SOLICITUD.Termino.Value, FERIADOS);
                    }
                    else
                    {
                        this.SOLICITUD.DiasSolicitados = BusinessDaysUntil(this.SOLICITUD.Inicio.Value, this.SOLICITUD.Termino.Value, FERIADOS) - 0.5;
                    }
                }

                if (this.SOLICITUD.DiasSolicitados > this.SOLICITUD.SaldoDias)
                {
                    results.AddPropertyError("El número de días a solicitar debe ser menor o igual a tu saldo de días ");
                }

                if (this.SOLICITUD.DiasSolicitados <= 0)
                {
                    results.AddPropertyError("El número de días a solicitar debe ser mayor a 0");
                }
            }
        }
Ejemplo n.º 35
0
 partial void EMPLEADO_Validate(ScreenValidationResultsBuilder results)
 {
     // results.AddPropertyError("<Mensaje de error>");
     try
     {
         if (this.EMPLEADO == null)
         {
             EmpleadoFiltroSolicitudes = null;
         }
         else
         {
             EmpleadoFiltroSolicitudes = this.EMPLEADO.Rut_Persona;
         }
     }
     catch { }
 }
        partial void Solicitud_Detalles_HorasExtras_Validate(ScreenValidationResultsBuilder results)
        {
            // results.AddPropertyError("<Mensaje de error>");

            if (TIPOSOLICITUD == 3)// si la solicitud es del tipo horas extras
            {

                if (this.Solicitud_Detalles_HorasExtras.HorasAutorizadas > 2)
                {

                    results.AddPropertyError("El máximo de horas extras a trabajar es 2");

                }

                if (this.Solicitud_Detalles_HorasExtras.HorasAutorizadas <= 0)
                {

                    results.AddPropertyError("Las horas autorizadas deben ser mayor a 0");

                }

                if (this.Solicitud_Detalles_HorasExtras.FechaRealizacion <= DateTime.Today)
                {

                    results.AddPropertyError("La fecha de realización debe ser después de hoy");

                }

                if (COLACIÓN == true) { this.Solicitud_Detalles_HorasExtras.Colacion = true; } else { this.Solicitud_Detalles_HorasExtras.Colacion = false; }
                if (TAXI == true) { this.Solicitud_Detalles_HorasExtras.Taxi = true;  } else { this.Solicitud_Detalles_HorasExtras.Taxi = false; }

            }

        }
        partial void Division_Gerencia_Validate(ScreenValidationResultsBuilder results)
        {
            // results.AddPropertyError("<Mensaje de error>");
            try
            {
                if (this.GerenciaGeneral.First().Nombre != "GERENCIA GENERAL")
                {
                    results.AddPropertyError("No se puede cambiar el nombre de la 'GERENCIA GENERAL'");

                }
            }
            catch { }
        }
Ejemplo n.º 38
0
 partial void FirmendatenProperty_Validate(ScreenValidationResultsBuilder results)
 {
     // results.AddPropertyError("<Fehlermeldung>");
 }