예제 #1
0
        /// <summary>
        /// Método para consultar los datos completos de un responsable.
        /// </summary>
        /// <returns>Retorna un booleando indicando si el responsable existe.</returns>
        public bool Consultar()
        {
            DsResponsables ds = this.GetResponsablesDataSet();

            if (ds == null)
            {
                return(false);
            }

            DsResponsables.DatosRow dr = ds.Datos.FindByResponsableID(this.ResponsableID);
            if (dr == null)
            {
                return(false);
            }

            this.Apellido              = dr.Apellido;
            this.Nombre                = dr.Nombre;
            this.TipoDocumento         = (SisPack.TipoDocumento)dr.TipoDocumentoID;
            this.NroDocumento          = dr.NroDocumento;
            this.Domicilio.DomicilioID = dr.IsDomicilioIDNull() ? 0 : dr.DomicilioID;
            if (this.Domicilio.DomicilioID != 0)
            {
                ((Domicilio)this.Domicilio).Consultar();
            }
            this.FechaAlta         = dr.FechaAlta;
            this.EstadoResponsable = (SisPack.EstadoResponsable)dr.EstadoResponsableID;

            return(true);
        }
        private void Buscar()
        {
            int total = 0;

            try
            {
                IResponsable   responsable = ResponsableFactory.GetResponsable();
                DsResponsables ds          = responsable.GetResponsablesDataSet();
//ESTA que sigue
                string filtroEspecial = "docNro LIKE '" + this.documentoNro + "%' AND ApeNom LIKE '" + this.apellidoNombre + "%'";

                if (this.documentoNro != "")
                {
                    filtro = "NroDocumento = '" + this.documentoNro + "' AND (Apellido LIKE '" + this.apellidoNombre + "%' OR Nombre LIKE '" + this.apellidoNombre + "%')";
                }
                else
                {
                    filtro = "Apellido LIKE '" + this.apellidoNombre + "%' OR Nombre LIKE '" + this.apellidoNombre + "%'";
                }

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

                if (total > 0)
                {
                    if (total == 1)
                    {
                        DsResponsables.DatosRow dr = drLista[0];
                        this.txtResponsableID.Text  = dr.ResponsableID.ToString();
                        this.txtDocumentoNro.Text   = dr.NroDocumento.ToString();
                        this.txtApellidoNombre.Text = dr.Apellido + " " + dr.Nombre;
                        this.txtErrorMsg.Text       = "";
                        this.txtOpen.Text           = "";
                    }
                    else
                    {
                        this.txtDocumentoNro.Text   = this.documentoNro;
                        this.txtApellidoNombre.Text = this.apellidoNombre;
                        this.txtOpen.Text           = "S";
                    }
                }
                else
                {
                    this.txtResponsableID.Text = "";
                    this.txtErrorMsg.Text      = "No se encontraron datos.";
                    this.txtOpen.Text          = "";
                }
            }
            catch (Exception ex)
            {
                this.txtErrorMsg.Text = "Error al consultar datos de responsables: " + ex.Message;
            }
        }
        private void dtgResponsables_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            if (e.CommandName == "Select")
            {
                BindGrid();
                int indice = e.Item.DataSetIndex;

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

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

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

                int    responsableID = dr.ResponsableID;
                string docNro        = dr.NroDocumento.ToString();
                string apeNom        = dr.Apellido + " " + dr.Nombre;

                StringBuilder scriptString = new StringBuilder();
                scriptString.Append("<script language='javascript'>\n");
                scriptString.Append("window.dialogArguments.ResponsableID = '" + responsableID.ToString() + "';\n");
                scriptString.Append("window.dialogArguments.DocumentoNro = '" + docNro + "';\n");
                scriptString.Append("window.dialogArguments.ApellidoNombre = '" + apeNom + "';\n");
                scriptString.Append("window.returnValue = true;\n");
                scriptString.Append("window.close();\n");
                scriptString.Append("</script>");

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