Exemple #1
0
        public static void EliminarFisicoEntidadDetalleProceso(DocumentoDetalleBE DocumentoDetalle, DBBaseDatos BaseDatos = null)
        {
            DBBaseDatos baseDatosDA = new DBBaseDatos();

            if (BaseDatos == null)
            {
                baseDatosDA.Configurar();
                baseDatosDA.Conectar();
            }
            else
            {
                baseDatosDA = BaseDatos;
            }

            try
            {
                baseDatosDA.CrearComando("USP_DOCUMENTO_DET_PROC", CommandType.StoredProcedure);
                baseDatosDA.AsignarParametroCadena("@PCH_TIPO_TRANSACCION", "F", true);
                baseDatosDA.AsignarParametroCadena("@PCH_ID_DOCUMENTO", DocumentoDetalle.Documento.Documento.IdValor, true);
                baseDatosDA.EjecutarComando();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (BaseDatos == null)
                {
                    baseDatosDA.Desconectar();
                    baseDatosDA = null;
                }
            }
        }
Exemple #2
0
        public static void ObtenerDocumentoDetalle(DocumentoDetalleBE DocumentoDetalle
                                                   //,DocumentoBE Documento
                                                   //,String IdValor
                                                   , CheckBox chkAprobado,
                                                   HtmlInputHidden hfComentario,
                                                   DropDownList ddlValor = null,
                                                   TextBox txtValor      = null, HiddenField hfValor = null, String strRutaArchivo = null, Type tipo = null)
        {
            //DocumentoDetalle = new DocumentoDetalleBE();
            //DocumentoDetalle.Documento = Documento;
            //DocumentoDetalle.Campo.IdValor = IdValor;
            chkAprobado.Checked = DocumentoDetalle.Aprobado;
            hfComentario.Value  = DocumentoDetalle.Comentario;
            if (ddlValor != null)
            {
                ddlValor.SelectedValue = DocumentoDetalle.IdValor;
                //DocumentoDetalle.IdValor = ddlValor.SelectedValue;
                //DocumentoDetalle.ValorCadena = ddlValor.SelectedItem.Text;
            }
            else if (txtValor != null)
            {
                if (tipo != null && tipo.Equals(Type.GetType("System.DateTime")))
                {
                    if (!DocumentoDetalle.ValorFecha.Equals(Convert.ToDateTime("01/01/0001 00:00:00.00")))
                    {
                        txtValor.Text = DocumentoDetalle.ValorFecha.ToString("dd/MM/yyyy");
                    }
                }
                else if (tipo != null && tipo.Equals(Type.GetType("System.String")))
                {
                    txtValor.Text = DocumentoDetalle.ValorCadena;
                }
                else if (tipo != null && tipo.Equals(Type.GetType("System.Double")))
                {
                    if (DocumentoDetalle.ValorNumerico != null)
                    {
                        txtValor.Text = DocumentoDetalle.ValorNumerico.ToString();
                    }
                }
                else if (tipo != null && tipo.Equals(Type.GetType("System.Int32")))
                {
                    if (DocumentoDetalle.ValorEntero != null)
                    {
                        //DocumentoDetalle.ValorEntero = Convert.ToInt32(txtValor.Text);
                        txtValor.Text = DocumentoDetalle.ValorEntero.ToString();
                    }
                }
            }
            else if (hfValor != null)
            {
                if (tipo != null && tipo.Equals(Type.GetType("System.Byte[]")))
                {
                    if (DocumentoDetalle.ValorBinario != null)
                    {
                        //Creamos la imagen en ruta
                        //String strArchivo = DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss") + DocumentoDetalle.Documento.Documento.IdValor + "_" + DocumentoDetalle.Campo.IdValor + ".png";
                        String strArchivo = DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss") + DocumentoDetalle.Documento.Documento.IdValor + "_" + DocumentoDetalle.Campo.IdValor + DocumentoDetalle.ExtensionArchivo;
                        File.WriteAllBytes(strRutaArchivo + "\\" + strArchivo, DocumentoDetalle.ValorBinario); // Requires System.IO
                        //#region Agregado Carlos Ramos 19/06/2018 De ser necesario Se cambia la orientacion de la imagen
                        //if (DocumentoDetalle.ExtensionArchivo.Equals(".jpg"))
                        //{
                        //    var bmp = new Bitmap(strRutaArchivo + "\\" + strArchivo);
                        //    var exif = new EXIFextractor(ref bmp, "n"); // get source from http://www.codeproject.com/KB/graphics/exifextractor.aspx?fid=207371

                        //    if (exif["Orientation"] != null)
                        //    {
                        //        RotateFlipType flip = OrientationToFlipType(exif["Orientation"].ToString());

                        //        if (flip != RotateFlipType.RotateNoneFlipNone) // don't flip of orientation is correct
                        //        {
                        //            bmp.RotateFlip(flip);
                        //            exif.setTag(0x112, "1"); // Optional: reset orientation tag
                        //            bmp.Save(strRutaArchivo + "\\" + strArchivo);
                        //        }
                        //    }
                        //}
                        //#endregion
                        hfValor.Value = strArchivo;
                    }
                }
            }
            //Documento.Detalles.Add(DocumentoDetalle.Clone());
        }
