示例#1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            string ruta = Server.MapPath(FolderAlquiler);
            BL_TBL_RequerimientoSubDetalle objx = new BL_TBL_RequerimientoSubDetalle();
            DataTable dt = new DataTable();
            dt = objx.SP_LISTAR_ARCHIVOS_PDC_TODOS("");
            for (int j = 0; j < dt.Rows.Count; j++)
            {
                ////**********************************************************
                //******** CREAR DIRECTORIO PROYECTO ******************************
                string Proyecto       = dt.Rows[j]["PROYECTO"].ToString();
                string PDC            = dt.Rows[j]["PDC"].ToString();
                string DIRECTORIO_PDC = dt.Rows[j]["DIRECTORIO"].ToString();
                string rutaOBRA       = FolderFTP + Proyecto.Substring(0, 5);



                // Si el directorio no existe, crearlo
                if (!Directory.Exists(rutaOBRA))//directorio OBRA
                {
                    Directory.CreateDirectory(rutaOBRA);
                }

                //DIRECTORIO  SAT
                string rutaSAT = Path.Combine(rutaOBRA, "SAT");
                if (!Directory.Exists(rutaSAT))//directorio final
                {
                    Directory.CreateDirectory(rutaSAT);
                }


                //DIRECTORIO  CODIGO DE PDC
                string rutaPDC_CODIGO = Path.Combine(rutaSAT, DIRECTORIO_PDC);
                if (!Directory.Exists(rutaPDC_CODIGO))//directorio final
                {
                    Directory.CreateDirectory(rutaPDC_CODIGO);
                }

                BL_TBL_RequerimientoSubDetalle obj = new BL_TBL_RequerimientoSubDetalle();
                DataTable dtResultado = new DataTable();
                dtResultado = obj.SP_LISTAR_ARCHIVOS_PDC(PDC);
                for (int i = 0; i < dtResultado.Rows.Count; i++)
                {
                    string adjunto = dtResultado.Rows[i]["ARCHIVO"].ToString();
                    if (File.Exists(Path.Combine(ruta, adjunto)))
                    {
                        File.Copy(Path.Combine(ruta, adjunto), Path.Combine(rutaPDC_CODIGO, adjunto), true);
                    }
                }
            }
            string cleanMessage = "Registro exitoso.";

            ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", "doAlert('" + cleanMessage + "');", true);
        }
    }
