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()); } }