Exemple #3
0
        /// <summary>
        /// Perform a deep Copy of the object.
        /// </summary>
        /// <typeparam name="T">The type of object being copied.</typeparam>
        /// <param name="source">The object instance to copy.</param>
        /// <returns>The copied object.</returns>
        //public static T Clone<T>(this T source)
        //{
        //    if (!typeof(T).IsSerializable)
        //        throw new ArgumentException("The type must be serializable.", "source");

        //    // Don't serialize a null object, simply return the default for that object
        //    if (Object.ReferenceEquals(source, null))
        //        return default(T);

        //    var Ser = new XmlSerializer(typeof(T));
        //    using (var Ms = new MemoryStream())
        //    {
        //        Ser.Serialize(Ms, source);
        //        Ms.Seek(0, SeekOrigin.Begin);
        //        return (T)Ser.Deserialize(Ms);
        //    }
        //}

        public static void AsignarDocumentoDetalle(DocumentoDetalleBE DocumentoDetalle,
                                                   DocumentoBE Documento, String IdValor, CheckBox chkAprobado,
                                                   HtmlInputHidden hfComentario,
                                                   DropDownList ddlValor = null,
                                                   TextBox txtValor      = null, HiddenField hfValor = null, String strRutaArchivo = null, Type tipo = null)
        {
            DocumentoDetalle               = new DocumentoDetalleBE();
            DocumentoDetalle.Documento     = Documento;
            DocumentoDetalle.Campo.IdValor = IdValor;
            DocumentoDetalle.Aprobado      = chkAprobado.Checked;
            DocumentoDetalle.Comentario    = hfComentario.Value.ToUpper();
            if (ddlValor != null)
            {
                DocumentoDetalle.IdValor     = ddlValor.SelectedValue;
                DocumentoDetalle.ValorCadena = ddlValor.SelectedItem.Text;
            }
            else if (txtValor != null)
            {
                if (tipo != null && tipo.Equals(Type.GetType("System.DateTime")))
                {
                    if (!txtValor.Text.Equals(""))
                    {
                        DocumentoDetalle.ValorFecha = Convert.ToDateTime(txtValor.Text);
                    }
                }
                else if (tipo != null && tipo.Equals(Type.GetType("System.String")))
                {
                    DocumentoDetalle.ValorCadena = txtValor.Text.ToUpper();
                }
                else if (tipo != null && tipo.Equals(Type.GetType("System.Double")))
                {
                    if (!txtValor.Text.Equals(""))
                    {
                        DocumentoDetalle.ValorNumerico = Convert.ToDouble(txtValor.Text);
                    }
                }
                else if (tipo != null && tipo.Equals(Type.GetType("System.Int32")))
                {
                    if (!txtValor.Text.Equals(""))
                    {
                        //DocumentoDetalle.ValorEntero = Convert.ToInt32(txtValor.Text);
                        DocumentoDetalle.ValorEntero = Convert.ToInt32(Convert.ToDouble(txtValor.Text));
                    }
                }
            }
            else if (hfValor != null)
            {
                if (tipo != null && tipo.Equals(Type.GetType("System.Byte[]")))
                {
                    if (!hfValor.Value.Equals(""))
                    {
                        DocumentoDetalle.ExtensionArchivo = Path.GetExtension(strRutaArchivo + "\\" + hfValor.Value).ToLower();
                        #region Agregado Carlos Ramos 19/06/2018 De ser necesario Se cambia la orientacion de la imagen
                        if (DocumentoDetalle.ExtensionArchivo.Equals(".jpg"))
                        {
                            var bmp  = new Bitmap(strRutaArchivo + "\\" + hfValor.Value);
                            var exif = new EXIFextractor(ref bmp, "n"); // get source from http://www.codeproject.com/KB/graphics/exifextractor.aspx?fid=207371

                            if (exif["Orientation"] != null)
                            {
                                RotateFlipType flip = OrientationToFlipType(exif["Orientation"].ToString());

                                if (flip != RotateFlipType.RotateNoneFlipNone) // don't flip of orientation is correct
                                {
                                    bmp.RotateFlip(flip);
                                    exif.setTag(0x112, "1"); // Optional: reset orientation tag
                                    bmp.Save(strRutaArchivo + "\\" + hfValor.Value);
                                }
                            }
                        }
                        #endregion
                        DocumentoDetalle.ValorBinario = File.ReadAllBytes(strRutaArchivo + "\\" + hfValor.Value);
                    }
                }
            }
            Documento.Detalles.Add(DocumentoDetalle.Clone());
        }
