Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        protected void imgbtnAceptar_Click(object sender, DirectEventArgs e)
        {
            //1. Obtener datos de la Forma y saber si es edición o nuevo

            string strDescripcion = e.ExtraParams["DescripcionCorta"].Trim().Equals("") || e.ExtraParams["DescripcionCorta"] == null?"":e.ExtraParams["DescripcionCorta"];
            string strGeneradorD  = e.ExtraParams["GeneradorD"];
            string strPlano       = e.ExtraParams["vPlano"];
            int    iID            = Convert.ToInt32(Cookies.GetCookie("cookieEditarOrdenEstimacion").Value);
            string strConcepto    = Cookies.GetCookie("cookieConceptoOrdenEstimacion").Value;

            //2. Serializar el detalle

            List <GeneradorOrdenEstimacionD> lGeneradorD = JSON.Deserialize <List <GeneradorOrdenEstimacionD> >(strGeneradorD);

            //3. Guardar o Actuaizar el Movimiento

            //4. Lo que sucede cuando no es nuevo y ya se habia guardado

            //Se revisa que no este en la bd si devuelve falso se inserta pro primera vez
            if (GeneradorOrdenEstimacionDBusiness.ObtenerGeneradorOrdenEstimacionVaciosPorMovimientoConcepto(strConcepto, iID))
            {
                //1. Borrar todo el detalle e insertarlo de nuevo
                GeneradorOrdenEstimacionDBusiness.BorrarGeneradorOrdenEstimacionDPorConcepto(iID, strConcepto);

                //2. Insertar los datos del detalle
                foreach (GeneradorOrdenEstimacionD sd in lGeneradorD)
                {
                    //2. Validar que el objeto no venga en blanco
                    if (sd.Area.Equals(string.Empty) || sd.Total == 0)
                    {
                        continue;
                    }
                    else
                    {
                        sd.ConceptoID  = strConcepto;
                        sd.MovID       = iID;
                        sd.Descripcion = strDescripcion;
                        sd.Plano       = strPlano;
                        GeneradorOrdenEstimacionDBusiness.Insertar(sd);
                    }
                }
            }
            else
            {
                //1. Insertar los datos del detalle y regresar valor
                foreach (GeneradorOrdenEstimacionD sd in lGeneradorD)
                {
                    //2. Validar que el objeto no venga en blanco
                    if (sd.Area.Equals(string.Empty) || sd.Total == 0)
                    {
                        continue;
                    }
                    else
                    {
                        sd.ConceptoID  = strConcepto;
                        sd.MovID       = iID;
                        sd.Descripcion = strDescripcion;
                        sd.Plano       = strPlano;
                        GeneradorOrdenEstimacionDBusiness.Insertar(sd);
                    }
                }
            }
        }