protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int id = Convert.ToInt32(Request.QueryString["id"]);
                DalSic.SysPaciente pac = new DalSic.SysPaciente(id);
                DataTable          dtd = new DataTable();

                if (pac != null)
                {
                    txtDocumento.Text       = pac.NumeroDocumento.ToString();
                    txtApellidoNombres.Text = pac.Apellido.ToString() + " " + pac.Nombre.ToString();;
                    txtEdad.Text            = pac.Edad.ToString();
                    txtSexo.Text            = pac.SysSexo.Nombre.ToString();
                    txtOS.Text = pac.SysObraSocial.Nombre.ToString();


                    SubSonic.Select query = new SubSonic.Select();
                    query.From(DalSic.SysDefuncion.Schema);
                    query.Where(SysDefuncion.Columns.IdPaciente).IsEqualTo(id).And(SysDefuncion.Columns.Activo).IsEqualTo(true);

                    dtd = query.ExecuteDataSet().Tables[0];

                    if (dtd.Rows.Count > 0) //Se encontró registro de defunción asociado
                    {
                        cargarRegistro(dtd);
                        btnAnularDefuncion.Visible = true;
                        hfupdate.Value             = "si";
                    }
                    else
                    {
                        hfupdate.Value = "no";
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Loads the grid.
        /// </summary>
        private void LoadGrid()
        {
            if (String.IsNullOrEmpty(tableName))
            {
                throw new ArgumentException("No tableName property set - please be sure to set the name of the table or view you'd like to see", tableName);
            }

            DecideSortDirection();

            //load the data
            DataProvider provider = DataService.GetInstance(ProviderName);
            SqlQuery     q        = new Select(provider).From(tableName);

            //set the select list
            StringBuilder selectList = new StringBuilder("*");

            if (!String.IsNullOrEmpty(columnList))
            {
                selectList = new StringBuilder();
                for (int i = 0; i < colList.Count; i++)
                {
                    selectList.Append(colList[i].ToString().Trim());
                    if (i + 1 < colList.Count)
                    {
                        selectList.Append(",");
                    }
                }
            }

            q.SelectColumnList = selectList.ToString().Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            //sorting
            if (!String.IsNullOrEmpty(sortBy))
            {
                TableSchema.TableColumn col = provider.GetTableSchema(tableName, TableType.Table).GetColumn(sortBy);
                if (col != null && col.MaxLength < 2048 && col.DataType != DbType.Binary && col.DataType != DbType.Byte)
                {
                    if (String.IsNullOrEmpty(sortDirection) || sortDirection.Trim() == SqlFragment.ASC.Trim())
                    {
                        q.OrderAsc(sortBy);
                    }
                    else
                    {
                        q.OrderDesc(sortBy);
                    }
                }
            }

            //paging
            if (pageSize > 0)
            {
                q.Paged(pageIndex, pageSize);
                ddlPages.SelectedValue = pageIndex.ToString();
            }

            //honor logical deletes
            q.CheckLogicalDelete();

            //where
            if (!String.IsNullOrEmpty(whereExpression))
            {
                q.WhereExpression(whereExpression);
            }

            SqlQueryBridge.AddLegacyWhereCollection(q, whereCollection);

            DataSet ds = q.ExecuteDataSet();

            if (ds.Tables.Count > 0)
            {
                dataSource = ds.Tables[0];
            }
            else
            {
                throw new Exception("Bad query - no data returned. Did you set the correct provider?");
            }

            EnsureTotals(q);
            //set the buttons
            SetPagingButtonState();
            //create a table
            BuildRows();
        }