public DetalleMotorExistente(int Id)
 {
     InitializeComponent();
     try
     {
         //MotorExistente = General.GetEntityById<MotorExistente>("MotorExistente", "MotorExistenteID", Id);
         MotorExistente = Datos.GetEntity<MotorExistente>(c => c.MotorExistenteID == Id && c.Estatus);
         if (MotorExistente == null)
             throw new EntityNotFoundException(Id.ToString(), "MotorExistente");
         EsNuevo = false;
     }
     catch (Exception ex)
     {
         Util.MensajeError(ex.Message, GlobalClass.NombreApp);
     }
 }
Exemple #2
0
 public DetalleMotorExistente(int Id)
 {
     InitializeComponent();
     try
     {
         //MotorExistente = General.GetEntityById<MotorExistente>("MotorExistente", "MotorExistenteID", Id);
         MotorExistente = Datos.GetEntity <MotorExistente>(c => c.MotorExistenteID == Id && c.Estatus);
         if (MotorExistente == null)
         {
             throw new EntityNotFoundException(Id.ToString(), "MotorExistente");
         }
         EsNuevo = false;
     }
     catch (Exception ex)
     {
         Util.MensajeError(ex.Message, GlobalClass.NombreApp);
     }
 }
Exemple #3
0
        protected override void btnGuardar_Click(object sender, EventArgs e)
        {
            if (!Validaciones())
            {
                return;
            }

            try
            {
                if (EsNuevo)
                {
                    var motor = new MotorExistente()
                    {
                        NombreMotorExistente = txtNombreMotor.Text,
                        UsuarioID            = GlobalClass.UsuarioGlobal.UsuarioID,
                        FechaRegistro        = DateTime.Now,
                        Estatus    = true,
                        Actualizar = true
                    };
                    Datos.SaveOrUpdate <MotorExistente>(motor);
                }
                else
                {
                    MotorExistente.NombreMotorExistente = txtNombreMotor.Text;
                    MotorExistente.UsuarioID            = GlobalClass.UsuarioGlobal.UsuarioID;
                    MotorExistente.FechaModificacion    = DateTime.Now;
                    MotorExistente.Estatus = true;
                    Datos.SaveOrUpdate <MotorExistente>(MotorExistente);
                }
                new Notificacion("Motor Guardado exitosamente", 2 * 1000).Mostrar(Principal.Instance);
                motoresExistentes.Instance.CustomInvoke <motoresExistentes>(m => m.ActualizarListado());
            }
            catch (Exception ex)
            {
                Util.MensajeError(ex.Message, GlobalClass.NombreApp);
            }
            this.Close();
        }
        protected override void btnGuardar_Click(object sender, EventArgs e)
        {
            if (!Validaciones())
                return;

            try
            {
                if (EsNuevo)
                {
                    var motor = new MotorExistente()
                    {
                        NombreMotorExistente = txtNombreMotor.Text,
                        UsuarioID = GlobalClass.UsuarioGlobal.UsuarioID,
                        FechaRegistro = DateTime.Now,
                        Estatus = true,
                        Actualizar = true
                    };
                    Datos.SaveOrUpdate<MotorExistente>(motor);
                }
                else
                {
                    MotorExistente.NombreMotorExistente = txtNombreMotor.Text;
                    MotorExistente.UsuarioID = GlobalClass.UsuarioGlobal.UsuarioID;
                    MotorExistente.FechaModificacion = DateTime.Now;
                    MotorExistente.Estatus = true;
                    Datos.SaveOrUpdate<MotorExistente>(MotorExistente);
                }
                new Notificacion("Motor Guardado exitosamente", 2 * 1000).Mostrar(Principal.Instance);
                motoresExistentes.Instance.CustomInvoke<motoresExistentes>(m => m.ActualizarListado());
            }
            catch (Exception ex)
            {
                Util.MensajeError(ex.Message, GlobalClass.NombreApp);
            }
            this.Close();
        }