Пример #1
0
        static void Main()
        {
            string path     = AppConfigReader.Get("log_path");
            string filename = Path.Combine(path, string.Format("{0}.log", DateTime.Now.ToString("yyyyMMddhhmmss")));

            ContextoActual = new Contexto(filename, FechaHelper.Ahora());

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            try
            {
                ContextoActual.Logger.Iniciar();
                Application.Run(new FrmPrincipal());
            }
            catch (Exception ex)
            {
                MensajePorPantalla.MensajeError("Ha ocurrido un error fatal. Revise el archivo de log para obtener más información al respecto.");
                ContextoActual.Logger.Log(ex);
            }
            finally
            {
                ContextoActual.Logger.Finalizar();
            }
        }
Пример #2
0
        private void FrmEstadisticas_Load(object sender, EventArgs e)
        {
            Semestre semestre = ObtenerSemestre();

            lblSemestre.Text    = semestre.ToString();
            this.dtpFecha.Value = FechaHelper.Ahora();

            try
            {
                IResultado <IList <Estadistica> > resultadoObtenerNombres = _domain.ObtenerTodos();
                if (!resultadoObtenerNombres.Correcto)
                {
                    throw new ResultadoIncorrectoException <IList <Estadistica> >(resultadoObtenerNombres);
                }

                IList <Estadistica> vistas = resultadoObtenerNombres.Retorno;
                cbVista.DataSource    = vistas;
                cbVista.DisplayMember = "NombreEstadistica";
                cbVista.ValueMember   = "IdEstadistica";
            }
            catch (Exception ex)
            {
                MensajePorPantalla.MensajeError(this, ex.Message);
            }
        }
Пример #3
0
        /// <summary>
        /// Genera la fecha para la carta encomienda
        /// </summary>
        /// <param name="ciudad"></param>
        /// <param name="estado"></param>
        /// <returns></returns>
        private Paragraph ObtenerFecha(string ciudad, string estado)
        {
            FechaHelper fechaHelper = new FechaHelper();

            var fechaCarta = new Paragraph();

            var chunkFecha = new Chunk("         " + ciudad + "," + estado + "         ", new Font(Font.FontFamily.UNDEFINED, 11.0f, Font.BOLD | Font.UNDERLINE, BaseColor.BLACK));

            fechaCarta.Add(chunkFecha);

            chunkFecha = new Chunk(" a ", new Font(Font.FontFamily.UNDEFINED, 11.0f, Font.NORMAL, BaseColor.BLACK));
            fechaCarta.Add(chunkFecha);

            chunkFecha = new Chunk("     " + DateTime.Now.Day.ToString() + "     ", new Font(Font.FontFamily.UNDEFINED, 11.0f, Font.BOLD | Font.UNDERLINE, BaseColor.BLACK));
            fechaCarta.Add(chunkFecha);

            chunkFecha = new Chunk(" de ", new Font(Font.FontFamily.UNDEFINED, 11.0f, Font.NORMAL, BaseColor.BLACK));
            fechaCarta.Add(chunkFecha);

            chunkFecha = new Chunk("     " + fechaHelper.ObtenerNombreMes(DateTime.Now.Month) + "     ", new Font(Font.FontFamily.UNDEFINED, 11.0f, Font.BOLD | Font.UNDERLINE, BaseColor.BLACK));
            fechaCarta.Add(chunkFecha);

            chunkFecha = new Chunk(" de ", new Font(Font.FontFamily.UNDEFINED, 11.0f, Font.NORMAL, BaseColor.BLACK));
            fechaCarta.Add(chunkFecha);

            chunkFecha = new Chunk("     " + DateTime.Now.Year.ToString() + "     ", new Font(Font.FontFamily.UNDEFINED, 11.0f, Font.BOLD | Font.UNDERLINE, BaseColor.BLACK));
            fechaCarta.Add(chunkFecha);

            fechaCarta.Alignment = Element.ALIGN_RIGHT;

            return(fechaCarta);
        }
        public static DialogResult MensajeValidacionDateTime(string controlName, DateTime from, DateTime until)
        {
            var sUntil = FechaHelper.Format(until);
            var sFrom  = FechaHelper.Format(from);

            return(MessageBox.Show(string.Format("El valor ingresado en el campo {0} debe ser mayor a {1} y menor a {2}", controlName, sFrom, sUntil), "Error al validar"));
        }
