Exemplo n.º 1
0
 public void Save(documento entity)
 {
     DataModel.Entry(entity).State = entity.id_documento == 0 ?
                                     EntityState.Added :
                                     EntityState.Modified;
     DataModel.SaveChanges();
 }
Exemplo n.º 2
0
        //---------------FUNCIONES DE CREAR, EDITAR Y ELIMINAR
        public static bool Add_AutoEvaluacion(Tuple <int, int> IdEmpSuc, String[] valores, FileUpload flpArchivo)
        {
            int     IdEmpresa  = IdEmpSuc.Item1;
            int     IdSucursal = IdEmpSuc.Item2;
            Boolean berror     = false;
            string  _ruta      = Utilidades.GuardarArchivo(flpArchivo, IdEmpresa + valores[0], Paginas.Archivos_Autoevaluacion.Value);

            DateTime fecha = new DateTime(Convert.ToInt32(valores[1]), 1, 1);

            documento nuevo = new documento()
            {
                nombre       = valores[2],
                ruta         = _ruta,
                fecha_subida = fecha,
                id_tabla     = IdSucursal,
                tipo         = TipoDocumento.Auto_Evaluacion.Value
            };

            berror = CRUD.Add_Fila(nuevo);

            if (berror)
            {
                GrupoLiEntities contexto = new GrupoLiEntities();
                lista_actividad Edit     = contexto.lista_actividad.SingleOrDefault(b => b.id_sucursal == IdSucursal);
                if (Edit != null)
                {
                    Edit.estatus = "Si";
                }
                berror = CRUD.Edit_Fila(contexto);
            }

            return(berror);
        }
Exemplo n.º 3
0
        public ActionResult Create(documento documento)
        {
            LoadFormJuri();

            try
            {
                if (validate(documento))
                {
                    return(View(documento));
                }

                if (UploadFile(ref documento))
                {
                    DocumentoRepository.Create(documento);
                    return(RedirectToAction("List", new { message = "Dados cadastrados com sucesso!" }));
                }
                else
                {
                    throw new Exception("Ocorreu um erro ao criar o registro");
                }
            }
            catch
            {
                if (!FileServerHelper.DeleteFile(documento.path))
                {
                    throw new Exception("Não foi possível excluir o arquivo");
                }
                else
                {
                    return(View(documento));
                }
            }
        }
Exemplo n.º 4
0
        public FileStreamResult Download(int id)
        {
            documento anexos      = DocumentoRepository.GetOne(id);
            string    contentType = FileServerHelper.GetContentType(anexos.path.Substring(anexos.path.LastIndexOf('.')));

            return(File(new FileStream(anexos.path, FileMode.Open), contentType));
        }
Exemplo n.º 5
0
        public static bool Delete_AutoEvaluacion(String idAutoEvaluacion, Model_UsuarioSistema ObjUsuario)
        {
            int idAuto     = Convert.ToInt32(idAutoEvaluacion);
            int idSucursal = 0;

            GrupoLiEntities  contexto       = new GrupoLiEntities();
            List <documento> ListaDocumento = new List <documento>();

            ListaDocumento = contexto.documento.Where(b => b.id_documento == idAuto).ToList();

            foreach (var item in ListaDocumento)
            {
                idSucursal = Convert.ToInt32(item.id_tabla);
            }

            documento tabla = new documento();

            ObjUsuario.Error = CRUD.Delete_Fila(tabla, idAuto);

            if (ObjUsuario.Error)
            {
                contexto = new GrupoLiEntities();
                lista_actividad Edit = contexto.lista_actividad.SingleOrDefault(b => b.id_sucursal == idSucursal);
                if (Edit != null)
                {
                    Edit.estatus = "No";
                }
                ObjUsuario.Error = CRUD.Edit_Fila(contexto);
            }

            return(ObjUsuario.Error);
        }
Exemplo n.º 6
0
 public ActionResult AgregarNiveles(int?id)
 {
     if (Session["usuario"] != null)
     {
         usuario usuarioSesion = (usuario)HttpContext.Session["usuario"];
         if (usuarioSesion.roles.FirstOrDefault().rol.Equals(Constantes.ADMINISTRADOR))
         {
             if (id == null)
             {
                 return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
             }
             documento documento = db.documentos.Find(id);
             if (documento == null)
             {
                 return(HttpNotFound());
             }
             ViewBag.id_tipo = new SelectList(db.tipo_documento, "id", "tipo_documento1", documento.id_tipo);
             return(View(documento));
         }
         else
         {
             return(RedirectToAction("../"));
         }
     }
     return(RedirectToAction("../Account/Login/ReturnUrl=documentos"));
 }
Exemplo n.º 7
0
        // GET: documentos/Details/5
        public ActionResult Details(int?id)
        {
            if (Session["usuario"] != null)
            {
                usuario usuarioSesion = (usuario)HttpContext.Session["usuario"];
                if (usuarioSesion.roles.FirstOrDefault().rol.Equals(Constantes.ADMINISTRADOR))
                {
                    if (id == null)
                    {
                        return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                    }
                    documento documento = db.documentos.Find(id);
                    if (documento == null)
                    {
                        return(HttpNotFound());
                    }
                    string nombreArchivo = Path.GetFileName(documento.url);
                    string ruta          = "~/Recursos/Documentos/" + nombreArchivo;
                    documento.url = ruta;

                    return(View(documento));
                }
                else
                {
                    return(RedirectToAction("../"));
                }
            }
            return(RedirectToAction("../Account/Login/ReturnUrl=documentos"));
        }
