Exemple #1
0
        private string ExportarPDF()
        {                       //cuando venga 0 en solicitud se han pedidos todas
            if (Session["dsClientes"] != null)
            {
                //el dataset que le voy a pasar al generador de reportes crystal
                DsClientes        clie    = (DsClientes)Session["dsClientes"];
                DsReporteClientes reporte = new DsReporteClientes();

                for (int i = 0; i <= clie.Datos.Count - 1; i++)
                {
                    DsClientes.DatosRow        drClie    = (DsClientes.DatosRow)clie.Datos.Rows[i];
                    DsReporteClientes.DatosRow drReporte = (DsReporteClientes.DatosRow)reporte.Datos.NewDatosRow();
                }
                string empresa = System.Configuration.ConfigurationSettings.AppSettings["empresa"];

//				for (int i=0; i<reporte.Datos.Count-1;i++)
//				{
//					byte[] d= null;
//					DsReporteClientes.DatosRow drDatos= (DsReporteClientes.DatosRow) reporte.Datos.Rows[i];
//					d = ConversionImagen(Server.MapPath("." + "/Reportes/images/"+ empresa + ".JPG"));
//					drDatos["Imagen"]=d;
//				}

                //			byte[] im= null;
                //			DsSolicitudRetiroImpresion.SolicitudRow dr= (DsSolicitudRetiroImpresion.SolicitudRow) dsSolicitud.Solicitud.Rows[0];
                //			im = ConversionImagen(Server.MapPath("." + "/Reportes/images/blanco.JPG"));
                //			for (int i=0; i<dsSolicitud.Solicitud.Count;i++)
                //			{
                //				dr["Imagen"]=im;
                //			}

                ReportDocument             oRD = new ReportDocument();
                ExportOptions              oExO;
                DiskFileDestinationOptions oExDo = new DiskFileDestinationOptions();
                string nombArchi  = "Clientes_" + this.AgenciaConectadaID + ".pdf";
                string sNombrePDF = Server.MapPath(".") + "/ReportesPDF/" + nombArchi;
                if (System.IO.File.Exists(sNombrePDF))
                {
                    System.IO.File.Delete(sNombrePDF);
                }
                oRD.Load(Server.MapPath("." + "/Reportes/Clientes.rpt"));
                oRD.SetDataSource(clie);
                oExDo.DiskFileName = sNombrePDF;
                oExO = oRD.ExportOptions;
                oExO.ExportDestinationType = ExportDestinationType.DiskFile;
                oExO.ExportFormatType      = ExportFormatType.PortableDocFormat;
                oExO.DestinationOptions    = oExDo;
                oRD.Export();
                oRD.Close();
                oRD.Dispose();
                return(nombArchi);
            }
            else
            {
                ((ErrorWeb)this.phErrores.Controls[0]).setMensaje("No se ha podido consultar los datos de la solicitud");
                return("");
            }
        }
        private void BindGrid()
        {
            SisPackController.AdministrarGrillas.Configurar(this.dtgClientes, "ClienteID", this.CantidadOpciones);
            try
            {
                int        total   = 0;
                ICliente   cliente = ClienteFactory.GetCliente();
                DsClientes ds      = new DsClientes();
                if (Session["Usuario"] != null)
                {
                    IUsuarios usuario = (IUsuarios)Session["Usuario"];
                    ds = cliente.GetClientesDataSet(usuario.VendedorID);
                }
                else
                {
                    ds = cliente.GetClientesDataSet();                    //para consistencia con lo viejo
                }
                //string codi = this.txtCodigo.Text;
                //string razon = this.txtRazonSocial.Text;
                if (codigo == "")
                {
                    codigo = this.txtCodigo.Text;
                }
                if (razonSocial == "")
                {
                    razonSocial = this.txtRazonSocial.Text;
                }
                DsClientes.DatosRow[] drLista = (DsClientes.DatosRow[])ds.Datos.Select("Codigo LIKE '" + codigo + "%' AND RazonSocial LIKE '" + razonSocial + "%'");

                dtgClientes.DataSource = drLista;
                dtgClientes.DataBind();
                total        = drLista.Length;
                txtFila.Text = Convert.ToString(total);

                if (total == 1)
                {
                    DsClientes.DatosRow dr = drLista[0];
                    this.txtClienteID.Text   = dr.ClienteID.ToString();
                    this.txtCodigo.Text      = dr.Codigo;
                    this.txtRazonSocial.Text = dr.RazonSocial;
                }
                else
                {
                    this.txtCodigo.Text      = codigo;
                    this.txtRazonSocial.Text = razonSocial;
                }
            }
            catch (Exception ex)
            {
                throw ex;
                //this.txtErrorMsg.Text = "Error al consultar datos de clientes: " + ex.Message;
            }
        }
        private void Buscar()
        {
            int total = 0;

            try
            {
                ICliente   cliente = ClienteFactory.GetCliente();
                DsClientes ds      = new DsClientes();
                if (Session["Usuario"] != null)
                {
                    IUsuarios usuario = (IUsuarios)Session["Usuario"];
                    ds = cliente.GetClientesDataSet(usuario.VendedorID);
                }
                else
                {
                    ds = cliente.GetClientesDataSet();                    //para consistencia con lo viejo
                }
                //DsClientes ds = cliente.GetClientesDataSet();

                DsClientes.DatosRow[] drLista = (DsClientes.DatosRow[])ds.Datos.Select("Codigo LIKE '" + this.codigo + "%' AND RazonSocial LIKE '" + this.razonSocial + "%'");
                total = drLista.Length;

                if (total > 0)
                {
                    if (total == 1)
                    {
                        DsClientes.DatosRow dr = drLista[0];
                        this.txtClienteID.Text   = dr.ClienteID.ToString();
                        this.txtCodigo.Text      = dr.IsCodigoNull() ? null : dr.Codigo;
                        this.txtRazonSocial.Text = dr.RazonSocial;
                        this.txtErrorMsg.Text    = "";
                        this.txtOpen.Text        = "";
                    }
                    else
                    {
                        this.txtCodigo.Text      = this.codigo;
                        this.txtRazonSocial.Text = this.razonSocial;
                        this.txtOpen.Text        = "S";
                    }
                }
                else
                {
                    this.txtClienteID.Text = "";
                    this.txtErrorMsg.Text  = "No se encontraron datos.";
                    this.txtOpen.Text      = "";
                }
            }
            catch (Exception ex)
            {
                this.txtErrorMsg.Text = "Error al consultar datos de clientes: " + ex.Message;
            }
        }
        private void dtgClientes_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            if (e.CommandName == "Select")
            {
                int indice = e.Item.DataSetIndex;
                BindGrid();

                DsClientes.DatosRow[] drLista = (DsClientes.DatosRow[])dtgClientes.DataSource;
                if (drLista == null)
                {
                    return;
                }

                if (drLista.Length == 0)
                {
                    return;
                }

                DsClientes.DatosRow dr = drLista[indice];
                if (dr == null)
                {
                    return;
                }

                int    clienteID   = dr.ClienteID;
                string codigo      = dr.IsCodigoNull() ? "" : dr.Codigo;
                string razonSocial = dr.RazonSocial;

                StringBuilder scriptString = new StringBuilder();
                scriptString.Append("<script language='javascript'>\n");
                scriptString.Append("window.dialogArguments.ClienteID = '" + clienteID.ToString() + "';\n");
                scriptString.Append("window.dialogArguments.Codigo = '" + codigo + "';\n");
                scriptString.Append("window.dialogArguments.RazonSocial = '" + razonSocial + "';\n");
                scriptString.Append("window.returnValue = true;\n");
                scriptString.Append("window.close();\n");
                scriptString.Append("</script>");

                Page.RegisterClientScriptBlock("scriptModalCliente", scriptString.ToString());
            }
        }
        private void dtgClientes_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            if (e.CommandName == "Select")
            {
                int indice = e.Item.DataSetIndex;
                BindGrid();

                DsClientes.DatosRow[] drLista = (DsClientes.DatosRow[])dtgClientes.DataSource;
                if (drLista == null)
                {
                    return;
                }

                if (drLista.Length == 0)
                {
                    return;
                }

                DsClientes.DatosRow dr = drLista[indice];
                if (dr == null)
                {
                    return;
                }

                int    clienteID   = dr.ClienteID;
                string codigo      = dr.IsCodigoNull() ? "" : dr.Codigo;
                string razonSocial = dr.RazonSocial;

                StringBuilder scriptString = new StringBuilder();
                scriptString.Append("<script language='javascript'>\n");
                //MODIFICACION PARA CHROME Y FIREFOX. FLORENCIA QUIROGA.02/07/2014
                scriptString.Append("select(" + clienteID + "," + "'" + razonSocial + "'" + "," + "'" + codigo + "'" + " );");
                scriptString.Append("parent.window.close();\n");
                scriptString.Append("</script>");

                Page.RegisterClientScriptBlock("scriptModalCliente", scriptString.ToString());
            }
        }