Пример #5
0
        private void FrmAfiliadoAlta_Load(object sender, EventArgs e)
        {
            this.AgregarValidacion(new ValidadorString(tbNombre, 1, 255));
            this.AgregarValidacion(new ValidadorString(tbApellido, 1, 255));
            this.AgregarValidacion(new ValidadorCombobox(cbTipoDocumento));
            this.AgregarValidacion(new ValidadorNumerico(tbNroDocumento));
            this.AgregarValidacion(new ValidadorDateTimeUntil(dpFechaNacimiento, FechaHelper.Ahora()));
            this.AgregarValidacion(new ValidadorString(tbDireccion, 1, 255));
            this.AgregarValidacion(new ValidadorNumerico(tbTelefono));
            this.AgregarValidacion(new ValidadorString(tbMail, 1, 255));
            this.AgregarValidacion(new ValidadorMail(tbMail));
            this.AgregarValidacion(new ValidadorString(tbPlanMedico, 1, 255));
            this.dpFechaNacimiento.Value = FechaHelper.Ahora();
            this.CargarCombos();

            if (_afiliadoAnterior != null)
            {
                tbApellido.Text     = _afiliadoAnterior.Apellido;
                tbApellido.ReadOnly = true;

                tbDireccion.Text = _afiliadoAnterior.Direccion;
                tbTelefono.Text  = _afiliadoAnterior.Telefono.ToString();

                cbEstadoCivil.SelectedItem = (!EsHijo) ? _afiliadoAnterior.EstadoCivil : new Soltero();
                cbEstadoCivil.Enabled      = EsHijo;

                ndCantHijos.Enabled = false;
                ndCantHijos.Value   = (!EsHijo) ? _afiliadoAnterior.CantidadHijos : 0;

                this.CargarPlan(_planAnterior);
            }
        }
Пример #6
0
 private void frmPrincipal_Load_CargarBarraEstado()
 {
     this.lblUsuario.Text          = "Usuario: " + Program.ContextoActual.UsuarioActual.Username;
     this.lblLogPath.Text          = "Almacenando log en: " + Program.ContextoActual.LogPath;
     this.lblFechaSistema.Text     = "Fecha: " + FechaHelper.Format(Program.ContextoActual.FechaActual);
     this.lblConnectionString.Text = "Conectado: " + AppConfigReader.Get("connection_string");
 }
Пример #7
0
        private bool validacionFechas(DateTimePicker dpFechaDesde, DateTimePicker dpFechaHasta)
        {
            bool resultado = new ValidadorDateTimeFrom(dpFechaDesde, FechaHelper.Ahora()).Validar()
                             & new ValidadorDateTimeUntil(dpFechaHasta, dpFechaDesde.Value.AddDays(120)).Validar()
                             & new ValidadorDateTimeFrom(dpFechaHasta, dpFechaDesde.Value).Validar();

            return(resultado);
        }
 private void FrmRegistroDeResultado_Load(object sender, EventArgs e)
 {
     dpFecha.Value        = FechaHelper.Ahora();
     dpFecha.Format       = DateTimePickerFormat.Custom;
     dpFecha.CustomFormat = "dd/MM/yyyy, hh:mm";
     this.AgregarValidacion(new ValidadorString(tbDiagnostico, 1, 255));
     this.AgregarValidacion(new ValidadorString(tbSintomas, 1, 255));
     this.btnConfirmarHorario.Enabled = false;
     this.button1.Enabled             = false;
 }
Пример #9
0
        protected override IList <SqlParameter> GenerarParametrosBorrar(decimal id)
        {
            IList <SqlParameter> parameters = base.GenerarParametrosBorrar(id);

            SqlParameter fechaBaja = new SqlParameter("@p_fecha_baja", System.Data.SqlDbType.DateTime, 8, "p_fecha_baja");

            fechaBaja.Value = FechaHelper.Ahora();
            parameters.Add(fechaBaja);

            return(parameters);
        }
 private void btnRegistrar_Click(object sender, EventArgs e)
 {
     DateTime ahora = FechaHelper.Ahora();
     if (_turno.HoraInicio.Subtract(ahora).TotalMinutes < 0 )
     {
         this.Registrar();
     }
     else
     {
         MensajePorPantalla.MensajeError(this, "Debería haberse presentado por lo menos 15 minutos antes del comienzo del turno");
     }
 }