Exemplo n.º 8
0
 public ActionResult Create([Bind(Include = "id,id_tipo,url,contador_visitas,titulo,descripcion_corta,descripcion_detallada,fecha_publicacion,status,imagen,historial_version,numero_version,unidad,capitulo")] documento documento, HttpPostedFileBase file, ICollection <int> nivel)
 {
     if (ModelState.IsValid)
     {
         if (file.ContentLength > 0)
         {
             string ruta       = Path.Combine(Request.PhysicalApplicationPath, "Recursos", "Documentos", "" + documento.unidad);
             string archivo    = Path.GetFileName(file.FileName);
             string ruta_final = Path.Combine(ruta, archivo);
             documento.url = ruta_final;
             documento.fecha_publicacion = DateTime.Today;
             if (!Directory.Exists(ruta))
             {
                 Directory.CreateDirectory(ruta);
             }
             file.SaveAs(ruta_final);
         }
         foreach (int nivelSeleccionado in nivel)
         {
             nivele nivelobj = db.niveles.Find(nivelSeleccionado);
             documento.niveles.Add(nivelobj);
         }
         db.documentos.Add(documento);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.nivel   = new MultiSelectList(db.niveles, "id", "nivel");
     ViewBag.id_tipo = new SelectList(db.tipo_documento, "id", "tipo_documento1", documento.id_tipo);
     ViewBag.unidad  = new SelectList(db.unidades, "id", "unidad", documento.unidad);
     return(View(documento));
 }
Exemplo n.º 9
0
 // GET: documentos/Delete/5
 public ActionResult Delete(int?id)
 {
     if (Session["usuario"] != null)
     {
         usuario usuarioSesion = (usuario)HttpContext.Session["usuario"];
         if (usuarioSesion.roles.FirstOrDefault().rol.Equals(Constantes.ADMINISTRADOR))
         {
             if (id == null)
             {
                 return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
             }
             documento documento = db.documentos.Find(id);
             if (documento == null)
             {
                 return(HttpNotFound());
             }
             return(View(documento));
         }
         else
         {
             return(RedirectToAction("../"));
         }
     }
     return(RedirectToAction("../Account/Login/ReturnUrl=documentos"));
 }
Exemplo n.º 10
0
        public ActionResult Delete(int id, documento documento)
        {
            try
            {
                documento = DocumentoRepository.GetOne(id);

                if (ExistDependences(documento))
                {
                    return(View(documento));
                }

                if (!FileServerHelper.DeleteFile(documento.path))
                {
                    throw new Exception("Não foi possível salvar o arquivo");
                }
                else
                {
                    DocumentoRepository.Delete(documento);
                }

                return(RedirectToAction("List", new { message = "Dados excluídos com sucesso!" }));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 11
0
        protected void EditarRegistro(object sender, EventArgs e)
        {
            int IdEmpresa  = Mgr_Empresa.Set_IdEmpresaDDl(ObjUsuario, ddlEmpresaEdit);
            int IdSucursal = Mgr_Sucursal.Set_IdSucursalDDl(ObjUsuario, ddlSucursalEdit);

            string ruta = Utilidades.GuardarArchivo(flpArchivoEdit, IdEmpresa + txtNombreEdit.Text, "~/archivos/mapas/");

            GrupoLiEntities contexto = new GrupoLiEntities();
            int             idPlan   = Convert.ToInt32(hdfPlanID.Value);

            documento Edit = contexto.documento.SingleOrDefault(b => b.id_documento == idPlan);

            if (Edit != null)
            {
                Edit.nombre   = txtNombreEdit.Text;
                Edit.ruta     = ruta;
                Edit.id_tabla = IdSucursal;
            }

            ObjUsuario.Error = CRUD.Edit_Fila(contexto);


            Modal.MostrarAlertaEdit(phAlerta, divAlerta, lbAlerta, ObjUsuario.Error, txtBuscar);
            LlenarGridView();
        }
Exemplo n.º 12
0
 public ActionResult Edit([Bind(Include = "id,descripcion")] libro libro, ICollection <int> documentosSeleccionados, ICollection <int> documentosRemover)
 {
     if (ModelState.IsValid)
     {
         db.Entry(libro).State = EntityState.Modified;
         if (documentosRemover != null)
         {
             foreach (int docRemover in documentosRemover)
             {
                 documento documento = db.documentos.Find(docRemover);
                 db.documentos.Find(documento.id).libros.Remove(libro);
             }
         }
         if (documentosSeleccionados != null)
         {
             foreach (int docAgregar in documentosSeleccionados)
             {
                 documento documento = db.documentos.Find(docAgregar);
                 libro.documentos.Add(documento);
             }
         }
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(libro));
 }
        public RenameDocument(ListView.SelectedListViewItemCollection selectedItems)
        {
            InitializeComponent();

            if (selectedItems.Count > 0)
            {
                this.SelectedItems = selectedItems;

                if (this.SelectedItems.Count == 1)
                {
                    this.label.Text = "Digite um novo nome para o documento";

                    documento tag = (documento)this.SelectedItems[0].Tag;

                    if (tag != null)
                    {
                        this.boxName.Text = tag.name;
                    }
                }
                else
                {
                    this.label.Text = "Digite um novo nome para os [" + this.SelectedItems.Count + "] documentos";
                }
            }
            else
            {
                MessageBox.Show("Não foi possível renomear o documento");
            }

            this.ShowDialog();
        }
Exemplo n.º 14
0
        public ActionResult Edit([Bind(Include = "id,id_tipo,url,contador_visitas,titulo,descripcion_corta,descripcion_detallada,fecha_publicacion,status,imagen,historial_version,numero_version,unidad,capitulo")] documento documento, HttpPostedFileBase file, int unidadAnterior, ICollection <int> nivel)
        {
            if (ModelState.IsValid)
            {
                db.Entry(documento).State = EntityState.Modified;
                if (file != null)
                {
                    try
                    {
                        System.IO.File.Delete(documento.url);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                    string ruta       = Path.Combine(Request.PhysicalApplicationPath, "Recursos", "Documentos", "" + documento.unidad);
                    string archivo    = Path.GetFileName(file.FileName);
                    string ruta_final = Path.Combine(ruta, archivo);
                    documento.url = ruta_final;
                    if (!Directory.Exists(ruta))
                    {
                        Directory.CreateDirectory(ruta);
                    }
                    file.SaveAs(ruta_final);
                }
                else if (unidadAnterior != 0)
                {
                    if (unidadAnterior != documento.unidad)
                    {
                        string ruta       = Path.Combine(Request.PhysicalApplicationPath, "Recursos", "Documentos", "" + documento.unidad);
                        string archivo    = Path.GetFileName(documento.url);
                        string ruta_final = Path.Combine(ruta, archivo);
                        try
                        {
                            System.IO.File.Move(documento.url, ruta_final);
                            documento.url = ruta_final;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }
                    }
                }
                if (nivel != null && nivel.Count > 0)
                {
                    foreach (var item in nivel)
                    {
                        nivele nivelObj = db.niveles.Find(item);
                        documento.niveles.Add(nivelObj);
                    }
                }

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.unidad  = new SelectList(db.unidades, "id", "unidad", documento.unidad);
            ViewBag.id_tipo = new SelectList(db.tipo_documento, "id", "tipo_documento1", documento.id_tipo);
            return(View(documento));
        }
Exemplo n.º 15
0
        public void FirmarUserPDF_POLICY_SELLO_GENERICO_Button_Click(object sender, EventArgs e)
        {
            //Recuperamos la instancia del cliente
            ViafirmaClient clienteViafirma = ViafirmaClientFactory.GetInstance();

            // Recuperamos el documento a firmar.
            //string path = Environment.CurrentDirectory;
            //FileStream fs = File.OpenRead(path + "\\resources\\exampleSign.pdf");
            Assembly assembly = Assembly.GetExecutingAssembly();
            Stream   fs       = assembly.GetManifestResourceStream(Global.DEMO_FILE_PDF_PATH);

            byte[] datos_a_firmar = new byte[fs.Length];
            fs.Read(datos_a_firmar, 0, datos_a_firmar.Length);

            //Obtengo la imagen a estampar
            Stream stampImage = assembly.GetManifestResourceStream(Global.DEMO_STAMPER_PATH);

            byte[] image = new byte[stampImage.Length];
            stampImage.Read(image, 0, image.Length);
            String imageB64 = System.Convert.ToBase64String(image);


            // Enviamos a firmar el documento

            //Creamos el objeto documento con los datos a firmar
            documento doc = new documento();

            doc.nombre         = "PDF_SELLOIMAGEN.pdf";
            doc.datos          = datos_a_firmar;
            doc.typeFormatSign = typeFormatSign.PAdES_BASIC;
            doc.tipo           = typeFile.PDF;

            // En algunos casos, por ejemplo en el arranque de la aplicación puede ser interesante
            // Comprobar que efectivamente el servidor de firma está disponible
            System.Console.Write(clienteViafirma.ping("Prueba Conexión") + "\n");

            //Creamos la politica de firma
            policy pol = PolicyUtil.newPolicy(typeFormatSign.PAdES_BASIC, typeSign.ATTACHED);

            PolicyUtil.AddParameter(pol, PolicyParams.DIGITAL_SIGN_PAGE, "1");
            //creamos el rectangle
            rectangle r = PolicyUtil.newRectangle(140, 200, 100, 50);

            PolicyUtil.AddParameter(pol, PolicyParams.DIGITAL_SIGN_RECTANGLE, PolicyUtil.rectangleToJson(r));

            // Registramos el documento que deseamos firmar. Obteniendo un identificador temporal.
            // Este identificador temporal no es necesario que sea almacenado ya que sólo tiene validez durante el proceso de firma.
            string idTemporalFirma = clienteViafirma.PrepareSignWithPolicy(pol, doc);

            System.Console.Write("idTemporalFirma: " + idTemporalFirma);

            //Logica del ejemplo para descagar el fichero con la extension correcta
            Session["extension"] = ".pdf";

            // Iniciamos el proceso de firma redireccionando al usuario a Viafirma..
            // Esto redireccionará al usuario a Viafirma para la firma del documento con el
            // identificador de firma indicado.
            clienteViafirma.Sign(idTemporalFirma);
        }
Exemplo n.º 16
0
        public void Download_Click(Object sender, EventArgs e)
        {
            LinkButton btn = sender as LinkButton;

            string signatureID = Convert.ToString(btn.CommandArgument);

            // Recuperamos la instancia del cliente
            ViafirmaClient clienteViafirma = ViafirmaClientFactory.GetInstance();

            // Recuperamos el documento original.
            documento docu = clienteViafirma.getOriginalDocument(signatureID);
            // Y lo ponemos a disposicion del usario

            Stream stream = null;

            try
            {
                // Open the file into a stream.
                stream = new MemoryStream(docu.datos);
                // Total bytes to read:
                long bytesToRead = stream.Length;
                Response.ContentType = "application/octet-stream";
                Response.AddHeader("Content-Disposition", "attachment; filename=" + "documentoOriginal.xml");
                // Read the bytes from the stream in small portions.
                while (bytesToRead > 0)
                {
                    // Make sure the client is still connected.
                    if (Response.IsClientConnected)
                    {
                        // Read the data into the buffer and write into the
                        // output stream.
                        byte[] buffer = new Byte[10000];
                        int    length = stream.Read(buffer, 0, 10000);
                        Response.OutputStream.Write(buffer, 0, length);
                        Response.Flush();
                        // We have already read some bytes.. need to read
                        // only the remaining.
                        bytesToRead = bytesToRead - length;
                    }
                    else
                    {
                        // Get out of the loop, if user is not connected anymore..
                        bytesToRead = -1;
                    }
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
                // An error occurred..
            }
            finally
            {
                if (stream != null)
                {
                    stream.Close();
                }
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            documento documento = db.documento.Find(id);

            db.documento.Remove(documento);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 18
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            documento documento = await db.documento.FindAsync(id);

            db.documento.Remove(documento);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Exemplo n.º 19
0
        protected void EliminarRegistro(object sender, EventArgs e)
        {
            documento tabla = new documento();

            ObjUsuario.Error = CRUD.Delete_Fila(tabla, Convert.ToInt32(hdfIDDel.Value));
            Modal.CerrarModal("deleteModal", "DeleteModalScript", this);
            Modal.MostrarAlertaDelete(phAlerta, divAlerta, lbAlerta, ObjUsuario.Error, txtBuscar);
            LlenarGridView();
        }
Exemplo n.º 20
0
        public void FirmarServerPDFButton_Click(object sender, EventArgs e)
        {
            //Recuperamos la instancia del cliente
            ViafirmaClient clienteViafirma = ViafirmaClientFactory.GetInstance();

            // Recuperamos el documento a firmar.
            //string path = Environment.CurrentDirectory;
            //FileStream fs = File.OpenRead(path + "\\resources\\exampleSign.pdf");

            Assembly assembly = Assembly.GetExecutingAssembly();
            Stream   fs       = assembly.GetManifestResourceStream(Global.DEMO_FILE_PDF_PATH);

            byte[] datos_a_firmar = new byte[fs.Length];
            fs.Read(datos_a_firmar, 0, datos_a_firmar.Length);

            //byte[] datos_a_firmar = File.ReadAllBytes(@"C:\598MB.pdf");

            //FileStream strm = new FileStream(@"C:\598MB.pdf", FileMode.Open, FileAccess.Read, FileShare.Read, 1024, FileOptions.Asynchronous);

            //datos_a_firmar_grande = new byte[strm.Length];
            //IAsyncResult result = strm.BeginRead(datos_a_firmar_grande, 0, datos_a_firmar_grande.Length, new AsyncCallback(CompleteRead), strm);



            // En algunos casos, por ejemplo en el arranque de la aplicación puede ser interesante
            // Comprobar que efectivamente el servidor de firma está disponible
            System.Console.Write(clienteViafirma.ping("Prueba Conexión") + "\n");

            // Enviamos a firmar el documento al servidor y obtenemos el identificador final de la firma.
            //idFirma = clienteViafirma.signByServerWithTypeFileAndFormatSign("FicheroEjemploServer.pdf", datos_a_firmar, Global.ALIAS, Global.PASS_CERT, typeFile.PDF, typeFormatSign.PDF_PKCS7);



            //Creamos el objeto documento con los datos a firmar
            documento doc = new documento();

            doc.nombre         = "PDF_ejemplo.pdf";
            doc.datos          = datos_a_firmar;
            doc.typeFormatSign = typeFormatSign.PAdES_LTV;
            doc.tipo           = typeFile.PDF;

            //Creamos la politica de firma
            policy pol = PolicyUtil.newPolicy(typeFormatSign.PAdES_LTV, typeSign.ATTACHED);

            idFirma = clienteViafirma.SignByServerWithPolicy(pol, doc, Global.ALIAS, Global.PASS_CERT);

            // Generamos la url a la página que gestiona la comunicación con Viafirma.
            // Uri url = new Uri(HttpContext.Current.Request.Url, HttpContext.Current.Response.ApplyAppPathModifier("~/ResultadoFirmaServidor.aspx"));
            // Log.Debug("Redireccionado al usuario a: " + url);

            // Guardamos el Id de Firma
            HttpContext.Current.Session["idFirma"] = idFirma;

            // Redirecciona a la url
            // HttpContext.Current.Response.Redirect(url.AbsoluteUri);
        }
 public ActionResult Edit([Bind(Include = "idDocumento,descripcion")] documento documento)
 {
     if (ModelState.IsValid)
     {
         db.Entry(documento).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(documento));
 }
Exemplo n.º 22
0
        //
        // GET: /Documento/Details/5

        public ActionResult Details(int id)
        {
            documento documento = db.documento.Find(id);

            if (documento == null)
            {
                return(HttpNotFound());
            }
            return(View(documento));
        }
Exemplo n.º 23
0
        public ActionResult VerDocumentos(int?id, int?idCurso, int?unidad, int?capitulo)
        {
            if (Session["usuario"] != null)
            {
                usuario usuarioSesion = (usuario)HttpContext.Session["usuario"];
                if (usuarioSesion.roles.FirstOrDefault().rol.Equals(Constantes.ADMINISTRADOR))
                {
                    if (id == null)
                    {
                        return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                    }
                    DocumentosCurso         documentosCurso = new DocumentosCurso();
                    curso                   curso           = db.cursos.Find(idCurso);
                    ICollection <documento> documentos      = db.niveles.Find(id).documentos;
                    if (curso == null || documentos == null)
                    {
                        return(HttpNotFound());
                    }
                    documentosCurso.curso = curso;
                    for (int i = 0; i < documentos.Count; i++)
                    {
                        documento documento = documentos.ElementAt(i);
                        foreach (var documentoCurso in curso.documentos_curso)
                        {
                            if (documento.id == documentoCurso.id_documento)
                            {
                                documentos.Remove(documento);
                                i--;
                            }
                        }
                    }

                    if (unidad != null)
                    {
                        documentos = documentos.Where(d => d.unidad == unidad).ToList();
                    }
                    if (capitulo != null)
                    {
                        documentos = documentos.Where(d => d.capitulo == capitulo).ToList();
                    }
                    documentosCurso.documentos             = documentos;
                    documentosCurso.unidad                 = unidad.GetValueOrDefault();
                    documentosCurso.capitulo               = capitulo.GetValueOrDefault();
                    documentosCurso.curso.contador_visitas = id;
                    ViewBag.docsSeleccionados              = curso.documentos_curso.Where(dc => dc.documento.niveles.Where(n => n.id == id).ToList().Count > 0);
                    ViewBag.unidades = db.unidades;
                    return(View(documentosCurso));
                }
                else
                {
                    return(RedirectToAction("../"));
                }
            }
            return(RedirectToAction("../Account/Login/ReturnUrl=cursos"));
        }
Exemplo n.º 24
0
 public string insert_documento(documento obj)
 {
     if (obj_documento.insert_documento(obj))
     {
         return("I200");
     }
     else
     {
         return("I500");
     }
 }
Exemplo n.º 25
0
 public string update_documento(documento obj)
 {
     if (obj_documento.update_documento(obj))
     {
         return("U200");
     }
     else
     {
         return("U500");
     }
 }
        public ActionResult Create([Bind(Include = "idDocumento,descripcion")] documento documento)
        {
            if (ModelState.IsValid)
            {
                db.documento.Add(documento);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(documento));
        }
 public ActionResult Edit([Bind(Include = "id_documento,id_obra,id_tipo_documento,numero,dta_documento,sin_ativo,endereco_arquivo,extensao_arquivo,nome_arquivo")] documento documento)
 {
     if (ModelState.IsValid)
     {
         db.Entry(documento).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.id_obra           = new SelectList(db.obra, "id_obra", "cod_obra", documento.id_obra);
     ViewBag.id_tipo_documento = new SelectList(db.tipo_documento, "id_tipo_documento", "nome", documento.id_tipo_documento);
     return(View(documento));
 }
Exemplo n.º 28
0
        public async Task <ActionResult> Edit([Bind(Include = "id,descripcion,fechacreacion,mime,nombre,extension,tamano,creado,expedienteIid")] documento documento)
        {
            if (ModelState.IsValid)
            {
                db.Entry(documento).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.expedienteIid = new SelectList(db.expediente, "id", "titulo", documento.expedienteIid);
            return(View(documento));
        }
Exemplo n.º 29
0
 public ActionResult List(documento entity, String message)
 {
     ViewData["message"] = message;
     if (string.IsNullOrEmpty(entity.nome_documento) && (entity.fk_id_juri.Equals(0)))
     {
         return(View(DocumentoRepository.GetAll()));
     }
     else
     {
         return(View(DocumentoRepository.GetAllByCriteria(entity.nome_documento, entity.fk_id_juri)));
     }
 }
Exemplo n.º 30
0
 public ActionResult Edit(documento documento)
 {
     if (ModelState.IsValid)
     {
         db.Entry(documento).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("../telefone/edit", new { id = documento.IdPessoa }));
     }
     ViewBag.IdPessoa        = new SelectList(db.pessoa, "IdPessoa", "Nome", documento.IdPessoa);
     ViewBag.IdTipoDocumento = new SelectList(db.tipodocumento, "IdTipoDocumento", "Descricao", documento.IdTipoDocumento);
     return(View(documento));
 }
Exemplo n.º 31
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            if (File.Exists(this.FilePath))
            {
                var node = this.treeFolders.SelectedNode;
                if (node != null)
                {
                    if (node.Level > 0)
                    {
                        this.buttonSave.Enabled = false;

                        Thread t = new Thread(() =>
                        {
                            String name = this.boxName.Text.TrimStart().TrimEnd();

                            if (!String.IsNullOrEmpty(name))
                            {
                                String obs = this.boxObs.Text.TrimStart().TrimEnd();
                                area @area = (area)this.treeFolders.Nodes[0].Tag;

                                if (@area != null)
                                {
                                    bool sucess = false;
                                    Int64 groupId = 0;
                                    Int64 subId = 0;

                                    if (node.Level == 1)
                                    {
                                        group tag = (group)node.Tag;

                                        if (tag != null)
                                        {
                                            groupId = tag.id;
                                            sucess = true;
                                        }
                                    }
                                    else
                                    {
                                        subGroup tag = (subGroup)node.Tag;

                                        if (tag != null)
                                        {
                                            groupId = tag.idGroup;
                                            subId = tag.id;
                                            sucess = true;
                                        }
                                    }

                                    if (sucess)
                                    {
                                        //build document
                                        documento doc = new documento();
                                        doc.active = true;
                                        doc.areaid = @area.id;
                                        doc.format = Path.GetExtension(this.FilePath);
                                        doc.grupoid = groupId;
                                        doc.idacc = Addin.CurrentAccount.id;
                                        doc.name = name;
                                        doc.observacao = obs;
                                        doc.pages = 1;
                                        doc.subid = subId;

                                        Cloud cloud = new Cloud();
                                        cloud.UploadFile(this.FilePath, doc, this);
                                    }
                                    else
                                    {
                                        MessageBox.Show("Não foi possível salvar o documento.");
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Não foi possível salvar o documento.");
                                }
                            }

                            else
                            {
                                MessageBox.Show("Digite um nome para o documento");
                            }

                            this.Invoke((MethodInvoker)(() => this.buttonSave.Enabled = true));                            
                        });

                        t.Start();                        
                    }
                    else
                    {
                        MessageBox.Show("Selecione uma pasta para salvar o documento");
                    }
                }
            }
            else
            {
                MessageBox.Show("Não foi possível enviar. O arquivo não existe.");
            }            
        }
Exemplo n.º 32
0
        private void buttonSend_Click(object sender, EventArgs e)
        {
            String dir = Convert.ToString(this.buttonChoiceFile.Tag);
            String name = Path.GetFileNameWithoutExtension(this.buttonChoiceFile.Text);
            String ext = Path.GetExtension(this.buttonChoiceFile.Text);

            if(File.Exists(dir))
            {
                this.buttonSend.Enabled = false;

                //build document
                documento doc = new documento();
                doc.active = true;
                doc.idacc = Addin.CurrentAccount.id;
                doc.name = name;
                doc.observacao = this.boxObs.Text.TrimStart().TrimEnd();
                doc.pages = 1;
                doc.format = ext;
                doc.areaid = Util.User.CurrentArea.id;

                bool change = false;

                Cloud cloud = new Cloud();

                if(this.Level > 0)
                {
                    if (this.Level == 1)
                    {
                        group tag = (group)this.tag;

                        if (tag != null)
                        {
                            doc.grupoid = tag.id;
                            doc.subid = 0;
                            change = true;
                        }
                    }
                    else
                    {
                        subGroup tag = (subGroup)this.tag;

                        if(tag != null)
                        {
                            doc.grupoid = tag.idGroup;
                            doc.subid = tag.id;
                            change = true;
                        }
                    }
                }

                if(change)
                {
                    cloud.UploadFile(dir, doc, this);
                }
                else
                {
                    MessageBox.Show("Não foi possível enviar o arquivo. Tente novamente");
                }
            }
            else
            {
                MessageBox.Show("Não foi possível enviar. O arquivo não existe.");
            }
        }
Exemplo n.º 33
0
        public Decimal guardarTraslado(Decimal id_bodega_origen,
            List<int> lista_productos,
            List<int> lista_Cantidades,
            List<int> lista_lotes,
            Decimal id_bodega_destino,
            String Observaciones,
            List<String> talla,
            List<EquipoTraslado> listaEquiposTraslado)
        {
            int cantidadRegistrosActualizados = 0;
            int ConteLo;

            DateTime fecha = System.DateTime.Today;
            Decimal idInventario = 0;
            Decimal idDOC = 0;

            Boolean correcto = true;

            Conexion conexion = new Conexion(Empresa);
            conexion.IniciarTransaccion();

            try
            {
                lote _lote = new lote(Empresa, Usuario);

                documento _doc = new documento(Empresa, Usuario);
                idDOC = _doc.AdicionarAlmDocumentos(0, 0, "TRASLADO", "", "", fecha, new DateTime(), Convert.ToInt32(id_bodega_destino), 0, 0, "ELABORADO", Observaciones, conexion, 0, null);

                if (idDOC == 0)
                {
                    conexion.DeshacerTransaccion();
                    correcto = false;
                    MensajeError = _doc.MensajeError;
                }
                else
                {
                    for (int i = 0; i < lista_productos.Count; i++)
                    {
                        _lote.MensajeError = null;
                        DataTable tablalo = _lote.ObtenerAlmLotePorId(lista_lotes[i], conexion);

                        if (_lote.MensajeError != null)
                        {
                            conexion.DeshacerTransaccion();
                            correcto = false;
                            break;
                        }
                        else
                        {
                            DataRow filalo = tablalo.Rows[0];
                            ConteLo = Convert.ToInt32(filalo["ENTRADAS"]) - Convert.ToInt32(filalo["SALIDAS"]);

                            if (lista_Cantidades[i] <= ConteLo)
                            {
                                idInventario = AdicionarAlmInventario(Convert.ToInt32(idDOC), lista_productos[i], Convert.ToInt32(id_bodega_origen), lista_Cantidades[i], Convert.ToDecimal(filalo["COSTO"]), fecha, "SALIDA", conexion, lista_lotes[i], talla[i], 0, 0, null, filalo["REEMBOLSO"].ToString());

                                if (idInventario == 0)
                                {
                                    conexion.DeshacerTransaccion();
                                    MensajeError += "ADVERTENCIA: El registro de inventario no pudo ser creado. Valide Por favor.";
                                    correcto = false;
                                    break;
                                }
                                else
                                {
                                    String activo = "S";
                                    if (ConteLo - lista_Cantidades[i] <= 0)
                                    {
                                        activo = "N";
                                    }

                                    if (_lote.ActualizarAlmLote(lista_lotes[i], Convert.ToInt32(filalo["ID_DOCUMENTO"]), lista_productos[i], Convert.ToInt32(id_bodega_origen), Convert.ToDateTime(filalo["FECHA_REGISTRO"]), Convert.ToInt32(filalo["ENTRADAS"]), Convert.ToInt32(filalo["SALIDAS"]) + lista_Cantidades[i], Convert.ToDecimal(filalo["COSTO"]), filalo["TALLA"].ToString(), activo, conexion) == false)
                                    {
                                        conexion.DeshacerTransaccion();
                                        correcto = false;
                                        MensajeError += "ADVERTENCIA: El registro del lote no pudo ser actualizado. Verifique Por Favor";
                                        break;
                                    }
                                    else
                                    {
                                        cantidadRegistrosActualizados++;
                                    }
                                }
                            }
                            else
                            {
                                conexion.DeshacerTransaccion();
                                correcto = false;
                                MensajeError += "ADVERTENCIA: La cantidad de producto (" + lista_productos[i].ToString() + ") solicitada no puede ser sacada del lote (" + lista_lotes[i].ToString() + ") seleccionado, cambie la cantidad o haga varios registros con cantidades posibles.";
                                break;
                            }
                        }
                    }

                    foreach (EquipoTraslado equipo in listaEquiposTraslado)
                    {
                        _lote.MensajeError = null;
                        DataTable tablalo = _lote.ObtenerAlmLotePorId(Convert.ToInt32(equipo.ID_LOTE), conexion);

                        if (_lote.MensajeError != null)
                        {
                            conexion.DeshacerTransaccion();
                            correcto = false;
                            break;
                        }
                        else
                        {
                            DataRow filalo = tablalo.Rows[0];
                            ConteLo = Convert.ToInt32(filalo["ENTRADAS"]) - Convert.ToInt32(filalo["SALIDAS"]);

                            if (1 <= ConteLo)
                            {
                                idInventario = AdicionarAlmInventario(Convert.ToInt32(idDOC), Convert.ToInt32(equipo.ID_PRODUCTO), Convert.ToInt32(id_bodega_origen), 1, Convert.ToDecimal(filalo["COSTO"]), fecha, "SALIDA", conexion, Convert.ToInt32(equipo.ID_LOTE), filalo["TALLA"].ToString(), Convert.ToInt32(equipo.ID_EQUIPO), 0, null, filalo["REEMBOLSO"].ToString());

                                if (idInventario == 0)
                                {
                                    conexion.DeshacerTransaccion();
                                    MensajeError += "ADVERTENCIA: El registro de inventario no pudo ser creado. Valide Por favor.";
                                    correcto = false;
                                    break;
                                }
                                else
                                {
                                    String activo = "S";
                                    if (ConteLo - 1 <= 0)
                                    {
                                        activo = "N";
                                    }

                                    if (_lote.ActualizarAlmLote(Convert.ToInt32(equipo.ID_LOTE), Convert.ToInt32(filalo["ID_DOCUMENTO"]), Convert.ToInt32(equipo.ID_PRODUCTO), Convert.ToInt32(filalo["ID_BODEGA"]), Convert.ToDateTime(filalo["FECHA_REGISTRO"]), Convert.ToInt32(filalo["ENTRADAS"]), Convert.ToInt32(filalo["SALIDAS"]) + 1, Convert.ToDecimal(filalo["COSTO"]), filalo["TALLA"].ToString(), activo, conexion) == false)
                                    {
                                        conexion.DeshacerTransaccion();
                                        correcto = false;
                                        MensajeError += "ADVERTENCIA: El registro del lote no pudo ser actualizado. Verifique Por Favor";
                                        break;
                                    }
                                    else
                                    {
                                        _lote.MensajeError = null;
                                        if (_lote.ActualizarLoteActualDeUnEquipo(equipo.ID_EQUIPO, 0, 0, conexion) == false)
                                        {
                                            conexion.DeshacerTransaccion();
                                            correcto = false;
                                            MensajeError = _lote.MensajeError;
                                            break;
                                        }
                                        else
                                        {
                                            cantidadRegistrosActualizados++;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                conexion.DeshacerTransaccion();
                                correcto = false;
                                MensajeError += "ADVERTENCIA: La cantidad de (equipo(s)) solicitada no puede ser sacada del lote (" + equipo.ID_LOTE.ToString() + ") seleccionado, cambie la cantidad o haga varios registros con cantidades posibles.";
                                break;
                            }
                        }
                    }
                }

                if (correcto == true)
                {
                    conexion.AceptarTransaccion();
                }
            }
            catch (Exception ex)
            {
                conexion.DeshacerTransaccion();
                correcto = false;
                MensajeError = ex.Message;
            }
            finally
            {
                conexion.Desconectar();
            }

            if (correcto == true)
            {
                return idDOC;
            }
            else
            {
                return 0;
            }
        }
Exemplo n.º 34
0
        public Boolean guardarTrasladoIngreso(int idDocumento,
            List<int> listaProductos,
            int idbodegaDest,
            List<int> listacantidad,
            List<int> listalote,
            List<String> listaTallas,
            int falta,
            List<EquipoTraslado> listaEquiposTraslado)
        {
            int transaccion = 0;
            Boolean retorno = true;
            Decimal idLote = 0;
            String estado;
            Decimal id_inventario = 0;

            Conexion conexion = new Conexion(Empresa);
            conexion.IniciarTransaccion();

            lote _lote = new lote(Empresa, Usuario);

            try
            {
                for (int i = 0; i < listaProductos.Count; i++)
                {
                    _lote.MensajeError = null;
                    DataTable tablalote = _lote.ObtenerAlmLotePorId(listalote[i], conexion);

                    if (_lote.MensajeError != null)
                    {
                        retorno = false;
                        MensajeError = _lote.MensajeError;
                        conexion.DeshacerTransaccion();
                        break;
                    }
                    else
                    {
                        DataRow filalote = tablalote.Rows[0];
                        Decimal costo = Convert.ToDecimal(filalote["COSTO"]);
                        DateTime fecha = System.DateTime.Today;

                        idLote = _lote.AdicionarAlmLote(Convert.ToInt32(filalote["ID_DOCUMENTO"]), listaProductos[i], idbodegaDest, fecha, listacantidad[i], 0, costo, listaTallas[i], "S", conexion, filalote["REEMBOLSO"].ToString());
                        if (idLote <= 0)
                        {
                            retorno = false;
                            conexion.DeshacerTransaccion();
                            MensajeError += "No fue posible crear el lote por: " + _lote.MensajeError;
                            break;
                        }
                        else
                        {
                            id_inventario = AdicionarAlmInventario(idDocumento, listaProductos[i], idbodegaDest, listacantidad[i], costo, fecha, "ENTRADA", conexion, Convert.ToInt32(idLote), listaTallas[i], 0, 0, null, filalote["REEMBOLSO"].ToString());

                            if (id_inventario <= 0)
                            {
                                retorno = false;
                                conexion.DeshacerTransaccion();
                                break;
                            }
                            else
                            {
                                transaccion++;
                            }
                        }
                    }
                }

                if (retorno == true)
                {
                    foreach (EquipoTraslado equipo in listaEquiposTraslado)
                    {
                        _lote.MensajeError = null;
                        DataTable tablalote = _lote.ObtenerAlmLotePorId(Convert.ToInt32(equipo.ID_LOTE), conexion);

                        if (_lote.MensajeError != null)
                        {
                            retorno = false;
                            MensajeError = _lote.MensajeError;
                            conexion.DeshacerTransaccion();
                            break;
                        }
                        else
                        {
                            DataRow filalote = tablalote.Rows[0];
                            Decimal costo = Convert.ToDecimal(filalote["COSTO"]);
                            DateTime fecha = System.DateTime.Today;

                            idLote = _lote.AdicionarAlmLote(Convert.ToInt32(filalote["ID_DOCUMENTO"]), Convert.ToInt32(equipo.ID_PRODUCTO), idbodegaDest, fecha, 1, 0, costo, filalote["TALLA"].ToString(), "S", conexion, filalote["REEMBOLSO"].ToString());
                            if (idLote <= 0)
                            {
                                retorno = false;
                                conexion.DeshacerTransaccion();
                                MensajeError += "No fue posible crear el lote por: " + _lote.MensajeError;
                                break;
                            }
                            else
                            {
                                id_inventario = AdicionarAlmInventario(idDocumento, Convert.ToInt32(equipo.ID_PRODUCTO), idbodegaDest, 1, costo, fecha, "ENTRADA", conexion, Convert.ToInt32(idLote), filalote["TALLA"].ToString(), Convert.ToInt32(equipo.ID_EQUIPO), 0, null, filalote["REEMBOLSO"].ToString());

                                if (id_inventario <= 0)
                                {
                                    retorno = false;
                                    conexion.DeshacerTransaccion();
                                    break;
                                }
                                else
                                {
                                    if (_lote.ActualizarLoteActualDeUnEquipo(equipo.ID_EQUIPO, idLote, Convert.ToDecimal(idDocumento), conexion) == false)
                                    {
                                        retorno = false;
                                        conexion.DeshacerTransaccion();
                                        MensajeError = _lote.MensajeError;
                                        break;
                                    }
                                    else
                                    {
                                        transaccion++;
                                    }
                                }
                            }
                        }
                    }
                }

                if (retorno == true)
                {
                    if (falta > 0)
                    {
                        estado = "RECIBIDO";
                    }
                    else
                    {
                        estado = "COMPLETO";
                    }

                    if (transaccion == (listaProductos.Count + listaEquiposTraslado.Count))
                    {
                        documento _doc = new documento(Empresa, Usuario);
                        DataTable tablaDoc = _doc.ObtenerAlmRegDocumentoPorId(idDocumento);
                        DataRow filaDoc = tablaDoc.Rows[0];

                        if (_doc.ActualizarAlmDocumento(idDocumento, 0, 0, "TRASLADO", "", "", Convert.ToDateTime(filaDoc["FECHA_DOCUMENTO"]), new DateTime(), idbodegaDest, 0, 0, estado, filaDoc["OBSERVACION_JUSTIFICACION"].ToString(), 0, conexion) == false)
                        {
                            retorno = false;
                            MensajeError = _doc.MensajeError;
                            conexion.DeshacerTransaccion();
                        }
                    }
                    else
                    {
                        MensajeError = "la transaccion arrojó un resultado inconcistente en cuanto a los productos que se tenian que procesar.";
                        retorno = false;
                        conexion.DeshacerTransaccion();
                    }
                }

                if (retorno == true)
                {
                    conexion.AceptarTransaccion();
                }
            }
            catch (Exception ex)
            {
                retorno = false;
                conexion.DeshacerTransaccion();
                MensajeError = ex.Message;
            }
            finally
            {
                conexion.Desconectar();
            }

            return retorno;
        }
Exemplo n.º 35
0
        public Decimal guardarAjuste(String tipo,
            String idRegional,
            String idCiudad,
            int idEmpresa,
            int idProducto,
            String talla,
            int idLote,
            int CantidadMod,
            Decimal costo,
            String Motivo,
            Decimal idDocTemp,
            List<EquipoAjuste> listaEquiposAjuste,
            String NOMBRE_SERVICIO_COMPLEMENTARIO,
            String OBS_AUTORIZACION)
        {
            Decimal idDoc = 0;
            DateTime fecha;
            Decimal idInventario = 0;

            Boolean correcto = true;

            fecha = System.DateTime.Today;

            Conexion _dato = new Conexion(Empresa);
            _dato.IniciarTransaccion();

            try
            {
                documento _doc = new documento(Empresa, Usuario);
                idDoc = _doc.AdicionarAlmDocumentos(0, Convert.ToInt32(idDocTemp), "AJUSTE", "", "", fecha, new DateTime(), 0, 0, 0, "APROBADO", Motivo, _dato, 0, OBS_AUTORIZACION);

                if (idDoc <= 0)
                {
                    _dato.DeshacerTransaccion();
                    correcto = false;
                    MensajeError = _doc.MensajeError;
                }
                else
                {
                    bodega _bodega = new bodega(Empresa, Usuario);
                    DataTable tablaBodega = _bodega.ObtenerAlmRegBodegaPorIds(idRegional, idCiudad, idEmpresa, _dato);

                    if (_bodega.MensajeError != null)
                    {
                        _dato.DeshacerTransaccion();
                        correcto = false;
                        MensajeError = _bodega.MensajeError;
                    }
                    else
                    {
                        DataRow filaBodega = tablaBodega.Rows[0];

                        lote _lote = new lote(Empresa, Usuario);
                        DataTable tablaLote = _lote.ObtenerAlmLotePorId(idLote, _dato);

                        if (_lote.MensajeError != null)
                        {
                            _dato.DeshacerTransaccion();
                            correcto = false;
                            MensajeError = _bodega.MensajeError;
                        }
                        else
                        {

                            DataRow filalote = tablaLote.Rows[0];

                            if (tipo.Equals("COSTO"))
                            {
                                idInventario = AdicionarAlmInventario(Convert.ToInt32(idDoc), idProducto, Convert.ToInt32(filaBodega["ID_BODEGA"]), 0, costo, fecha, "COSTO", _dato, idLote, talla, 0, 0, null, filalote["REEMBOLSO"].ToString());
                                if (idInventario <= 0)
                                {
                                    _dato.DeshacerTransaccion();
                                    correcto = false;
                                }
                                else
                                {
                                    if (_lote.ActualizarAlmLote(idLote, Convert.ToInt32(filalote["ID_DOCUMENTO"]), idProducto, Convert.ToInt32(filalote["ID_BODEGA"]), Convert.ToDateTime(filalote["FECHA_REGISTRO"]), Convert.ToInt32(filalote["ENTRADAS"]), Convert.ToInt32(filalote["SALIDAS"]), costo, filalote["TALLA"].ToString(), filalote["ACTIVO"].ToString(), _dato) == false)
                                    {
                                        _dato.DeshacerTransaccion();
                                        correcto = false;
                                        MensajeError = _lote.MensajeError;
                                    }
                                }
                            }
                            else if (tipo.Equals("ENTRADA"))
                            {
                                int contenido = 0;
                                int entradas = 0;
                                int salidas = 0;

                                if (NOMBRE_SERVICIO_COMPLEMENTARIO != "EQUIPOS")
                                {
                                    entradas = Convert.ToInt32(filalote["ENTRADAS"]) + CantidadMod;
                                    salidas = Convert.ToInt32(filalote["SALIDAS"]);

                                    contenido = entradas - salidas;

                                    String activo = "S";
                                    if (contenido <= 0)
                                    {
                                        activo = "N";
                                    }

                                    idInventario = AdicionarAlmInventario(Convert.ToInt32(idDoc), idProducto, Convert.ToInt32(filaBodega["ID_BODEGA"]), CantidadMod, Convert.ToDecimal(filalote["COSTO"]), fecha, "ENTRADA", _dato, idLote, filalote["TALLA"].ToString(), 0, 0, null, filalote["REEMBOLSO"].ToString());

                                    if (idInventario <= 0)
                                    {
                                        _dato.DeshacerTransaccion();
                                        correcto = false;
                                    }
                                    else
                                    {
                                        if (_lote.ActualizarAlmLote(idLote, Convert.ToInt32(filalote["ID_DOCUMENTO"]), idProducto, Convert.ToInt32(filalote["ID_BODEGA"]), Convert.ToDateTime(filalote["FECHA_REGISTRO"]), entradas, salidas, Convert.ToDecimal(filalote["COSTO"]), filalote["TALLA"].ToString(), activo, _dato) == false)
                                        {
                                            _dato.DeshacerTransaccion();
                                            correcto = false;
                                            MensajeError += _lote.MensajeError;
                                        }
                                    }
                                }
                                else
                                {
                                    producto _prod = new producto(Empresa, Usuario);

                                    entradas = Convert.ToInt32(filalote["ENTRADAS"]);
                                    salidas = Convert.ToInt32(filalote["SALIDAS"]);

                                    foreach (EquipoAjuste equipo in listaEquiposAjuste)
                                    {
                                        Decimal ID_NUEVO_EQUIPO = _prod.AdicionarAlmEquipo(Convert.ToInt32(equipo.ID_DOCUMENTO), equipo.MARCA, equipo.MODELO, equipo.SERIE, equipo.IMEI, equipo.NUMERO_CELULAR, "S", fecha, Convert.ToDecimal(idLote), _dato);

                                        if (ID_NUEVO_EQUIPO <= 0)
                                        {
                                            _dato.DeshacerTransaccion();
                                            correcto = false;
                                            MensajeError += _lote.MensajeError;
                                            break;
                                        }
                                        else
                                        {
                                            entradas += 1;
                                            contenido = entradas - salidas;

                                            String activo = "S";
                                            if (contenido <= 0)
                                            {
                                                activo = "N";
                                            }

                                            idInventario = AdicionarAlmInventario(Convert.ToInt32(idDoc), idProducto, Convert.ToInt32(filaBodega["ID_BODEGA"]), 1, Convert.ToDecimal(filalote["COSTO"]), fecha, "ENTRADA", _dato, idLote, filalote["TALLA"].ToString(), Convert.ToInt32(ID_NUEVO_EQUIPO), 0, null, filalote["REEMBOLSO"].ToString());

                                            if (idInventario <= 0)
                                            {
                                                _dato.DeshacerTransaccion();
                                                correcto = false;
                                                break;
                                            }
                                            else
                                            {
                                                if (_lote.ActualizarAlmLote(idLote, Convert.ToInt32(filalote["ID_DOCUMENTO"]), idProducto, Convert.ToInt32(filalote["ID_BODEGA"]), Convert.ToDateTime(filalote["FECHA_REGISTRO"]), entradas, salidas, Convert.ToDecimal(filalote["COSTO"]), filalote["TALLA"].ToString(), activo, _dato) == false)
                                                {
                                                    _dato.DeshacerTransaccion();
                                                    correcto = false;
                                                    MensajeError += _lote.MensajeError;
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                int contenido = 0;
                                int entradas = 0;
                                int salidas = 0;

                                if (NOMBRE_SERVICIO_COMPLEMENTARIO != "EQUIPOS")
                                {
                                    entradas = Convert.ToInt32(filalote["ENTRADAS"]);
                                    salidas = Convert.ToInt32(filalote["SALIDAS"]) + CantidadMod;

                                    contenido = entradas - salidas;

                                    String activo = "S";
                                    if (contenido <= 0)
                                    {
                                        activo = "N";
                                    }

                                    idInventario = AdicionarAlmInventario(Convert.ToInt32(idDoc), idProducto, Convert.ToInt32(filaBodega["ID_BODEGA"]), CantidadMod, Convert.ToDecimal(filalote["COSTO"]), fecha, "SALIDA", _dato, idLote, filalote["TALLA"].ToString(), 0, 0, null, filalote["REEMBOLSO"].ToString());

                                    if (idInventario <= 0)
                                    {
                                        _dato.DeshacerTransaccion();
                                        correcto = false;
                                    }
                                    else
                                    {
                                        if (_lote.ActualizarAlmLote(idLote, Convert.ToInt32(filalote["ID_DOCUMENTO"]), idProducto, Convert.ToInt32(filalote["ID_BODEGA"]), Convert.ToDateTime(filalote["FECHA_REGISTRO"]), entradas, salidas, Convert.ToDecimal(filalote["COSTO"]), filalote["TALLA"].ToString(), activo, _dato) == false)
                                        {
                                            _dato.DeshacerTransaccion();
                                            correcto = false;
                                            MensajeError += _lote.MensajeError;
                                        }
                                    }
                                }
                                else
                                {
                                    producto _prod = new producto(Empresa, Usuario);

                                    entradas = Convert.ToInt32(filalote["ENTRADAS"]);
                                    salidas = Convert.ToInt32(filalote["SALIDAS"]);

                                    foreach (EquipoAjuste equipo in listaEquiposAjuste)
                                    {
                                        if (_prod.ActualizarAlmEquipoIdLoteActualIDocumentoActualParaSalida(equipo.ID_EQUIPO, "N", 0, 0, _dato) == false)
                                        {
                                            _dato.DeshacerTransaccion();
                                            correcto = false;
                                            MensajeError += _prod.MensajeError;
                                            break;
                                        }
                                        else
                                        {
                                            salidas += 1;

                                            contenido = entradas - salidas;

                                            String activo = "S";
                                            if (contenido <= 0)
                                            {
                                                activo = "N";
                                            }

                                            idInventario = AdicionarAlmInventario(Convert.ToInt32(idDoc), idProducto, Convert.ToInt32(filaBodega["ID_BODEGA"]), 1, Convert.ToDecimal(filalote["COSTO"]), fecha, "SALIDA", _dato, idLote, filalote["TALLA"].ToString(), Convert.ToInt32(equipo.ID_EQUIPO), 0, null, filalote["REEMBOLSO"].ToString());

                                            if (idInventario <= 0)
                                            {
                                                _dato.DeshacerTransaccion();
                                                correcto = false;
                                                break;
                                            }
                                            else
                                            {
                                                if (_lote.ActualizarAlmLote(idLote, Convert.ToInt32(filalote["ID_DOCUMENTO"]), idProducto, Convert.ToInt32(filalote["ID_BODEGA"]), Convert.ToDateTime(filalote["FECHA_REGISTRO"]), entradas, salidas, Convert.ToDecimal(filalote["COSTO"]), filalote["TALLA"].ToString(), activo, _dato) == false)
                                                {
                                                    _dato.DeshacerTransaccion();
                                                    correcto = false;
                                                    MensajeError += _lote.MensajeError;
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                if (correcto == true)
                {
                    documento_temp _docTemp = new documento_temp(Empresa, Usuario);
                    if (_docTemp.ActualizarAlmDocumentoTemp(Convert.ToInt32(idDocTemp), Convert.ToDateTime(DateTime.Now.ToShortDateString()), "APROBADO", _dato, OBS_AUTORIZACION) == false)
                    {
                        _dato.DeshacerTransaccion();
                        correcto = false;
                        MensajeError = _docTemp.MensajeError;
                    }
                }

                if (correcto == true)
                {
                    _dato.AceptarTransaccion();
                }
            }
            catch (Exception ex)
            {
                _dato.DeshacerTransaccion();
                correcto = false;
                MensajeError = ex.Message;
            }
            finally
            {
                _dato.Desconectar();
            }

            if (correcto == true)
            {
                return idDoc;
            }
            else
            {
                return 0;
            }
        }
Exemplo n.º 36
0
        public Decimal guardarAjusteEquipo(String tipo, String idRegional, String idCiudad, int idEmpresa, int idProducto, int idEquipo, String talla, int idLote, int CantidadMod, Decimal costo, String Motivo)
        {
            Decimal idDoc = 0;
            DateTime fecha;
            Decimal idInventario = 0;

            fecha = System.DateTime.Today;
            Conexion _dato = new Conexion(Empresa);
            _dato.IniciarTransaccion();

            documento _doc = new documento(Empresa, Usuario);
            idDoc = _doc.AdicionarAlmDocumentos(0, 0, "AJUSTE", "", "", fecha, new DateTime(), 0, 0, 0, "", Motivo, _dato, 0, null);
            if (idDoc != 0)
            {
                bodega _bodega = new bodega(Empresa, Usuario);
                DataTable tablaBodega = _bodega.ObtenerAlmRegBodegaPorIds(idRegional, idCiudad, idEmpresa);
                DataRow filaBodega = tablaBodega.Rows[0];

                lote _lote = new lote(Empresa, Usuario);
                DataTable tablaLote = _lote.ObtenerAlmLotePorId(idLote, _dato);
                DataRow filalote = tablaLote.Rows[0];
                if (tipo.Equals("COSTO"))
                {
                    idInventario = AdicionarAlmInventario(Convert.ToInt32(idDoc), idProducto, Convert.ToInt32(filaBodega["ID_BODEGA"].ToString()), 0, costo, fecha, "MODIFICACION", _dato, idLote, talla, idEquipo, 0, null, filalote["REEMBOLSO"].ToString());
                    if (idInventario == 0)
                    {
                        _dato.DeshacerTransaccion();

                    }
                    else
                    {
                        if (_lote.ActualizarAlmLote(idLote, Convert.ToInt32(idDoc), idProducto, Convert.ToInt32(filalote["ID_BODEGA"].ToString()), Convert.ToDateTime(filalote["FECHA_REGISTRO"]), Convert.ToInt32(filalote["ENTRADAS"]), Convert.ToInt32(filalote["SALIDAS"]), costo, talla, "S", _dato))
                        {
                            _dato.AceptarTransaccion();
                        }
                        else
                        {
                            _dato.DeshacerTransaccion();
                            MensajeError += _lote.MensajeError;
                        }
                    }
                }
                else if (tipo.Equals("ENTRADA"))
                {
                    int contenido;
                    contenido = Convert.ToInt32(filalote["ENTRADAS"].ToString()) - Convert.ToInt32(filalote["SALIDAS"].ToString());
                    contenido = CantidadMod - contenido;

                    idInventario = AdicionarAlmInventario(Convert.ToInt32(idDoc), idProducto, Convert.ToInt32(filaBodega["ID_BODEGA"].ToString()), contenido, 0, fecha, "ENTRADA", _dato, idLote, talla, idEquipo, 0, null, filalote["REEMBOLSO"].ToString());

                    if (idInventario == 0)
                    {
                        _dato.DeshacerTransaccion();

                    }
                    else
                    {
                        if (_lote.ActualizarAlmLote(idLote, Convert.ToInt32(idDoc), idProducto, Convert.ToInt32(filalote["ID_BODEGA"].ToString()), Convert.ToDateTime(filalote["FECHA_REGISTRO"]), Convert.ToInt32(filalote["ENTRADAS"].ToString()) + contenido, Convert.ToInt32(filalote["SALIDAS"]), Convert.ToDecimal(filalote["COSTO"].ToString()), talla, "S", _dato))
                        {
                            _dato.AceptarTransaccion();
                        }
                        else
                        {
                            _dato.DeshacerTransaccion();
                            idDoc = 0;
                            MensajeError += _lote.MensajeError;
                        }
                    }
                }
                else
                {
                    int contenido;
                    contenido = Convert.ToInt32(filalote["ENTRADAS"].ToString()) - Convert.ToInt32(filalote["SALIDAS"].ToString());
                    contenido = contenido - CantidadMod;

                    idInventario = AdicionarAlmInventario(Convert.ToInt32(idDoc), idProducto, Convert.ToInt32(filaBodega["ID_BODEGA"].ToString()), contenido, 0, fecha, "SALIDA", _dato, idLote, talla, idEquipo, 0, null, filalote["REEMBOLSO"].ToString());
                    if (idInventario == 0)
                    {
                        _dato.DeshacerTransaccion();
                        idDoc = 0;

                    }
                    else
                    {
                        if (_lote.ActualizarAlmLote(idLote, Convert.ToInt32(idDoc), idProducto, Convert.ToInt32(filalote["ID_BODEGA"].ToString()), Convert.ToDateTime(filalote["FECHA_REGISTRO"]), Convert.ToInt32(filalote["ENTRADAS"].ToString()), Convert.ToInt32(filalote["SALIDAS"].ToString()) + contenido, Convert.ToDecimal(filalote["COSTO"]), talla, "S", _dato))
                        {
                            _dato.AceptarTransaccion();
                        }
                        else
                        {
                            _dato.DeshacerTransaccion();
                            idDoc = 0;
                            MensajeError += _lote.MensajeError;
                        }
                    }
                }
            }
            else
            {
                _dato.DeshacerTransaccion();
                MensajeError = _doc.MensajeError;
                idDoc = 0;
            }

            return idDoc;
        }
Exemplo n.º 37
0
        public Decimal guardarDevolucion(List<int> ID_LOTE,
            int ID_BODEGA,
            int ID_EMPLEADO,
            List<int> ID_DOCUMENTO,
            List<int> ID_INVENTARIO,
            List<int> ID_PRODUCTO,
            List<int> cantidad,
            List<String> Estado,
            List<String> motivo,
            List<Decimal> ID_DETALLE_ENTREGAS,
            List<EquipoEntrega> listaEquiposDevueltos)
        {
            Decimal idDocumento = 0;
            Decimal idInventario = 0;
            Decimal idLote = 0;

            DateTime fecha = System.DateTime.Today;
            documento _doc = new documento(Empresa, Usuario);
            Inventario _inventario = new Inventario(Empresa, Usuario);
            Conexion _dato = new Conexion(Empresa);
            lote _lote = new lote(Empresa, Usuario);
            int cuenta = 0;

            Boolean correcto = true;

            _dato.IniciarTransaccion();

            try
            {
                idDocumento = _doc.AdicionarAlmDocumentos(ID_EMPLEADO, 0, "DEVOLUCION", "", "", fecha, new DateTime(), 0, 0, 0, "", "", _dato, 0, null);

                if (idDocumento == 0)
                {
                    correcto = false;
                    MensajeError = _doc.MensajeError;
                    _dato.DeshacerTransaccion();
                }
                else
                {
                    for (int i = 0; i < ID_PRODUCTO.Count; i++)
                    {
                        _lote.MensajeError = null;

                        DataTable tablalote = _lote.ObtenerAlmLotePorId(ID_LOTE[i], _dato);

                        if (_lote.MensajeError != null)
                        {
                            correcto = false;
                            _dato.DeshacerTransaccion();
                            MensajeError = _lote.MensajeError;
                            break;
                        }
                        else
                        {
                            DataRow filalote = tablalote.Rows[0];

                            String activoLote = "S";
                            if (Estado[i] != "BUENO")
                            {
                                activoLote = "N";
                            }

                            idLote = _lote.AdicionarAlmLote(ID_DOCUMENTO[i], ID_PRODUCTO[i], Convert.ToInt32(filalote["ID_BODEGA"]), Convert.ToDateTime(DateTime.Now.ToShortDateString()), cantidad[i], 0, Convert.ToDecimal(filalote["COSTO"]), filalote["TALLA"].ToString().Trim(), activoLote, _dato, filalote["REEMBOLSO"].ToString());

                            if (idLote == 0)
                            {
                                correcto = false;
                                MensajeError = _lote.MensajeError;
                                _dato.DeshacerTransaccion();
                                break;
                            }
                            else
                            {
                                _inventario.MensajeError = null;
                                idInventario = _inventario.AdicionarAlmInventario(Convert.ToInt32(idDocumento), ID_PRODUCTO[i], Convert.ToInt32(filalote["ID_BODEGA"]), cantidad[i], Convert.ToDecimal(filalote["COSTO"]), Convert.ToDateTime(DateTime.Now.ToShortDateString()), "ENTRADA", _dato, Convert.ToInt32(idLote), filalote["TALLA"].ToString(), 0, ID_DETALLE_ENTREGAS[i], motivo[i], filalote["REEMBOLSO"].ToString());

                                if (idInventario <= 0)
                                {
                                    correcto = false;
                                    MensajeError = _inventario.MensajeError;
                                    _dato.DeshacerTransaccion();
                                    break;
                                }
                                else
                                {
                                    cuenta++;
                                }
                            }
                        }
                    }

                    if (correcto == true)
                    {
                        foreach (EquipoEntrega equipo in listaEquiposDevueltos)
                        {
                            _lote.MensajeError = null;

                            DataTable tablalote = _lote.ObtenerAlmLotePorId(Convert.ToInt32(equipo.ID_LOTE), _dato);

                            if (_lote.MensajeError != null)
                            {
                                correcto = false;
                                _dato.DeshacerTransaccion();
                                MensajeError = _lote.MensajeError;
                                break;
                            }
                            else
                            {
                                DataRow filalote = tablalote.Rows[0];

                                String activoLote = "S";
                                if (equipo.ESTADO_DEV != "BUENO")
                                {
                                    activoLote = "N";
                                }

                                idLote = _lote.AdicionarAlmLote(Convert.ToInt32(equipo.ID_DOCUMENTO), Convert.ToInt32(equipo.ID_PRODUCTO), Convert.ToInt32(filalote["ID_BODEGA"]), Convert.ToDateTime(DateTime.Now.ToShortDateString()), 1, 0, Convert.ToDecimal(filalote["COSTO"]), filalote["TALLA"].ToString().Trim(), activoLote, _dato, filalote["REEMBOLSO"].ToString());

                                if (idLote == 0)
                                {
                                    correcto = false;
                                    MensajeError = _lote.MensajeError;
                                    _dato.DeshacerTransaccion();
                                    break;
                                }
                                else
                                {
                                    _inventario.MensajeError = null;
                                    idInventario = _inventario.AdicionarAlmInventario(Convert.ToInt32(idDocumento), Convert.ToInt32(equipo.ID_PRODUCTO), Convert.ToInt32(filalote["ID_BODEGA"]), 1, Convert.ToDecimal(filalote["COSTO"]), Convert.ToDateTime(DateTime.Now.ToShortDateString()), "ENTRADA", _dato, Convert.ToInt32(idLote), filalote["TALLA"].ToString(), Convert.ToInt32(equipo.ID_EQUIPO), equipo.ID_DETALLE_ENTREGAS, equipo.DETALLE_DEV, filalote["REEMBOLSO"].ToString());

                                    if (idInventario <= 0)
                                    {
                                        correcto = false;
                                        MensajeError = _inventario.MensajeError;
                                        _dato.DeshacerTransaccion();
                                        break;
                                    }
                                    else
                                    {
                                        Entrega _entrega = new Entrega(Empresa, Usuario);
                                        if (_entrega.ActualizarAlmEquiposEntregaDevolucion(equipo.ID_EQUIPO_ENTREGA, equipo.ID_EQUIPO, idLote, idDocumento, equipo.ESTADO_DEV, equipo.DETALLE_DEV, _dato) == false)
                                        {
                                            correcto = false;
                                            MensajeError = _entrega.MensajeError;
                                            _dato.DeshacerTransaccion();
                                            break;
                                        }
                                        else
                                        {
                                            cuenta++;
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if (correcto == true)
                    {
                        if (cuenta != (ID_PRODUCTO.Count + listaEquiposDevueltos.Count))
                        {
                            correcto = false;
                            _dato.DeshacerTransaccion();
                            MensajeError = "Ocurrio un error inesperado, el numero de productos y equipos procesados no corresponde.";
                        }
                    }
                }

                if (correcto == true)
                {
                    _dato.AceptarTransaccion();
                }
            }
            catch (Exception ex)
            {
                _dato.DeshacerTransaccion();
                MensajeError = ex.Message;
                correcto = false;
            }
            finally
            {
                _dato.Desconectar();
            }

            if (correcto == true)
            {
                return idDocumento;
            }
            else
            {
                return 0;
            }
        }
Exemplo n.º 38
0
        public static void Assembly(ListView list, documento[] docs, DocumentAssemblyType type, bool clear = true, bool change=true)
        {
            Framework.Forms.MyAccount myAccountForm = Application.OpenForms.OfType<Framework.Forms.MyAccount>().FirstOrDefault();
            if (myAccountForm != null)
            {
                myAccountForm.Invoke((MethodInvoker)(() =>
                {
                    if (clear)
                    {
                        list.Items.Clear();
                    }

                    if (docs == null || docs.Length == 0)
                    {
                        CreateNoResultData(list);
                        return;
                    }

                    list.Columns.Clear();
                    list.Columns.Add("Nome", 400);
                    list.Columns.Add("Observação", 200);

                    if (type == DocumentAssemblyType.Trash)
                    {
                        list.Columns.Add("Data de exclusão", 127);
                    }
                    else
                    {
                        list.Columns.Add("Data de criação", 127);
                    }

                    list.Columns.Add("Tipo", 100)
                        .AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize);

                    foreach (documento doc in docs)
                    {
                        if (!String.IsNullOrEmpty(doc.name))
                        {
                            ListViewItem item = new ListViewItem(doc.name);

                            item.SubItems.Add(doc.observacao.TrimStart().TrimEnd());

                            if (type == DocumentAssemblyType.Trash)
                            {
                                item.SubItems.Add(doc.delete);
                            }
                            else
                            {
                                item.SubItems.Add(doc.criacao);
                            }

                            item.SubItems.Add(doc.format.TrimStart().TrimEnd());

                            item.Tag = doc;
                            item.Name = doc.name;

                            list.Items.Add(item);
                        }
                    }

                    if (change)
                    {
                        Documents = docs;

                        foreach (object menuItem in myAccountForm.filters.DropDownItems)
                        {
                            try
                            {
                                var filter = (ToolStripMenuItem)menuItem;
                                if (filter != null) filter.Checked = false;
                            }
                            catch
                            {
                                continue;
                            }
                        }
                        ((ToolStripMenuItem)myAccountForm.filters.DropDownItems[0]).Checked = true;
                    }

                    LastAssemblyType = type;
                }));
            }
        }
Exemplo n.º 39
0
        public void DownloadFile(documento doc, Forms.MyAccount form)
        {
            Thread t = new Thread(() => {
                if (!String.IsNullOrEmpty(doc.hash))
                {
                    if (String.IsNullOrEmpty(doc.name))
                    {
                        doc.name = "Sem nome";
                    }

                    if (AbcDoc != null)
                    {
                        String oldName = string.Empty;

                        try
                        {
                            //recebe o arquivo do abcdoc
                            oldName = AbcDoc.receberArquivo(doc.hash, Dir.TempDirectory);
                        }
                        catch
                        {
                            oldName = string.Empty;
                        }

                        if (!String.IsNullOrEmpty(oldName))
                        {
                            String newFileName = Util.User.GetDirDownload() + doc.name;
                            String newFileExtension = new FileInfo(oldName).Extension;
                            String newName = newFileName + newFileExtension;

                            if (File.Exists(newName))
                            {
                                //cria um versionamento pro arquivo, pois ele ja existe
                                Int32 count = 1;

                                while (File.Exists(newFileName + "(" + count.ToString() + ")" + newFileExtension))
                                {
                                    count++;
                                }

                                newName = newFileName + "(" + count.ToString() + ")" + newFileExtension;
                            }

                            if (File.Exists(oldName) && !File.Exists(newName))
                            {
                                File.Move(oldName, newName);

                                if (File.Exists(newName))
                                {
                                    if (Addin.CurrentAccount.openDocument)
                                    {
                                        //faz a uniao das extensoes de documentos, planilhas e apresentacoes
                                        var union =
                                            Forms.MyAccount.wextensions
                                            .Concat(Forms.MyAccount.eextensions)
                                            .Concat(Forms.MyAccount.pextensions)
                                            .Concat(Forms.MyAccount.iextensions);

                                        if(union.Any(ext => ext.ToLower().Equals(newFileExtension.ToLower())))
                                        {
                                            Process.Start(newName);
                                        }
                                    }
                                }

                                try
                                {
                                    File.Delete(oldName);
                                }
                                catch
                                {
                                }
                            }
                            else
                            {
                                MessageBox.Show("Não foi possível completar o download. O arquivo é inválido.");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Não foi possível completar o download. Verifique sua conexão com a internet.");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Não foi possível completar o download. Verifique sua conexão com a internet.");
                    }
                }
                else
                {
                    MessageBox.Show("Não foi possível completar o download. O documento selecionado é inválido.");
                }

                form.Invoke((MethodInvoker)(() => form.buttonDownloadDocument.Enabled = true));
            });

            t.Start();
        }
Exemplo n.º 40
0
 public static String GetIdentifier(documento doc)
 {
     return doc.name;
 }
Exemplo n.º 41
0
        public void UploadFile(String dir, documento doc, Form form)
        {
            Thread t = new Thread(() => {
                if(File.Exists(dir))
                {
                    if(doc != null)
                    {
                        if(AbcDoc != null)
                        {
                            if(String.IsNullOrEmpty(doc.name))
                            {
                                doc.name = "Sem nome";
                            }

                            if(AbcDocInfo != null)
                            {
                                String docIdentifier = Util.Document.GetIdentifier(doc);
                                doc.identifier = docIdentifier;
                                String hash = string.Empty;

                                try
                                {
                                    //envia o arquivo pro abcdoc
                                    hash = AbcDoc.enviarArquivo(dir, AbcDocInfo.application, doc.identifier, doc.pages);
                                }
                                catch
                                {
                                    hash = string.Empty;
                                }

                                if(!String.IsNullOrEmpty(hash))
                                {
                                    doc.hash = hash;

                                    if (Tasks.Service.IService != null)
                                    {
                                        newDocumentoResponse response = null;

                                        try
                                        {
                                            //guarda os dados do arquivo no banco de dados
                                            response = Tasks.Service.IService.newDocumento(new newDocumentoRequest(doc, Util.User.GetHashID()));
                                        }
                                        catch
                                        {
                                            response = null;
                                        }

                                        if (response != null)
                                        {
                                            documento docReturned = response.@return;

                                            if (docReturned == null)
                                            {
                                                MessageBox.Show("Não foi possível completar o upload[#7].");
                                            }
                                            else
                                            {
                                                try
                                                {
                                                    form.Invoke((MethodInvoker)(() => form.Close()));
                                                }
                                                catch
                                                { }

                                                //Atualiza a lista de documentos
                                                Forms.MyAccount myAccountForm = Application.OpenForms.OfType<Forms.MyAccount>().FirstOrDefault();
                                                if (myAccountForm != null)
                                                {
                                                    myAccountForm.Invoke((MethodInvoker)(() =>
                                                    {
                                                        if (myAccountForm.treeFolders.SelectedNode != null && myAccountForm.treeFolders.SelectedNode.Level > 0)
                                                        {
                                                            bool add = false;

                                                            if (myAccountForm.treeFolders.SelectedNode.Level == 1)
                                                            {
                                                                group tag = (group)myAccountForm.treeFolders.SelectedNode.Tag;

                                                                if (tag != null)
                                                                {
                                                                    if (docReturned.grupoid == tag.id && docReturned.subid == 0)
                                                                    {
                                                                        add = true;
                                                                    }
                                                                }
                                                            }
                                                            else
                                                            {
                                                                subGroup tag = (subGroup)myAccountForm.treeFolders.SelectedNode.Tag;

                                                                if (tag != null)
                                                                {
                                                                    if (docReturned.grupoid == tag.idGroup && docReturned.subid == tag.id)
                                                                    {
                                                                        add = true;
                                                                    }
                                                                }
                                                            }

                                                            if (add)
                                                            {
                                                                if (myAccountForm.list.Columns.Count > 1)
                                                                {
                                                                    if (!String.IsNullOrEmpty(docReturned.name))
                                                                    {
                                                                        ListViewItem item = new ListViewItem(docReturned.name);
                                                                        item.SubItems.Add(docReturned.observacao.TrimStart().TrimEnd());
                                                                        item.SubItems.Add(docReturned.criacao);
                                                                        item.SubItems.Add(docReturned.format.TrimStart().TrimEnd());
                                                                        item.Tag = docReturned;
                                                                        item.Name = docReturned.name;
                                                                        myAccountForm.list.Items.Add(item);
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    documento[] docs = { docReturned };
                                                                    Util.Document.Assembly(myAccountForm.list, docs, DocumentAssemblyType.Tree, true);
                                                                }
                                                            }
                                                        }
                                                    }));
                                                }
                                            }
                                        }
                                        else
                                        {
                                            MessageBox.Show("Não foi possível completar o upload[#8].");
                                        }
                                    }
                                    else
                                    {
                                        MessageBox.Show("Não foi possível completar o upload[#1]. Verifique sua conexão com a internet.");
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Não foi possível completar o upload[#2]. Verifique sua conexão com a internet.");
                                }
                            }
                            else
                            {
                                MessageBox.Show("Não foi possível completar o upload[#3]. Verifique sua conexão com a internet.");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Não foi possível completar o upload[#4]. Verifique sua conexão com a internet.");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Não foi possível completar o upload[#5]. O documento selecionado é inválido.");
                    }
                }
                else
                {
                    MessageBox.Show("Não foi possível completar o upload[#6]. Arquivo selecionado não existente.");
                }
            });

            t.Start();
        }
Exemplo n.º 42
0
        private async void buttonRestoreDocument_Click(object sender, EventArgs e)
        {
            if (this.list.SelectedItems != null && this.list.SelectedItems.Count > 0 && this.list.Columns.Count > 1)
            {
                if(Util.User.CurrentArea.id == Util.User.TRASH_ID)
                {
                    this.buttonRestoreDocument.Enabled = false;

                    bool restore = false;

                    documento[] docs = new documento[this.list.SelectedItems.Count];

                    for (Int32 i = 0; i < this.list.SelectedItems.Count; i++)
                    {
                        documento tag = (documento)this.list.SelectedItems[i].Tag;

                        docs[i] = tag;

                        setRestaurarDocumentoResponse response = null;

                        try
                        {
                            response = await Service.IService.setRestaurarDocumentoAsync(new setRestaurarDocumentoRequest(tag.id, Util.User.GetHashID()));
                        }
                        catch
                        {
                            response = null;
                        }
                        
                        if(response != null)
                        {
                            bool sucess = response.@return;

                            if(sucess)
                            {
                                restore = true;
                            }
                        }
                    }

                    if(restore)
                    {
                        for (Int32 i = 0; i < this.list.SelectedItems.Count; i++)
                        {
                            this.list.SelectedItems[i].Remove();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Não foi possível restaurar o arquivo");
                    }

                    if (this.list.Items.Count == 0)
                    {
                        this.buttonDownloadDocument.Visible = false;
                        this.buttonRenameDocument.Visible = false;
                        this.buttonDeleteDocument.Visible = false;
                        this.buttonRestoreDocument.Visible = false;
                        this.documentSeparator.Visible = false;
                        this.documentSeparator1.Visible = false;
                        this.documentSeparator2.Visible = false;

                        Util.Document.CreateNoResultData(this.list);
                    }
                }
            }

            this.buttonRestoreDocument.Enabled = true;
        }
Exemplo n.º 43
0
        public Decimal guardarGarantia(int idbodega,
            int idLote,
            int idEmpresa,
            int idProducto,
            int Cantidad,
            String idRegional,
            String idCiudad,
            String talla,
            String motivo)
        {
            Boolean correcto = true;

            lote _lote = new lote(Empresa, Usuario);
            documento _doc = new documento(Empresa, Usuario);
            Decimal idDoc = 0;
            Decimal idInventario = 0;
            int idProveedor = 0;

            Conexion _dato = new Conexion(Empresa);
            _dato.IniciarTransaccion();

            try
            {
                _lote.MensajeError = null;
                DataTable tablalote = _lote.ObtenerAlmLotePorId(idLote, _dato);

                if (_lote.MensajeError != null)
                {
                    _dato.DeshacerTransaccion();
                    correcto = false;
                }
                else
                {
                    DataRow filalote = tablalote.Rows[0];
                    Decimal costo = Convert.ToDecimal(filalote["COSTO"]);
                    DateTime fecha = System.DateTime.Today;

                    _doc.MensajeError = null;
                    DataTable tabladoc = _doc.ObtenerAlmRegDocumentoPorId(Convert.ToInt32(filalote["ID_DOCUMENTO"]), _dato);

                    if (_doc.MensajeError != null)
                    {
                        _dato.DeshacerTransaccion();
                        correcto = false;
                    }
                    else
                    {
                        DataRow filaDoc = tabladoc.Rows[0];
                        idProveedor = Convert.ToInt32(filaDoc["ID_PROVEEDOR"]);

                        idDoc = _doc.AdicionarAlmDocumentos(0, 0, "GARANTIA", "", "", fecha, new DateTime(), idbodega, 0, 0, "ELABORADO", motivo, _dato, idProveedor, null);

                        if (idDoc <= 0)
                        {
                            _dato.DeshacerTransaccion();
                            MensajeError += _doc.MensajeError;
                            correcto = false;
                        }
                        else
                        {
                            idInventario = AdicionarAlmInventario(Convert.ToInt32(idDoc), idProducto, idbodega, Cantidad, costo, fecha, "SALIDA", _dato, idLote, talla, 0, 0, null, filalote["REEMBOLSO"].ToString());
                            if (idInventario <= 0)
                            {
                                _dato.DeshacerTransaccion();
                                idDoc = 0;
                                correcto = false;
                            }
                            else
                            {
                                Int32 salidas = Convert.ToInt32(filalote["SALIDAS"]);
                                Int32 entradas = Convert.ToInt32(filalote["ENTRADAS"]);

                                salidas = salidas + Cantidad;

                                String ACTIVO = "S";
                                if (entradas <= salidas)
                                {
                                    ACTIVO = "N";
                                }

                                if (_lote.ActualizarAlmLote(idLote, Convert.ToInt32(filalote["ID_DOCUMENTO"]), idProducto, Convert.ToInt32(idbodega), fecha, entradas, salidas, costo, filalote["TALLA"].ToString(), ACTIVO, _dato) == false)
                                {
                                    _dato.DeshacerTransaccion();
                                    correcto = false;
                                    MensajeError = _lote.MensajeError;
                                }
                            }
                        }
                    }
                }

                if (correcto == true)
                {
                    _dato.AceptarTransaccion();
                }
            }
            catch (Exception ex)
            {
                _dato.DeshacerTransaccion();
                correcto = false;
                MensajeError = ex.Message;
            }
            finally
            {
                _dato.Desconectar();
            }

            if (correcto == true)
            {
                return idDoc;
            }
            else
            {
                return 0;
            }
        }
Exemplo n.º 44
0
        private async void buttonDeleteDocument_Click(object sender, EventArgs e)
        {
            if (this.list.SelectedItems != null && this.list.SelectedItems.Count > 0 && this.list.Columns.Count > 1)
            {
                String message = String.Empty;

                if (Util.User.CurrentArea.id == Util.User.TRASH_ID)
                {
                    if (this.list.SelectedItems.Count == 1)
                    {
                        documento doc = (documento)this.list.SelectedItems[0].Tag;

                        message = String.Format("Deseja remover PERMANENTEMENTE o arquivo {0}?", doc.name);
                    }
                    else
                    {
                        message = String.Format("Deseja remover PERMANENTEMENTE os {0} arquivos selecionados?", this.list.SelectedItems.Count);
                    }
                }
                else
                {
                    if (this.list.SelectedItems.Count == 1)
                    {
                        documento doc = (documento)this.list.SelectedItems[0].Tag;

                        message = String.Format("Deseja enviar o arquivo {0} para lixeira?", doc.name);
                    }
                    else
                    {
                        message = String.Format("Deseja enviar os {0} arquivos selecionados para a lixeira?", this.list.SelectedItems.Count);
                    }
                }

                if (MessageBox.Show(message, "", MessageBoxButtons.YesNo, MessageBoxIcon.None) == DialogResult.Yes)
                {
                    this.buttonDeleteDocument.Enabled = false;

                    bool remove = false;

                    documento[] docs = new documento[this.list.SelectedItems.Count];

                    for(Int32 i = 0; i < this.list.SelectedItems.Count; i++)
                    {
                        documento tag = (documento)this.list.SelectedItems[i].Tag;

                        docs[i] = tag;
                        
                        if (Util.User.CurrentArea.id == Util.User.TRASH_ID)
                        {
                            setExclusaoDefinitivaDocumentoResponse response = null;

                            try
                            {
                                response = await Service.IService.setExclusaoDefinitivaDocumentoAsync(new setExclusaoDefinitivaDocumentoRequest(tag.id, Util.User.GetHashID()));
                            }
                            catch
                            {
                                response = null;
                            }

                            if(response != null)
                            {
                                Int32 sucess = response.@return;

                                if(sucess != 0)
                                {
                                    remove = true;
                                }
                            }
                        }
                        else
                        {
                            setExcluirDocumentoResponse response = null;

                            try
                            {
                                response = await Service.IService.setExcluirDocumentoAsync(new setExcluirDocumentoRequest(tag.id, Util.User.GetHashID()));
                            }
                            catch
                            {
                                response = null;
                            }

                            if(response != null)
                            {
                                Int32 sucess = response.@return;

                                if(sucess != 0)
                                {
                                    remove = true;
                                }
                            }
                        }
                    }

                    if(remove)
                    {
                        for(Int32 i = 0; i < this.list.SelectedItems.Count; i++)
                        {
                            this.list.SelectedItems[i].Remove();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Não foi possível remover o arquivo");
                    }

                    if(this.list.Items.Count == 0)
                    {
                        this.buttonDownloadDocument.Visible = false;
                        this.buttonRenameDocument.Visible = false;
                        this.buttonDeleteDocument.Visible = false;
                        this.buttonRestoreDocument.Visible = false;
                        this.documentSeparator.Visible = false;
                        this.documentSeparator1.Visible = false;
                        this.documentSeparator2.Visible = false;

                        Util.Document.CreateNoResultData(this.list);
                    }
                }
            }
            else
            {
                MessageBox.Show("Não foi possível remover o arquivo.");
            }

            this.buttonDeleteDocument.Enabled = true;
        }
Exemplo n.º 45
0
        public Decimal AdicionarEntregaProductos(Decimal id_empleado,
            List<Entrega> listaProductosEntrega,
            List<Equipo> listaEquiposEntrega)
        {
            Conexion conexion = new Conexion(Empresa);
            conexion.IniciarTransaccion();

            Boolean correcto = true;

            Decimal id_documento_entrega = 0;

            try
            {
                documento _documento = new documento(Empresa, Usuario);
                id_documento_entrega = _documento.AdicionarAlmDocumentos(Convert.ToInt32(id_empleado), 0, TiposDeDocumento.ENTREGA.ToString(), null, null, DateTime.Now, new DateTime(), 0, 0, 0, EstadosDocumento.COMPLETO.ToString(), null, conexion, 0, null);

                if (id_documento_entrega <= 0)
                {
                    conexion.DeshacerTransaccion();
                    correcto = false;
                    MensajeError = _documento.MensajeError;
                    id_documento_entrega = 0;
                }
                else
                {
                    lote _lote = new lote(Empresa, Usuario);
                    Inventario _inventario = new Inventario(Empresa, Usuario);

                    Dictionary<Decimal, Decimal> listaIndices = new Dictionary<Decimal, Decimal>();

                    foreach (Entrega productoEntrega in listaProductosEntrega)
                    {
                        DataTable tablaLote = _lote.ObtenerAlmLotePorId(Convert.ToInt32(productoEntrega.ID_LOTE), conexion);
                        DataRow filaLote = tablaLote.Rows[0];

                        Decimal ID_BODEGA = Convert.ToDecimal(filaLote["ID_BODEGA"]);
                        Decimal COSTO_UNIDAD = Convert.ToDecimal(filaLote["COSTO"]);
                        Decimal COSTO_TOTAL = (COSTO_UNIDAD * productoEntrega.CANTIDAD);

                        Decimal ID_INVENTARIO = _inventario.AdicionarAlmInventario(Convert.ToInt32(id_documento_entrega), Convert.ToInt32(productoEntrega.ID_PRODUCTO), Convert.ToInt32(ID_BODEGA), productoEntrega.CANTIDAD, Convert.ToDecimal(filaLote["COSTO"]), DateTime.Now, TiposMovimientos.SALIDA.ToString(), conexion, Convert.ToInt32(productoEntrega.ID_LOTE), productoEntrega.TALLA, 0, 0, null, filaLote["REEMBOLSO"].ToString());

                        if (ID_INVENTARIO <= 0)
                        {
                            conexion.DeshacerTransaccion();
                            correcto = false;
                            MensajeError = _inventario.MensajeError;
                            id_documento_entrega = 0;
                            break;
                        }
                        else
                        {
                            if (_lote.ActualizarCantidadesInventario(productoEntrega.ID_LOTE, productoEntrega.CANTIDAD, TiposMovimientos.SALIDA.ToString(), conexion) == false)
                            {
                                conexion.DeshacerTransaccion();
                                correcto = false;
                                MensajeError = _inventario.MensajeError;
                                id_documento_entrega = 0;
                                break;
                            }
                            else
                            {
                                Decimal ID_ASIGNACION_SC = 0;

                                if (productoEntrega.ID_ASIGNACION_SC == 0)
                                {
                                    if (listaIndices.ContainsKey(productoEntrega.ID_INDEX) == true)
                                    {
                                        ID_ASIGNACION_SC = listaIndices[productoEntrega.ID_INDEX];
                                    }
                                    else
                                    {
                                        ID_ASIGNACION_SC = AdicionarEscAsignacionSC(id_empleado, productoEntrega.ID_PRODUCTO, productoEntrega.CANTIDAD_TOTAL, 0, productoEntrega.FECHA_PROYECTADA_ENTREGA, productoEntrega.TIPO_ENTREGA, EstadosAsignacionSC.ABIERTA.ToString(), conexion);

                                        if (ID_ASIGNACION_SC <= 0)
                                        {
                                            conexion.DeshacerTransaccion();
                                            correcto = false;
                                            id_documento_entrega = 0;
                                            break;
                                        }
                                        else
                                        {
                                            listaIndices.Add(productoEntrega.ID_INDEX, ID_ASIGNACION_SC);
                                        }
                                    }
                                }
                                else
                                {
                                    ID_ASIGNACION_SC = productoEntrega.ID_ASIGNACION_SC;
                                }

                                Decimal ID_DETALLE_ASIGNACION = AdicionarEscDetalleContenidoAsignacion(ID_ASIGNACION_SC, id_documento_entrega, productoEntrega.CANTIDAD, productoEntrega.TALLA, COSTO_UNIDAD, COSTO_TOTAL, productoEntrega.ID_LOTE, conexion, ID_INVENTARIO);

                                if (ID_DETALLE_ASIGNACION <= 0)
                                {
                                    conexion.DeshacerTransaccion();
                                    correcto = false;
                                    id_documento_entrega = 0;
                                    break;
                                }
                                else
                                {
                                    if (ActualizarCantidadesAsignacion(ID_ASIGNACION_SC, productoEntrega.CANTIDAD, conexion) == false)
                                    {
                                        conexion.DeshacerTransaccion();
                                        correcto = false;
                                        id_documento_entrega = 0;
                                        break;
                                    }
                                }
                            }
                        }
                    }

                    listaIndices = new Dictionary<Decimal, Decimal>();

                    foreach (Equipo equipo in listaEquiposEntrega)
                    {
                        DataTable tablaLote = _lote.ObtenerAlmLotePorId(Convert.ToInt32(equipo.ID_LOTE), conexion);
                        DataRow filaLote = tablaLote.Rows[0];

                        Decimal ID_BODEGA = Convert.ToDecimal(filaLote["ID_BODEGA"]);
                        Decimal COSTO_UNIDAD = Convert.ToDecimal(filaLote["COSTO"]);

                        Decimal ID_INVENTARIO = _inventario.AdicionarAlmInventario(Convert.ToInt32(id_documento_entrega), Convert.ToInt32(equipo.ID_PRODUCTO), Convert.ToInt32(ID_BODEGA), 1, Convert.ToDecimal(filaLote["COSTO"]), DateTime.Now, TiposMovimientos.SALIDA.ToString(), conexion, Convert.ToInt32(equipo.ID_LOTE), filaLote["TALLA"].ToString(), Convert.ToInt32(equipo.ID_EQUIPO), 0, null, filaLote["REEMBOLSO"].ToString());

                        if (ID_INVENTARIO <= 0)
                        {
                            conexion.DeshacerTransaccion();
                            correcto = false;
                            MensajeError = _inventario.MensajeError;
                            id_documento_entrega = 0;
                            break;
                        }
                        else
                        {
                            if (_lote.ActualizarCantidadesInventario(equipo.ID_LOTE, 1, TiposMovimientos.SALIDA.ToString(), conexion) == false)
                            {
                                conexion.DeshacerTransaccion();
                                correcto = false;
                                MensajeError = _inventario.MensajeError;
                                id_documento_entrega = 0;
                                break;
                            }
                            else
                            {
                                Decimal ID_ASIGNACION_SC = 0;

                                if (equipo.ID_ASIGNACION_SC == 0)
                                {
                                    if (listaIndices.ContainsKey(equipo.ID_INDEX) == true)
                                    {
                                        ID_ASIGNACION_SC = listaIndices[equipo.ID_INDEX];
                                    }
                                    else
                                    {
                                        ID_ASIGNACION_SC = AdicionarEscAsignacionSC(id_empleado, equipo.ID_PRODUCTO, equipo.CANTIDAD_TOTAL, 0, equipo.FECHA_PROYECTADA_ENTREGA, equipo.TIPO_ENTREGA, EstadosAsignacionSC.ABIERTA.ToString(), conexion);

                                        if (ID_ASIGNACION_SC <= 0)
                                        {
                                            conexion.DeshacerTransaccion();
                                            correcto = false;
                                            id_documento_entrega = 0;
                                            break;
                                        }
                                        else
                                        {
                                            listaIndices.Add(equipo.ID_INDEX, ID_ASIGNACION_SC);
                                        }
                                    }
                                }
                                else
                                {
                                    ID_ASIGNACION_SC = equipo.ID_ASIGNACION_SC;
                                }

                                Decimal ID_DETALLE_ASIGNACION = AdicionarEscDetalleContenidoAsignacion(ID_ASIGNACION_SC, id_documento_entrega, 1, filaLote["TALLA"].ToString(), Convert.ToDecimal(filaLote["COSTO"]), Convert.ToDecimal(filaLote["COSTO"]), equipo.ID_LOTE, conexion, ID_INVENTARIO);

                                if (ID_DETALLE_ASIGNACION <= 0)
                                {
                                    conexion.DeshacerTransaccion();
                                    correcto = false;
                                    id_documento_entrega = 0;
                                    break;
                                }
                                else
                                {
                                    if (ActualizarCantidadesAsignacion(ID_ASIGNACION_SC, 1, conexion) == false)
                                    {
                                        conexion.DeshacerTransaccion();
                                        correcto = false;
                                        id_documento_entrega = 0;
                                        break;
                                    }
                                    else
                                    {
                                        Decimal ID_EQUIPO_ENTREGA = AdicionarAlmEquiposEntrega(equipo.ID_EQUIPO, ID_DETALLE_ASIGNACION, DateTime.Now, conexion);

                                        if (ID_EQUIPO_ENTREGA <= 0)
                                        {
                                            conexion.DeshacerTransaccion();
                                            correcto = false;
                                            id_documento_entrega = 0;
                                            break;
                                        }
                                        else
                                        {
                                            if (ActualizarDisponibilidadDeEquipo(equipo.ID_EQUIPO, "N", conexion) == false)
                                            {
                                                conexion.DeshacerTransaccion();
                                                correcto = false;
                                                id_documento_entrega = 0;
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                if (correcto == true)
                {
                    conexion.AceptarTransaccion();
                }
            }
            catch (Exception ex)
            {
                conexion.DeshacerTransaccion();
                correcto = false;
                id_documento_entrega = 0;
                MensajeError = ex.Message;
            }
            finally
            {
                conexion.Desconectar();
            }

            return id_documento_entrega;
        }
Exemplo n.º 46
0
 /// <summary>
 /// There are no comments for documento in the schema.
 /// </summary>
 public void AddTodocumento(documento documento)
 {
     base.AddObject("documento", documento);
 }
Exemplo n.º 47
0
 /// <summary>
 /// Create a new documento object.
 /// </summary>
 /// <param name="idEmpresa">Initial value of idEmpresa.</param>
 /// <param name="idDoc">Initial value of idDoc.</param>
 /// <param name="idVista">Initial value of idVista.</param>
 /// <param name="idTipoDoc">Initial value of idTipoDoc.</param>
 /// <param name="dtCriacao">Initial value of dtCriacao.</param>
 /// <param name="pathImgF">Initial value of pathImgF.</param>
 /// <param name="pathImgV">Initial value of pathImgV.</param>
 /// <param name="dtUltAlteracao">Initial value of dtUltAlteracao.</param>
 /// <param name="del">Initial value of del.</param>
 /// <param name="status">Initial value of status.</param>
 public static documento Createdocumento(short idEmpresa, global::System.Guid idDoc, global::System.Guid idVista, decimal idTipoDoc, global::System.DateTime dtCriacao, string pathImgF, string pathImgV, byte[] dtUltAlteracao, bool del, byte status)
 {
     documento documento = new documento();
     documento.idEmpresa = idEmpresa;
     documento.idDoc = idDoc;
     documento.idVista = idVista;
     documento.idTipoDoc = idTipoDoc;
     documento.dtCriacao = dtCriacao;
     documento.pathImgF = pathImgF;
     documento.pathImgV = pathImgV;
     documento.dtUltAlteracao = dtUltAlteracao;
     documento.del = del;
     documento.status = status;
     return documento;
 }