private void btnAddPariente_Click(object sender, EventArgs e)
        {
            try {
                if (txtArchivo.Text == "")
                {
                    RadMessageBox.Show("Selecciona un archivo antes de continuar", this.Text, MessageBoxButtons.OK, RadMessageIcon.Exclamation);
                    return;
                }

                if (oList.FindAll(item => item.Documento.Id == int.Parse(cboDocs.SelectedValue.ToString()) && item.DatosUsuario.Estatus == true).Count == 0)
                {
                    DigitalizadosDetalleBE oDetalle = new DigitalizadosDetalleBE();

                    oDetalle.Sel              = false;
                    oDetalle.Documento.Id     = int.Parse(cboDocs.SelectedValue.ToString());
                    oDetalle.Documento.Nombre = cboDocs.SelectedItem.Text;
                    oDetalle.RutaArchivo      = path;
                    oDetalle.NombreArchivo    = System.IO.Path.GetFileName(oDialog.FileName);
                    oDetalle.RutaOriginal     = oDialog.FileName;
                    oDetalle.Archivo          = ConvertImage.FileToByteArray(oDialog.FileName);

                    oList.Add(oDetalle);

                    ActualizaGrid();
                    txtArchivo.Text = string.Empty;
                }
                else
                {
                    RadMessageBox.Show("No es posible agregar un tipo de documento o un archivo  que ya existe en la lista", this.Text, MessageBoxButtons.OK, RadMessageIcon.Info);
                }
            } catch (Exception ex) {
                RadMessageBox.Show("Ocurrió un error al agregar el archivo\n" + ex.Message, this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
            }
        }
        private void btnImagen_Click(object sender, EventArgs e)
        {
            OpenFileDialog oDialog = new OpenFileDialog();

            try {
                oDialog.Filter = "Archivos jpg (*.jpg)|*.jpg";
                oDialog.Title  = "Imagen de Producto";

                if (oDialog.ShowDialog() == DialogResult.OK)
                {
                    System.IO.FileInfo oFile = new System.IO.FileInfo(oDialog.FileName);

                    if (oFile.Length > 200000)
                    {
                        RadMessageBox.Show("La imagen debe no debe ser mayor a 200Kb", this.Text, MessageBoxButtons.OK, RadMessageIcon.Info);
                    }
                    else
                    {
                        Imagen        = ConvertImage.FileToByteArray(oDialog.FileName);
                        picFoto.Image = ConvertImage.ByteToImage(Imagen);
                    }
                }
            } catch (Exception ex) {
                RadMessageBox.Show("Ocurrió un error al cargar la fotografía del expediente\n" + ex.Message, this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
            }
        }
Example #3
0
        private Byte[] ObtenerImagen(int Expediente)
        {
            byte[] Foto;
            string Imagen = RutaImagen + Expediente.ToString() + ".png";;

            try {
                if (File.Exists(Imagen))
                {
                    Foto = ConvertImage.FileToByteArray(Imagen);
                }
                else
                {
                    Foto = null;
                }
            } catch (Exception ex) {
                throw new Exception("Error al intentar guardar el archivo.", ex);
            }
            return(Foto);
        }
        private void ObtenerArchivos(int Expediente, ref List <DigitalizadosDetalleBE> oList)
        {
            string Ruta = RutaDoctos + Expediente.ToString() + "\\";

            try {
                if (!Directory.Exists(Ruta))
                {
                    Directory.CreateDirectory(Ruta);
                }

                DirectoryInfo Dir = new DirectoryInfo(Ruta);
                foreach (var fi in Dir.GetFiles())
                {
                    var file = oList.Find(item => item.NombreArchivo == fi.Name);
                    file.Archivo = ConvertImage.FileToByteArray(Ruta + fi.Name);
                }
            } catch (Exception ex) {
                throw new Exception("Error al intentar guardar el archivo.", ex);
            }
        }