Пример #11
0
        protected override void AccionLimpiar()
        {
            tbApellido.Text             = string.Empty;
            tbDireccion.Text            = string.Empty;
            tbMail.Text                 = string.Empty;
            tbMatriculaProfesional.Text = string.Empty;
            tbNombre.Text               = string.Empty;
            tbNroDocumento.Text         = string.Empty;
            tbTelefono.Text             = string.Empty;

            dpFechaNacimiento.Value = FechaHelper.Ahora();
        }
Пример #12
0
        private void Main_Load(object sender, EventArgs e)
        {
            #region ValidarFechaConfig
            FechaHelper fechaHelper = new FechaHelper();

            if (!fechaHelper.ConfigDateIsValid())
            {
                MessageBox.Show(Resources.ErrorFechaSistema, Resources.MercadoEnvio, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
            #endregion
        }
Пример #13
0
        private void FrmAfiliadoListado_Load(object sender, EventArgs e)
        {
            AccionLimpiar();
            this.AgregarValidacion(new ValidadorNumerico(tbNroPrincipal));
            this.AgregarValidacion(new ValidadorCombobox(cbTipoDoc));
            this.AgregarValidacion(new ValidadorNumerico(tbPlanMedico));
            this.AgregarValidacion(new ValidadorString(tbNombre, 1, 255));
            this.AgregarValidacion(new ValidadorString(tbApellido, 1, 255));
            this.dtpFechaNac.Value = FechaHelper.Ahora();

            this.CargarCombos();
        }
Пример #14
0
 private void FrmAfiliadoModificar_Load(object sender, EventArgs e)
 {
     this.AgregarValidacion(new ValidadorString(tbNombre, 1, 255));
     this.AgregarValidacion(new ValidadorString(tbApellido, 1, 255));
     this.AgregarValidacion(new ValidadorCombobox(cbTipoDocumento));
     this.AgregarValidacion(new ValidadorNumerico(tbNroDocumento));
     this.AgregarValidacion(new ValidadorDateTimeUntil(dpFechaNacimiento, FechaHelper.Ahora()));
     this.AgregarValidacion(new ValidadorString(tbDireccion, 1, 255));
     this.AgregarValidacion(new ValidadorNumerico(tbTelefono));
     this.AgregarValidacion(new ValidadorString(tbMail, 1, 255));
     this.AgregarValidacion(new ValidadorMail(tbMail));
 }
Пример #15
0
        private void FrmRecetaVista_Load(object sender, EventArgs e)
        {
            this.lblFecha.Text          = FechaHelper.Format(_receta.Fecha, FechaHelper.DateFormat);
            this.lblNombreAfiliado.Text = _afiliadoNombre;
            this.lblProfesional.Text    = _profesionalNombre;
            StringBuilder sb = new StringBuilder();

            foreach (ItemReceta item in _receta.Items)
            {
                sb.Append(item.ToString()).Append(Environment.NewLine);
            }
            this.lblItems.Text = sb.ToString();
        }
Пример #16
0
 protected override void AccionLimpiar()
 {
     tbApellido.Text               = string.Empty;
     ndCantHijos.Value             = 0;
     tbDireccion.Text              = string.Empty;
     tbMail.Text                   = string.Empty;
     tbNombre.Text                 = string.Empty;
     tbNroAfiliado.Text            = string.Empty;
     tbNroDocumento.Text           = string.Empty;
     tbTelefono.Text               = string.Empty;
     cbTipoDocumento.SelectedIndex = 0;
     dpFechaNacimiento.Value       = FechaHelper.Ahora();
 }
        private List <string> ValidarDatosPublicacion()
        {
            List <string>   errors = new List <string>();
            TipoPublicacion tipo   = (TipoPublicacion)ComboTipoPublicacion.SelectedItem;
            FechaHelper     helper = new FechaHelper();

            if (string.IsNullOrEmpty(RichTextBoxDescripcion.Text))
            {
                errors.Add(Resources.ErrorDescripcionVacia);
            }

            if (string.IsNullOrEmpty(textBoxPrecio.Text) || Convert.ToDecimal(textBoxPrecio.Text) <= 0)
            {
                errors.Add(Resources.PrecioInvalido);
            }

            if (DatePickerFechaInicio.Value < helper.GetSystemDate())
            {
                errors.Add(Resources.ErrorFechaInicio);
            }

            if (DatePickerFechaVencimiento.Value < helper.GetSystemDate())
            {
                errors.Add(Resources.ErrorFechaVencimiento);
            }

            if (tipo.Descripcion.Equals(Resources.CompraInmediata, StringComparison.CurrentCultureIgnoreCase))
            {
                if (string.IsNullOrEmpty(textBoxStock.Text) || Convert.ToInt32(textBoxStock.Text) <= 0)
                {
                    errors.Add(Resources.StockInvalido);
                }
            }
            else
            {
                if (string.IsNullOrEmpty(textBoxPrecioReserva.Text) || Convert.ToInt32(textBoxPrecioReserva.Text) <= 0)
                {
                    errors.Add(Resources.PrecioReservaInvalido);
                }
            }

            if (Usuario.Roles.Exists(x => x.Descripcion.Equals(Resources.Empresa, StringComparison.CurrentCultureIgnoreCase)))
            {
                if (!((Rubro)ComboRubro.SelectedItem).DescripcionLarga.Equals(Resources.Electronicos, StringComparison.CurrentCultureIgnoreCase))
                {
                    errors.Add(Resources.ErrorPublicacionEmpresa);
                }
            }

            return(errors);
        }
Пример #18
0
 private void FrmAgendaAlta_Load(object sender, EventArgs e)
 {
     //this.AccionLimpiar();
     this.AgregarValidacion(new ValidadorString(tbProfesional, 1, 255));
     this.AgregarValidacion(new ValidadorCombobox(cbDia));
     this.dpFechaDesde.Value = FechaHelper.Ahora();
     this.dpFechaHasta.Value = FechaHelper.Ahora();
     this.dpExcepcion.Value  = FechaHelper.Ahora();
     this.CargarDiasSemana();
     this.gbDatosAgenda.Enabled   = true;
     this.gbDetalleDiario.Enabled = false;
     this.gbExcepciones.Enabled   = false;
     this.btnGuardar.Enabled      = false;
 }
Пример #19
0
        private void FrmRecetaAlta_Load(object sender, EventArgs e)
        {
            this.dateTimePicker1.Value = FechaHelper.Ahora();
            this.ndCantidad.Value      = 1;
            this.tbCantidad.Text       = "Uno";
            this.cantidadMedicamentos  = 0;

            this.AgregarValidacion(new ValidadorString(tbMedicamento, 1, 255));
            this.dateTimePicker1.Value = FechaHelper.Ahora();
            this.btnAceptar.Enabled    = false;

            this.btnAgregar.Enabled = false;
            this.btnQuitar.Enabled  = false;
            this.btnBuscar.Enabled  = false;
        }
        protected override void AccionIniciar()
        {
            ListaSexo sexos = new ListaSexo();

            this.cbSexo.DataSource    = sexos.Todos;
            this.cbSexo.DisplayMember = "Nombre";
            this.cbSexo.ValueMember   = "Id";

            ListaTipoDocumento documentos = new ListaTipoDocumento();

            this.cbTipoDoc.DataSource     = documentos.Todos;
            this.cbTipoDoc.DisplayMember  = "Nombre";
            this.cbTipoDoc.ValueMember    = "Id";
            this.dtpFechaNacimiento.Value = FechaHelper.Ahora();

            //this.CargarTodosLosProfesionales();
        }
Пример #21
0
        private void btnFarmacia_Click(object sender, EventArgs e)
        {
            BonoFarmacia farmacia = new BonoFarmacia();

            farmacia.IdPlanMedico     = _afiliado.IdPlanMedico;
            farmacia.NombrePlanMedico = _plan.Descripcion;
            farmacia.FechaVencimiento = FechaHelper.Ahora().AddDays(60);

            this.lstBonos.Items.Add(farmacia);

            Decimal subtotal = Convert.ToDecimal(tbPrecioTotal.Text);

            subtotal          += _plan.PrecioBonoFarmacia;
            tbPrecioTotal.Text = subtotal.ToString();

            this.btnComprar.Enabled = true;
        }
        protected override void AccionLimpiar()
        {
            tbApellido.Text             = string.Empty;
            tbDireccion.Text            = string.Empty;
            tbMail.Text                 = string.Empty;
            tbMatriculaProfesional.Text = string.Empty;
            tbNombre.Text               = string.Empty;
            tbNroDocumento.Text         = string.Empty;
            tbTelefono.Text             = string.Empty;

            dpFechaNacimiento.Value = FechaHelper.Ahora();

            //foreach (int i in clbEspecialidades.CheckedIndices)
            //{
            //    clbEspecialidades.SetItemCheckState(i, CheckState.Unchecked);
            //}
        }
        private void FrmProfesionalAlta_Load(object sender, EventArgs e)
        {
            AccionLimpiar();

            this.CargarCombo();

            this.AgregarValidacion(new ValidadorString(tbNombre, 1, 255));
            this.AgregarValidacion(new ValidadorString(tbApellido, 1, 255));
            this.AgregarValidacion(new ValidadorCombobox(cbTipoDocumento));
            this.AgregarValidacion(new ValidadorNumerico(tbNroDocumento));
            this.AgregarValidacion(new ValidadorString(tbDireccion, 1, 255));
            this.AgregarValidacion(new ValidadorNumerico(tbTelefono));
            this.AgregarValidacion(new ValidadorString(tbMail, 1, 255));
            this.AgregarValidacion(new ValidadorDateTimeUntil(dpFechaNacimiento, FechaHelper.Ahora()));
            this.AgregarValidacion(new ValidadorCombobox(cbSexo));
            this.AgregarValidacion(new ValidadorNumerico(tbMatriculaProfesional));
            this.AgregarValidacion(new ValidadorLista(lstEspecialidades));
            this.dpFechaNacimiento.Value = FechaHelper.Ahora();
        }
Пример #24
0
        public IResultado <Compra> Comprar(Afiliado afiliado, decimal costo, IList <BonoConsulta> bonosConsulta, IList <BonoFarmacia> bonosFarmacia)
        {
            Resultado <Compra> resultado = new Resultado <Compra>();

            try
            {
                Compra compra = new Compra();

                DateTime fechaImpresion = FechaHelper.Ahora();

                decimal idCompra = _dal.RegistrarCompra(afiliado, fechaImpresion, costo);
                compra.IdCompra = idCompra;

                foreach (BonoConsulta bono in bonosConsulta)
                {
                    bono.FechaImpresion = fechaImpresion;
                    bono.IdCompra       = idCompra;
                    decimal idBono = _dal.CrearBonoConsulta(bono);
                    bono.IdBonoConsulta = idBono;
                    compra.BonosConsulta.Add(bono);
                }

                foreach (BonoFarmacia bono in bonosFarmacia)
                {
                    bono.FechaImpresion = fechaImpresion;
                    bono.IdCompra       = idCompra;
                    decimal idBono = _dal.CrearBonoFarmacia(bono);
                    bono.IdBonoFarmacia = idBono;
                    compra.BonosFarmacia.Add(bono);
                }
                resultado.Retorno = compra;
            }
            catch (Exception ex)
            {
                resultado.Correcto = false;
                resultado.Mensajes.Add(ex.Message);
            }

            return(resultado);
        }
        private void FrmCancelarProfesional_Load(object sender, EventArgs e)
        {
            try
            {
                IResultado <IList <TipoCancelacion> > resultado = _tipoCancDomain.ObtenerTodos();
                if (!resultado.Correcto)
                {
                    throw new ResultadoIncorrectoException <IList <TipoCancelacion> >(resultado);
                }

                this.cbTipo.DataSource    = resultado.Retorno;
                this.cbTipo.DisplayMember = "Nombre";
                this.cbTipo.ValueMember   = "IdTipoCancelacion";

                this.monthCalendar1.SelectionStart = FechaHelper.Ahora();
                this.monthCalendar1.SelectionEnd   = FechaHelper.Ahora();
            }
            catch (Exception ex)
            {
                MensajePorPantalla.MensajeError(this, ex.Message);
            }
        }
        private void CancelarTurnos()
        {
            IValidador vMotivo = new ValidadorString(textBox2, 1, 255);

            if (vMotivo.Validar())
            {
                StringBuilder sb = new StringBuilder("Se cancelaran los siguientes días: ").Append(Environment.NewLine);
                for (DateTime dia = monthCalendar1.SelectionStart; dia <= monthCalendar1.SelectionEnd; dia = dia.AddDays(1))
                {
                    sb.Append(FechaHelper.Format(dia, FechaHelper.DateFormat)).Append(Environment.NewLine);
                }
                DialogResult ds = MensajePorPantalla.MensajeInterrogativo(this, sb.ToString(), MessageBoxButtons.YesNo);
                if (ds == DialogResult.Yes)
                {
                    for (DateTime dia = monthCalendar1.SelectionStart; dia <= monthCalendar1.SelectionEnd; dia = dia.AddDays(1))
                    {
                        IList <Turno> turnosDelDia = _domain.BuscarTurnos(_profesional.IdProfesional, dia).Retorno;
                        foreach (Turno turno in turnosDelDia)
                        {
                            Cancelacion c = new Cancelacion();
                            c.CanceladoPor      = 'P';
                            c.Fecha             = FechaHelper.Ahora();
                            c.IdTipoCancelacion = ((TipoCancelacion)cbTipo.SelectedItem).IdTipoCancelacion;
                            c.IdTurno           = turno.IdTurno;
                            c.Motivo            = textBox2.Text;

                            IResultado <Cancelacion> resultado = _domain.Cancelar(c);
                            if (!resultado.Correcto)
                            {
                                throw new ResultadoIncorrectoException <Cancelacion>(resultado);
                            }
                        }
                    }
                    MensajePorPantalla.MensajeInformativo(this, "Se han cancelado los turnos");
                    this.Close();
                }
            }
        }
Пример #27
0
        /// <summary>
        /// Obtiene un arreglo con los datos faltantes de la carta
        /// </summary>
        /// <param name="modelo"></param>
        /// <param name="nombreRepresentante"></param>
        /// <param name="razonSocial"></param>
        /// <param name="rfc"></param>
        /// <returns></returns>
        private string[] ObtenerDatosFaltantes(CartaEncomiendaViewModel modelo, ClienteDTO modeloDTO)

        {
            FechaHelper fechaHelper = new FechaHelper();

            var datos = new string[] { "       " + modeloDTO.RepresentanteLegal,
                                       modeloDTO.NombreFiscal,
                                       modeloDTO.ObtenerDomicilioFiscal,
                                       modeloDTO.RFC,
                                       modelo.NumeroEscritura,
                                       modelo.NombreNotarioPublico,
                                       modelo.NumeroNotaria,
                                       modelo.CiudadNotariado + ", " + modelo.EstadoNotariado,
                                       "AUTORIZARLO",
                                       modelo.PeriodoCompredidoInicio.Day.ToString(),
                                       fechaHelper.ObtenerNombreMes(modelo.PeriodoCompredidoInicio.Month),
                                       modelo.PeriodoCompredidoInicio.Year.ToString(),
                                       modelo.PeriodoCompredidoFin.Day.ToString(),
                                       fechaHelper.ObtenerNombreMes(modelo.PeriodoCompredidoFin.Month),
                                       modelo.PeriodoCompredidoFin.Year.ToString() };

            return(datos);
        }
Пример #28
0
        public FrmProfesionalModificar(Profesional profesional)
            : base()
        {
            _profesionalDomain  = new ProfesionalDomain(Program.ContextoActual.Logger);
            _especialidadDomain = new EspecialidadDomain(Program.ContextoActual.Logger);

            _profesional = profesional;

            InitializeComponent();

            ListaSexo sexos = new ListaSexo();

            this.cbSexo.DataSource    = sexos.Todos;
            this.cbSexo.DisplayMember = "Nombre";
            this.cbSexo.ValueMember   = "Id";

            ListaTipoDocumento documentos = new ListaTipoDocumento();

            this.cbTipoDocumento.DataSource    = documentos.Todos;
            this.cbTipoDocumento.DisplayMember = "Nombre";
            this.cbTipoDocumento.ValueMember   = "Id";
            this.dpFechaNacimiento.Value       = FechaHelper.Ahora();
        }
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                Cancelacion c = new Cancelacion();
                c.Fecha             = FechaHelper.Ahora();
                c.IdTipoCancelacion = ((TipoCancelacion)cbTipo.SelectedItem).IdTipoCancelacion;
                c.IdTurno           = _turno.IdTurno;
                c.Motivo            = tbMotivo.Text;
                c.CanceladoPor      = 'A';

                IResultado <Cancelacion> resultado = _domain.Cancelar(c);
                if (!resultado.Correcto)
                {
                    throw new ResultadoIncorrectoException <Cancelacion>(resultado);
                }
                MensajePorPantalla.MensajeInformativo(this, "Su turno ha sido cancelado con éxito.");
                this.Close();
            }
            catch (Exception ex)
            {
                MensajePorPantalla.MensajeError(this, ex.Message);
            }
        }
