/// <summary> /// Evento que se lanza al guardar los archivos en el servidor /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void muSubirImagenesOrdenEstimacion_OnFileUpload(object sender, FileUploadEventArgs e) { //1. Obtener el ID del movimiento y el concepto int iID = Convert.ToInt32(Cookies.GetCookie("cookieEditarOrdenEstimacion").Value); string strConcepto = Cookies.GetCookie("cookieConceptoOrdenEstimacion").Value; string strDireccion = Server.MapPath(" ") + "\\imagenesOrdenEstimacion\\" + iID + "\\" + strConcepto; //2. Validar si existe el directorio donde se guardaran las imagenes if (Directory.Exists(strDireccion)) { e.PostedFile.SaveAs(strDireccion + "\\" + e.FileName); } else { Directory.CreateDirectory(strDireccion); e.PostedFile.SaveAs(strDireccion + "\\" + e.FileName); } //3. Realizar el objeto e insertar en la base de datos ImagenOrdenEstimacionD oImagenOrdenEstimacionD = new ImagenOrdenEstimacionD(); oImagenOrdenEstimacionD.MovID = iID; oImagenOrdenEstimacionD.Concepto = strConcepto; oImagenOrdenEstimacionD.Nombre = e.FileName; oImagenOrdenEstimacionD.Direccion = "\\imagenesOrdenEstimacion\\" + iID + "\\" + strConcepto + "\\" + e.FileName; //Traemos el usuario que realiza el movimiento Usuario oUsuario = (Usuario)Session["Usuario"]; oImagenOrdenEstimacionD.Usuario = oUsuario.ID; oImagenOrdenEstimacionD.FechaAlta = DateTime.Now; ImagenOrdenEstimacionBusiness.Insertar(oImagenOrdenEstimacionD); }
public void obtenerImagenesPorConcepto() { //1. Obtener el ID del movimiento y el concepto int iID = Convert.ToInt32(Cookies.GetCookie("cookieIDBorrarFotosOrdenEstimacion").Value); string strConcepto = Cookies.GetCookie("cookieConceptoFotosOrdenEstimacion").Value; string strDireccionImagenes = Server.MapPath(" ") + "\\imagenesOrdenEstimacion\\" + iID + "\\" + strConcepto; string strDireccionCroquis = Server.MapPath(" ") + "\\croquisOrdenEstimacion\\" + iID + "\\" + strConcepto; string strDireccionFacturas = Server.MapPath(" ") + "\\facturasOrdenEstimacion\\" + iID + "\\" + strConcepto; //2. Validar si existe el directorio donde se borrarán las imagenes if (Directory.Exists(strDireccionImagenes)) { try { System.IO.Directory.Delete(strDireccionImagenes, true); } catch (System.IO.IOException e) { Console.WriteLine(e.Message); } } //3. Validar si existe el directorio donde se borrarán los croquis if (Directory.Exists(strDireccionCroquis)) { try { System.IO.Directory.Delete(strDireccionCroquis, true); } catch (System.IO.IOException e) { Console.WriteLine(e.Message); } } //4. Validar si existe el directorio donde se borrarán las Facturas if (Directory.Exists(strDireccionFacturas)) { try { System.IO.Directory.Delete(strDireccionFacturas, true); } catch (System.IO.IOException e) { Console.WriteLine(e.Message); } } //5. Borrar en la base de datos ImagenOrdenEstimacionBusiness.BorrarImagenesOrdenEstimacionDPorConcepto(iID, strConcepto); FacturaOrdenEstimacionBusiness.BorrarFacturaOrdenEstimacionDPorConcepto(iID, strConcepto); CroquisOrdenEstimacionBusiness.BorrarCroquisOrdenEstimacionDPorConcepto(iID, strConcepto); GeneradorOrdenEstimacionDBusiness.BorrarGeneradorOrdenEstimacionDPorConcepto(iID, strConcepto); }
public void borrarImagenesPorMovimiento(int strID) { //1. Obtener el ID del movimiento string strDireccionImagenes = Server.MapPath(" ") + "\\imagenesOrdenEstimacion\\" + strID; string strDireccionCroquis = Server.MapPath(" ") + "\\croquisOrdenEstimacion\\" + strID; string strDireccionFacturas = Server.MapPath(" ") + "\\facturasOrdenEstimacion\\" + strID; //2. Validar si existe el directorio donde se borrarán las imagenes if (Directory.Exists(strDireccionImagenes)) { try { System.IO.Directory.Delete(strDireccionImagenes, true); } catch (System.IO.IOException e) { Console.WriteLine(e.Message); } } //3. Validar si existe el directorio donde se borrarán los croquis if (Directory.Exists(strDireccionCroquis)) { try { System.IO.Directory.Delete(strDireccionCroquis, true); } catch (System.IO.IOException e) { Console.WriteLine(e.Message); } } //4. Validar si existe el directorio donde se borrarán las Facturas if (Directory.Exists(strDireccionFacturas)) { try { System.IO.Directory.Delete(strDireccionFacturas, true); } catch (System.IO.IOException e) { Console.WriteLine(e.Message); } } //5. Borrar en la base de datos ImagenOrdenEstimacionBusiness.BorrarImagenesOrdenesEstimacionPorID(strID); FacturaOrdenEstimacionBusiness.BorrarFacturasOrdenesEstimacionPorID(strID); CroquisOrdenEstimacionBusiness.BorrarCroquisOrdenesEstimacionPorID(strID); GeneradorOrdenEstimacionDBusiness.BorrarGeneradorOrdenesEstimacionPorID(strID); }
public void onLoadDataImages() { int iID = Convert.ToInt32(Cookies.GetCookie("cookieEditarOrdenEstimacion").Value); string strConcepto = Cookies.GetCookie("cookieConceptoOrdenEstimacion").Value; List <ImagenOrdenEstimacionD> lImagenOrdenEstimacionD = ImagenOrdenEstimacionBusiness.ObtenerImagenOrdenEstimacionDPorMovPreciarioConcepto(iID, strConcepto); foreach (ImagenOrdenEstimacionD sd in lImagenOrdenEstimacionD) { sd.Direccion = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath + sd.Direccion; } sImagenesOrdenEstimacionD.DataSource = lImagenOrdenEstimacionD; sImagenesOrdenEstimacionD.DataBind(); }
public void BorrarImagen(string conceptoID, int MovID, string nombreimg) { //1. Obtener el ID del movimiento y el concepto int iID = Convert.ToInt32(Cookies.GetCookie("cookieEditarOrdenEstimacion").Value); string strConcepto = Cookies.GetCookie("cookieConceptoOrdenEstimacion").Value; string strDireccion = Server.MapPath(" ") + "\\imagenesOrdenEstimacion\\" + iID + "\\" + strConcepto; string url = strDireccion + "\\" + nombreimg; if (!(conceptoID.Equals("") && MovID.Equals("") && nombreimg.Equals(""))) { ImagenOrdenEstimacionBusiness.BorrarImagenesOrdenEstimacionDPorConceptoYNombre(MovID, conceptoID, nombreimg); try { File.Delete(url); } catch (Exception e) { X.Msg.Alert("Error", e.Message.ToString(), new JFunction { Fn = "showResult" }).Show(); } } }