Пример #1
0
        private void dtgSupervisores_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            if (e.CommandName == "Select")
            {
                BindGrid();
                int indice = e.Item.DataSetIndex;

                DsVendedores.DatosRow[] drLista = (DsVendedores.DatosRow[]) this.dtgSupervisores.DataSource;
                if (drLista == null)
                {
                    return;
                }

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

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

                int    vendedorID = dr.VendedorID;
                string codigo     = dr.IsNroLegajoNull() ? null : dr.NroLegajo;
                string apeNom     = dr.Apellido + " " + dr.Nombre;

                StringBuilder scriptString = new StringBuilder();
                scriptString.Append("<script language='javascript'>\n");
                //scriptString.Append("window.dialogArguments.VendedorID = '" + vendedorID.ToString() + "';\n");
                //scriptString.Append("window.dialogArguments.Codigo = '" + codigo + "';\n");
                //scriptString.Append("window.dialogArguments.ApellidoNombre = '" + apeNom + "';\n");
                //scriptString.Append("window.returnValue = true;\n");

                scriptString.Append("select(" + vendedorID + "," + "'" + codigo + "'" + "," + "'" + apeNom + "'" + "," + "'" + parametro + "'" + " );");
                scriptString.Append("window.close();\n");
                scriptString.Append("</script>");

                Page.RegisterClientScriptBlock("scriptModalSupervisor", scriptString.ToString());
            }
            if (e.CommandName == "SelectConvenio")
            {
                BindGrid();
                int indice = e.Item.DataSetIndex;

                DsVendedores.DatosRow[] drLista = (DsVendedores.DatosRow[]) this.dtgSupervisores.DataSource;
                if (drLista == null)
                {
                    return;
                }

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

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

                int vendedorID = dr.VendedorID;
                Session["VendedorID"] = vendedorID;

                StringBuilder scriptString = new StringBuilder();
                scriptString.Append("<script language='javascript'>\n");
                scriptString.Append("window.returnValue = true;\n");
                scriptString.Append("window.close();\n");
                scriptString.Append("</script>");
                Page.RegisterClientScriptBlock("scrptConvenio", scriptString.ToString());

                //Response.Redirect("ConvenioCliente.aspx?CotizacionClienteID=" + cotizacion + "&VendedorID=" + vendedorID);
            }
        }
        private void Buscar()
        {
            int total = 0;

            try
            {
                IVendedor    vendedor = VendedorFactory.GetVendedor();
                DsVendedores ds       = vendedor.GetVendedoresDataSet();

                string filtro = null;
                if (this.codigo != "")
                {
                    filtro = "NroLegajo LIKE '" + codigo + "%' AND (Apellido LIKE '" + this.apellidoNombre + "%' OR Nombre LIKE '" + this.apellidoNombre + "%')";
                }
                else
                {
                    filtro = "(Apellido LIKE '" + this.apellidoNombre + "%' OR Nombre LIKE '" + this.apellidoNombre + "%')";
                }

                if (this.TxtEmpActual.Text != "")
                {
                    filtro += " AND VendedorID <> " + this.TxtEmpActual.Text;
                }

                //DEBE TENER EL ATRIBUTO DE SUPERVISOR EN "SI", siempre que sea llamado desde los vendedores
                if (this.txtFiltro.Text == "")
                {
                    filtro += " AND EsSupervisor=true";
                }

                DsVendedores.DatosRow[] drLista = (DsVendedores.DatosRow[])ds.Datos.Select(filtro);
                total = drLista.Length;

                if (total > 0)
                {
                    if (total == 1)
                    {
                        DsVendedores.DatosRow dr = drLista[0];

                        this.txtVendedorID.Text     = dr.VendedorID.ToString();
                        this.txtCodigo.Text         = dr.IsNroLegajoNull() ? null : dr.NroLegajo;
                        this.txtApellidoNombre.Text = dr.Apellido + " " + dr.Nombre;
                        this.txtErrorMsg.Text       = "";
                        this.txtOpen.Text           = "";
                    }
                    else
                    {
                        this.txtCodigo.Text         = this.codigo;
                        this.txtApellidoNombre.Text = this.apellidoNombre;
                        this.txtOpen.Text           = "S";
                    }
                }
                else
                {
                    this.txtVendedorID.Text = "";
                    this.txtErrorMsg.Text   = "No se encontraron datos.";
                    this.txtOpen.Text       = "";
                }
            }
            catch (Exception ex)
            {
                this.txtErrorMsg.Text = "Error al consultar datos de supervisores: " + ex.Message;
            }
        }