Пример #30
0
        private Boolean validarCargaHorarioDia()
        {
            Boolean   resultado       = true;
            DiaSemana diaSeleccionado = cbDia.SelectedItem as DiaSemana;

            DateTime horaDesdeSeleccionado = new DateTime(2013, 1, 1, (int)nudDesde.Value, (int)nudDesdeMinuto.Value, 0);
            DateTime horaHastaSeleccionado = new DateTime(2013, 1, 1, (int)nudHasta.Value, (int)nudHastaMinuto.Value, 0);

            if (horaDesdeSeleccionado == horaHastaSeleccionado)
            {
                resultado = false;
                MensajePorPantalla.MensajeError(this, "No puede cargar la misma hora de inicio que de finalización");
                return(resultado);
            }
            if (horaDesdeSeleccionado < diaSeleccionado.HoraDesdeLimite)
            {
                resultado = false;
                MensajePorPantalla.MensajeError(this, string.Format("La hora de inicio debe ser mayor o igual que {0}", FechaHelper.Format(diaSeleccionado.HoraDesdeLimite, FechaHelper.TimeFormat)));
                return(resultado);
            }

            if (horaHastaSeleccionado > diaSeleccionado.HoraHastaLimite)
            {
                resultado = false;
                MensajePorPantalla.MensajeError(this, string.Format("La hora de finalización debe ser menor o igual que {0}", FechaHelper.Format(diaSeleccionado.HoraHastaLimite, FechaHelper.TimeFormat)));
                return(resultado);
            }

            if (horaDesdeSeleccionado > horaHastaSeleccionado)
            {
                resultado = false;
                MensajePorPantalla.MensajeError(this, "La hora de inicio debe ser menor que la hora de finalización");
                return(resultado);
            }

            if (horaHastaSeleccionado < horaDesdeSeleccionado)
            {
                resultado = false;
                MensajePorPantalla.MensajeError(this, "La hora de finalización debe ser mayor que la hora de inicio");
                return(resultado);
            }

            List <DiaSemana> otrosDias = listCronograma.Items.Cast <DiaSemana>().Where(s => s.Id == diaSeleccionado.Id).ToList();

            foreach (DiaSemana otro in otrosDias)
            {
                if (horaDesdeSeleccionado >= otro.HoraDesde && horaDesdeSeleccionado <= otro.HoraHasta)
                {
                    MensajePorPantalla.MensajeError(this, "Ya existe un horario para ese día en esas horas. Revise la hora de inicio");
                    resultado = false;
                    return(resultado);
                }
                if (horaHastaSeleccionado <= otro.HoraHasta && horaHastaSeleccionado >= otro.HoraDesde)
                {
                    MensajePorPantalla.MensajeError(this, "Ya existe un horario para ese día en esas horas. Revise la hora de finalización");
                    resultado = false;
                    return(resultado);
                }
            }

            return(resultado);
        }