Exemple #4
0
        public static void ActualizarDocumentoDetalle(DocumentoDetalleBE DocumentoDetalle, DBBaseDatos BaseDatos = null)
        {
            DBBaseDatos baseDatosDA = new DBBaseDatos();

            if (BaseDatos == null)
            {
                baseDatosDA.Configurar();
                baseDatosDA.Conectar();
            }
            else
            {
                baseDatosDA = BaseDatos;
            }

            try
            {
                baseDatosDA.CrearComando("USP_DOCUMENTO_DET", CommandType.StoredProcedure);
                baseDatosDA.AsignarParametroCadena("@PCH_TIPO_TRANSACCION", "U", true);
                baseDatosDA.AsignarParametroCadena("@PCH_ID_DOCUMENTO", DocumentoDetalle.Documento.Documento.IdValor, true);
                baseDatosDA.AsignarParametroCadena("@PCH_ID_TAREA", DocumentoDetalle.Documento.Tarea.IdTarea, true);
                baseDatosDA.AsignarParametroCadena("@PCH_ID_CAMPO", DocumentoDetalle.Campo.IdValor, true);
                if (DocumentoDetalle.IdValor.Equals(""))
                {
                    baseDatosDA.AsignarParametroNulo("@PVC_VALOR_CAMPO", true);
                }
                else
                {
                    baseDatosDA.AsignarParametroCadena("@PVC_VALOR_CAMPO", DocumentoDetalle.IdValor, true);
                }
                if (DocumentoDetalle.ValorCadena.Equals(""))
                {
                    baseDatosDA.AsignarParametroNulo("@PVC_VALOR_CADENA", true);
                }
                else
                {
                    baseDatosDA.AsignarParametroCadena("@PVC_VALOR_CADENA", DocumentoDetalle.ValorCadena, true);
                }
                if (DocumentoDetalle.ValorEntero.Equals(null))
                {
                    baseDatosDA.AsignarParametroNulo("@PIN_VALOR_ENTERO", true);
                }
                else
                {
                    baseDatosDA.AsignarParametroEntero("@PIN_VALOR_ENTERO", (Int32)DocumentoDetalle.ValorEntero, true);
                }
                if (DocumentoDetalle.ValorNumerico.Equals(null))
                {
                    baseDatosDA.AsignarParametroNulo("@PNU_VALOR_NUMERICO", true);
                }
                else
                {
                    baseDatosDA.AsignarParametroDouble("@PNU_VALOR_NUMERICO", (Double)DocumentoDetalle.ValorNumerico, true);
                }
                if (DocumentoDetalle.ValorFecha.Equals(Convert.ToDateTime("01/01/0001 00:00:00.00")))
                {
                    baseDatosDA.AsignarParametroNulo("@PDT_VALOR_FECHA", true);
                }
                else
                {
                    baseDatosDA.AsignarParametroFecha("@PDT_VALOR_FECHA", DocumentoDetalle.ValorFecha, true);
                }
                if (DocumentoDetalle.ValorBoolean.Equals(null))
                {
                    baseDatosDA.AsignarParametroNulo("@PBL_VALOR_BOOLEANO", true);
                }
                else
                {
                    baseDatosDA.AsignarParametroBoolean("@PBL_VALOR_BOOLEANO", (Boolean)DocumentoDetalle.ValorBoolean, true);
                }
                if (DocumentoDetalle.ValorBinario == null || DocumentoDetalle.ValorBinario.Length.Equals(0))
                {
                    baseDatosDA.AsignarParametroNulo("@PVB_VALOR_BINARIO", true, ParameterDirection.Input, DbType.Binary);
                }
                else
                {
                    baseDatosDA.AsignarParametroArrayByte("@PVB_VALOR_BINARIO", DocumentoDetalle.ValorBinario, true, ParameterDirection.Input, DbType.Binary);
                }
                if (DocumentoDetalle.ExtensionArchivo.Equals(""))
                {
                    baseDatosDA.AsignarParametroNulo("@PVC_EXTENSION_ARCHIVO", true);
                }
                else
                {
                    baseDatosDA.AsignarParametroCadena("@PVC_EXTENSION_ARCHIVO", DocumentoDetalle.ExtensionArchivo, true);
                }
                baseDatosDA.AsignarParametroBoolean("@PBL_APROBADO", DocumentoDetalle.Aprobado, true);
                baseDatosDA.AsignarParametroCadena("@PVC_COMENTARIO", DocumentoDetalle.Comentario, true);
                baseDatosDA.AsignarParametroCadena("@PVC_ID_USUARIO_MOD", DocumentoDetalle.UsuarioModificacion.IdUsuario, true);

                baseDatosDA.EjecutarComando();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (BaseDatos == null)
                {
                    baseDatosDA.Desconectar();
                    baseDatosDA = null;
                }
            }
        }