示例#2
0
    public int registroPDC(string _Requ_Numero, string _Reqd_CodLinea, string _Reqs_Correlativo, decimal valor, decimal total, int contador, int registros, decimal valorMov, string G)
    {
        string ruta         = Server.MapPath(FolderAlquiler);
        string rutaBackups  = FolderAlquilerBackups;
        int    dtrpta       = 0;
        string cleanMessage = string.Empty;

        if (txtFechaPDC.Text.Trim() == string.Empty)
        {
            cleanMessage = "Ingresar fecha de PDC";
            ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", "doAlert('" + cleanMessage + "');", true);
        }
        else if (txtPdc.Text.Trim() == string.Empty)
        {
            cleanMessage = "Ingresar PDC";
            ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", "doAlert('" + cleanMessage + "');", true);
        }
        else if (txtPdc.Text.Length < 10)
        {
            cleanMessage = "Favor de ingresar los 10 digtos de la PDC";
            ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", "doAlert('" + cleanMessage + "');", true);
        }
        //else if (txtmonto.Text.Trim() == string.Empty)
        //{
        //    cleanMessage = "Ingresar monto PDC";
        //    ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", "doAlert('" + cleanMessage + "');", true);
        //}
        else
        {
            // Si el directorio no existe, crearlo
            //if (!Directory.Exists(Server.MapPath(FolderAlquiler)))
            //    Directory.CreateDirectory(FolderAlquiler);

            String  fileExtension = string.Empty;
            Boolean fileOK        = false;
            string  fileArchivo   = string.Empty;
            if (FileUploadGuia.HasFile)
            {
                string fileName = FileUploadGuia.FileName.ToString();
                int    length   = FileUploadGuia.PostedFile.ContentLength;

                fileExtension = Path.GetExtension(FileUploadGuia.FileName).ToUpper();

                String[] allowedExtensions = { ".gif", ".png", ".jpeg", ".jpg", ".pdf", ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".txt" };
                for (int i = 0; i < allowedExtensions.Length; i++)
                {
                    if (fileExtension == allowedExtensions[i].ToUpper())
                    {
                        fileOK = true;
                    }
                }
            }
            if (fileOK)
            {
                try
                {
                    // Si el directorio no existe, crearlo
                    //if (!Directory.Exists(ruta))
                    //    Directory.CreateDirectory(ruta);

                    string archivo = String.Format("{0}\\{1}", ruta, FileUploadGuia.PostedFile.FileName);

                    // Verificar que el archivo no exista
                    if (File.Exists(archivo))
                    {
                        fileArchivo = EliminarCaracteres.ReemplazarCaracteresEspeciales("PDC_" + DateTime.UtcNow.ToFileTimeUtc() + Path.GetExtension(FileUploadGuia.PostedFile.FileName));
                        fileArchivo = fileArchivo.Replace("&", "y");
                        FileUploadGuia.SaveAs(ruta + fileArchivo);
                        FileUploadGuia.SaveAs(rutaBackups + fileArchivo);
                    }

                    else
                    {
                        fileArchivo = EliminarCaracteres.ReemplazarCaracteresEspeciales("PDC_" + Path.GetFileName(FileUploadGuia.FileName));
                        fileArchivo = fileArchivo.Replace("&", "y");
                        //FileUpload1.SaveAs(archivo);

                        FileUploadGuia.SaveAs(ruta + fileArchivo);
                        FileUploadGuia.SaveAs(rutaBackups + fileArchivo);
                    }
                }
                catch (Exception ex)
                {
                    cleanMessage = "Archivo no puedo ser cargado";
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", "doAlert('" + cleanMessage + "');", true);
                }
            }


            BE_TBL_RequerimientoSubDetalle oBESol = new BE_TBL_RequerimientoSubDetalle();
            oBESol.Requ_Numero        = _Requ_Numero;
            oBESol.Reqd_CodLinea      = _Reqd_CodLinea;
            oBESol.Reqs_Correlativo   = _Reqs_Correlativo;
            oBESol.D_PDC              = txtPdc.Text.Trim();
            oBESol.D_OBSERVACION_RUTA = FolderAlquiler;
            oBESol.D_GUIA_RUTA        = FolderAlquiler;
            oBESol.D_GUIA_FILE        = fileArchivo;
            oBESol.D_PDC_FECHA        = txtFechaPDC.Text;
            oBESol.D_PDC_MONEDA       = Convert.ToInt32(ddlMoneda.SelectedValue);
            oBESol.D_PDC_MONTO        = Convert.ToDecimal(string.IsNullOrEmpty(valor.ToString()) ? "0" : valor.ToString());

            int ampliacion = 0;
            if (CheckAmpliacion.Checked)
            {
                ampliacion = 1;
            }
            else
            {
                ampliacion = 0;
            }

            oBESol.D_AMPLIACION      = ampliacion;
            oBESol.D_PDC_MONTO_TOTAL = Convert.ToDecimal(string.IsNullOrEmpty(total.ToString()) ? "0" : total.ToString());
            oBESol.D_PDC_MONTO_MOVIL = Convert.ToDecimal(string.IsNullOrEmpty(valorMov.ToString()) ? "0" : valorMov.ToString());
            oBESol.GUID = G.ToString();
            dtrpta      = new BL_TBL_RequerimientoSubDetalle().uspINS_TBL_RequerimientoSubDetalle_PDC(oBESol);


            if (contador == registros)
            {
                ////**********************************************************
                //******** CREAR DIRECTORIO PROYECTO ******************************
                string Proyecto = Request.QueryString["Requ_Numero"].ToString();

                string rutaOBRA = FolderFTP + Proyecto.Substring(0, 5);

                // Si el directorio no existe, crearlo
                if (!Directory.Exists(rutaOBRA))//directorio OBRA
                {
                    Directory.CreateDirectory(rutaOBRA);
                }

                //DIRECTORIO  PDC
                string rutaSAT = Path.Combine(rutaOBRA, "SAT");
                if (!Directory.Exists(rutaSAT))//directorio final
                {
                    Directory.CreateDirectory(rutaSAT);
                }

                string DIRECTORIO_PDC = string.Empty;
                BL_TBL_RequerimientoSubDetalle objx = new BL_TBL_RequerimientoSubDetalle();
                DataTable dt = new DataTable();
                dt = objx.SP_LISTAR_ARCHIVOS_PDC_TODOS(txtPdc.Text.Trim());
                if (dt.Rows.Count > 0)
                {
                    DIRECTORIO_PDC = dt.Rows[0]["DIRECTORIO"].ToString();

                    //DIRECTORIO  CODIGO DE PDC
                    string rutaPDC_CODIGO = Path.Combine(rutaSAT, DIRECTORIO_PDC);
                    if (!Directory.Exists(rutaPDC_CODIGO))//directorio final
                    {
                        Directory.CreateDirectory(rutaPDC_CODIGO);
                    }

                    BL_TBL_RequerimientoSubDetalle obj = new BL_TBL_RequerimientoSubDetalle();
                    DataTable dtResultado = new DataTable();
                    dtResultado = obj.SP_LISTAR_ARCHIVOS_PDC(txtPdc.Text.Trim());
                    for (int i = 0; i < dtResultado.Rows.Count; i++)
                    {
                        string adjunto = dtResultado.Rows[i]["ARCHIVO"].ToString();
                        if (File.Exists(Path.Combine(ruta, adjunto)))
                        {
                            File.Copy(Path.Combine(ruta, adjunto), Path.Combine(rutaPDC_CODIGO, adjunto), true);
                        }
                    }
                }



                cleanMessage = "Registro exitoso.";

                ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", "doAlert('" + cleanMessage + "');", true);
                datos();
                file();
                GrupoFile();
            }
        }
        return(dtrpta);
    }