Ejemplo n.º 1
0
 public Referencia(Documento.TipoDocumento tipoDoc, string numero, DateTime fechaEmision, CodigoReferencia codigo, string razon)
 {
     this.tipoDoc      = tipoDoc;
     this.numero       = numero;
     this.fechaEmision = fechaEmision;
     this.codigo       = codigo;
     this.razon        = razon;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// actualiza un registro
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ASPxGridView1_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            try
            {
                using (var conexion = new DataModelFE())
                {
                    // se declara el objeto a insertar
                    CodigoReferencia dato = new CodigoReferencia();
                    //llena el objeto con los valores de la pantalla
                    dato.codigo = e.NewValues["codigo"] != null ? e.NewValues["codigo"].ToString().ToUpper() : null;

                    //busca el objeto
                    dato = conexion.CodigoReferencia.Find(dato.codigo);

                    dato.aplicaFacturas      = e.NewValues["aplicaFacturas"] != null ? e.NewValues["aplicaFacturas"].ToString().ToUpper() : null;
                    dato.aplicaNotas         = e.NewValues["aplicaNotas"] != null ? e.NewValues["aplicaNotas"].ToString().ToUpper() : null;
                    dato.descripcion         = e.NewValues["descripcion"] != null ? e.NewValues["descripcion"].ToString().ToUpper() : null;
                    dato.estado              = e.NewValues["estado"].ToString();
                    dato.usuarioModificacion = Session["usuario"].ToString();
                    dato.fechaModificacion   = Date.DateTimeNow();

                    //modifica objeto
                    conexion.Entry(dato).State = EntityState.Modified;
                    conexion.SaveChanges();

                    //esto es para el manero del devexpress
                    e.Cancel = true;
                    this.ASPxGridView1.CancelEdit();
                }
            }
            catch (DbEntityValidationException ex)
            {
                // Retrieve the error messages as a list of strings.
                var errorMessages = ex.EntityValidationErrors
                                    .SelectMany(x => x.ValidationErrors)
                                    .Select(x => x.ErrorMessage);

                // Join the list to a single string.
                var fullErrorMessage = string.Join("; ", errorMessages);

                // Throw a new DbEntityValidationException with the improved exception message.
                throw new DbEntityValidationException(fullErrorMessage, ex.EntityValidationErrors);
            }
            catch (Exception ex)
            {
                throw new Exception(Utilidades.validarExepcionSQL(ex), ex.InnerException);
            }
            finally
            {
                //refescar los datos
                this.refreshData();
            }
        }