Exemple #5
0
        public static List <DocumentoDetalleBE> ListarDocumentoDetalle(DocumentoDetalleBE DocumentoDetalle)
        {
            List <DocumentoDetalleBE> lstResultado = new List <DocumentoDetalleBE>();
            DBBaseDatos baseDatosDA = new DBBaseDatos();

            baseDatosDA.Configurar();
            baseDatosDA.Conectar();
            try
            {
                baseDatosDA.CrearComando("USP_DOCUMENTO_DET", CommandType.StoredProcedure);
                baseDatosDA.AsignarParametroCadena("@PCH_TIPO_TRANSACCION", "S", true);
                if (DocumentoDetalle.Documento.Documento.IdValor.Equals(""))
                {
                    baseDatosDA.AsignarParametroNulo("@PCH_ID_DOCUMENTO", true);
                }
                else
                {
                    baseDatosDA.AsignarParametroCadena("@PCH_ID_DOCUMENTO", DocumentoDetalle.Documento.Documento.IdValor, true);
                }
                if (DocumentoDetalle.Documento.Tarea.IdTarea.Equals(""))
                {
                    baseDatosDA.AsignarParametroNulo("@PCH_ID_TAREA", true);
                }
                else
                {
                    baseDatosDA.AsignarParametroCadena("@PCH_ID_TAREA", DocumentoDetalle.Documento.Tarea.IdTarea, true);
                }

                DbDataReader drDatos = baseDatosDA.EjecutarConsulta();

                while (drDatos.Read())
                {
                    DocumentoDetalleBE item = new DocumentoDetalleBE();
                    item.Documento = new DocumentoBE();

                    item.Documento.Documento.IdValor = drDatos.GetString(drDatos.GetOrdinal("CH_ID_DOCUMENTO"));
                    item.Documento.Tarea.IdTarea     = drDatos.GetString(drDatos.GetOrdinal("CH_ID_TAREA"));
                    item.Campo.IdValor = drDatos.GetString(drDatos.GetOrdinal("CH_ID_CAMPO"));

                    if (!drDatos.IsDBNull(drDatos.GetOrdinal("VC_VALOR_CAMPO")))
                    {
                        item.IdValor = drDatos.GetString(drDatos.GetOrdinal("VC_VALOR_CAMPO"));
                    }
                    if (!drDatos.IsDBNull(drDatos.GetOrdinal("VC_VALOR_CADENA")))
                    {
                        item.ValorCadena = drDatos.GetString(drDatos.GetOrdinal("VC_VALOR_CADENA"));
                    }
                    if (!drDatos.IsDBNull(drDatos.GetOrdinal("IN_VALOR_ENTERO")))
                    {
                        item.ValorEntero = drDatos.GetInt32(drDatos.GetOrdinal("IN_VALOR_ENTERO"));
                    }
                    if (!drDatos.IsDBNull(drDatos.GetOrdinal("NU_VALOR_NUMERICO")))
                    {
                        item.ValorNumerico = (Double)drDatos.GetDecimal(drDatos.GetOrdinal("NU_VALOR_NUMERICO"));
                    }
                    if (!drDatos.IsDBNull(drDatos.GetOrdinal("DT_VALOR_FECHA")))
                    {
                        item.ValorFecha = drDatos.GetDateTime(drDatos.GetOrdinal("DT_VALOR_FECHA"));
                    }
                    if (!drDatos.IsDBNull(drDatos.GetOrdinal("BL_VALOR_BOOLEANO")))
                    {
                        item.ValorBoolean = drDatos.GetBoolean(drDatos.GetOrdinal("BL_VALOR_BOOLEANO"));
                    }
                    if (!drDatos.IsDBNull(drDatos.GetOrdinal("VB_VALOR_BINARIO")))
                    {
                        item.ValorBinario = (Byte[])drDatos.GetValue(drDatos.GetOrdinal("VB_VALOR_BINARIO"));
                    }
                    if (!drDatos.IsDBNull(drDatos.GetOrdinal("VC_EXTENSION_ARCHIVO")))
                    {
                        item.ExtensionArchivo = drDatos.GetString(drDatos.GetOrdinal("VC_EXTENSION_ARCHIVO"));
                    }
                    item.Aprobado = drDatos.GetBoolean(drDatos.GetOrdinal("BL_APROBADO"));
                    if (!drDatos.IsDBNull(drDatos.GetOrdinal("VC_COMENTARIO")))
                    {
                        item.Comentario = drDatos.GetString(drDatos.GetOrdinal("VC_COMENTARIO"));
                    }
                    lstResultado.Add(item);
                }

                drDatos.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                baseDatosDA.Desconectar();
                baseDatosDA = null;
            }

            return(lstResultado);
        }