private void BuildTableData(int patientItemId)
        {
            string tableName       = service.GetTableName();
            string tablePriKeyName = service.GetPriKeyName();
            IEnumerable <string> display_fields = service.GetFieldNames();
            DataView             view           = new DataView();

            int pageNum       = PageNumber;
            int start_row_num = GetStart(pageNum);
            int end_row_num   = GetEnd(pageNum);

            // build pager
            //int count = service.GetVisitRelatedRecordsCount();
            //BuildPages(count);

            DataTable table = service.GetVisitRelatedRecords(start_row_num, end_row_num);

            // clear columns, except special columns
            while (TableValues.Columns.Count > 1)
            {
                TableValues.Columns.RemoveAt(1);
            }

            //string[] display_columns = new string[] { "TableName" }.Concat(display_fields).Distinct().ToArray();
            // get display fields, flatted date fields
            string[] display_columns = display_fields.Except(from field in display_fields
                                                             where field.EndsWith("DateText") || field.EndsWith("Source") || field.EndsWith("Quality")
                                                             select field).ToArray();

            // add table value fields
            for (int i = 0; i < display_columns.Length; i++)
            {
                string     fieldName = display_columns[i];
                BoundField bf        = new BoundField();
                bf.DataField  = fieldName;
                bf.HeaderText = fieldName == "TableName" ? "Table" : pdec.GetFieldLabel(tableName, fieldName);
                if (fieldName.EndsWith("Date"))
                {
                    bf.DataFormatString = "{0:d}";
                }
                TableValues.Columns.Add(bf);
            }

            updateRowsIndexes.Clear();

            view = table.DefaultView;

            // build header
            TableHeaderRptr.DataSource = TableValues.Columns.Cast <DataControlField>().Select(c => c.HeaderText).ToArray();
            TableHeaderRptr.DataBind();

            // build data
            TableValues.DataKeyNames = new string[] { "TableName", tablePriKeyName };
            TableValues.DataSource   = view;
            TableValues.DataBind();

            RecordCount.Text = view.Count + " Record(s)";

            if (view.Count == 0)
            {
                Message.Text            = "There are no " + (!string.IsNullOrEmpty(tableName) ? pdec.GetTableLabel(tableName) : "") + " records for this Patient.";
                Message.Visible         = true;
                TableHeaderRptr.Visible = false;
                TableValues.Visible     = false;
                UpdateBtn.Visible       = false;
            }
            else
            {
                Message.Visible         = false;
                TableHeaderRptr.Visible = true;
                TableValues.Visible     = true;
                UpdateBtn.Visible       = true;
            }
        }
示例#2
0
        protected string RecordDetails(string tableName, string primaryKey)
        {
            string recordDetails = "";

            if (BOL.BusinessObjectFactory.CanBuildBusinessObject(tableName))
            {
                IBusinessObject biz = BusinessObjectFactory.BuildBusinessObject(tableName);
                biz.Get(int.Parse(primaryKey));

                string tableDisplayName = (biz.TableLabel.Length > 0) ? biz.TableLabel : tableName;

                Dictionary <string, string> HPIRecordDataEntryFields = new Dictionary <string, string>();
                HPIRecordDataEntryFields = CICHelper.GetCaisisInputControlsByTableName(tableName).ToDictionary(i => i.Field, i => pdec.GetFieldLabel(i.Table, i.Field));

                if (HPIRecordDataEntryFields.Keys.Count > 0)
                {
                    recordDetails = "<span id=\"HPIRecordDetailsBubbleContent_" + tableName + "_" + primaryKey + "\" class=\"HPIRecordDetailsBubbleContent\"><table><tr><td colspan=\"2\" class=\"HPIRecordDetailsBubbleTitle\" >" + tableDisplayName + "</td>";
                    foreach (string fieldName in HPIRecordDataEntryFields.Keys)
                    {
                        string fieldLabel = HPIRecordDataEntryFields[fieldName];
                        string fieldValue = biz[fieldName].ToString();

                        if (fieldValue.Length > 0)
                        {
                            recordDetails += "<tr><td>" + fieldLabel + "</td><td>" + fieldValue + "</td></tr>";
                        }
                    }
                    recordDetails += "</table></span>";
                }
            }

            return(recordDetails);
        }