Beispiel #1
0
    public object GetValue(string fieldName)
    {
        IEnumerator <DatabaseRowObject.DatabaseColumnObject> iter = databaseRowObj.GetEnumerator();

        DatabaseRowObject.DatabaseColumnObject col = null;

        while (iter.MoveNext())
        {
            if (iter.Current.DataBaseTableColumnName == fieldName)
            {
                break;
            }
        }

        col = iter.Current;
        object retValue    = null;
        object columnValue = null;

        switch (col.DataType)
        {
        case MyDataTypes.INTEGER:
            columnValue = Utilities.ParseInt32(sqlReader, col.Column);
            break;

        case MyDataTypes.STRING:
            columnValue = Utilities.ParseStr(sqlReader, col.Column);
            break;

        case MyDataTypes.DATETIME:
            columnValue = Utilities.ParseDateTime(sqlReader, col.Column);
            break;

        case MyDataTypes.GUID:
            columnValue = Utilities.ParseGuid(sqlReader, col.Column);
            break;
        }

        if (col.Encrypted)
        {
            retValue = dataEncryptionAlgorithm.DecryptObj(columnValue);

            if (col.DisplayType == MyDisplayTypes.DATE)
            {
                DateTime dt = DateTime.Parse(retValue.ToString());
                retValue = (object)String.Format("{0}/{1}/{2}", dt.Month.ToString(), dt.Day.ToString(), dt.Year.ToString());;
            }

            return(retValue);
        }
        else
        {
            return(columnValue);
        }
    }
    public void AddColumn(string databaseColumnName, string dataGridColumnName, MyDataTypes dataType, bool orderByColumn, int gridWidth, bool includeInGrid = true)
    {
        DatabaseRowObject.DatabaseColumnObject column = new DatabaseRowObject.DatabaseColumnObject();
        column.DataBaseTableColumnName = databaseColumnName;
        column.DataGridColumnName      = dataGridColumnName;
        column.OrderByColumn           = orderByColumn;
        column.DataType          = dataType;
        column.IncludeInDataGrid = includeInGrid;

        columnDictionary.Add(columnDictionary.Count + 1, column);
        gridIndexByColumnName.Add(databaseColumnName, gridIndexByColumnName.Count);
    }
    public void LoadGrid()
    {
        DatabaseRowObject.DatabaseColumnObject databaseColumnObj = null;

        dataGridObject    = new DataGridObject(WebConfigurationManager.ConnectionStrings["MyTherapistDatabaseConnectionString"].ConnectionString, "PatientInformation");
        databaseRowObject = new DatabaseRowObject();
        databaseColumnObj = new DatabaseRowObject.DatabaseColumnObject();

        databaseColumnObj.DataBaseTableColumnName = "Id";
        databaseColumnObj.DataGridColumnName      = "Id";
        databaseColumnObj.DataType          = MyDataTypes.INTEGER;
        databaseColumnObj.IncludeInDataGrid = true;
        databaseColumnObj.OrderByColumn     = true;
        databaseColumnObj.Encrypted         = false;
        databaseRowObject.AddColumn(databaseColumnObj);

        databaseColumnObj = new DatabaseRowObject.DatabaseColumnObject();
        databaseColumnObj.DataBaseTableColumnName = "FirstName";
        databaseColumnObj.DataGridColumnName      = "First Name";
        databaseColumnObj.DataType          = MyDataTypes.STRING;
        databaseColumnObj.IncludeInDataGrid = true;
        databaseColumnObj.OrderByColumn     = false;
        databaseColumnObj.Encrypted         = false;
        databaseRowObject.AddColumn(databaseColumnObj);

        databaseColumnObj = new DatabaseRowObject.DatabaseColumnObject();
        databaseColumnObj.DataBaseTableColumnName = "LastName";
        databaseColumnObj.DataGridColumnName      = "Last Name";
        databaseColumnObj.DataType          = MyDataTypes.STRING;
        databaseColumnObj.IncludeInDataGrid = true;
        databaseColumnObj.OrderByColumn     = false;
        databaseColumnObj.Encrypted         = false;
        databaseRowObject.AddColumn(databaseColumnObj);

        databaseColumnObj = new DatabaseRowObject.DatabaseColumnObject();
        databaseColumnObj.DataBaseTableColumnName = "BirthDate";
        databaseColumnObj.DataGridColumnName      = "BirthDate";
        databaseColumnObj.DataType          = MyDataTypes.STRING;
        databaseColumnObj.DisplayType       = MyDisplayTypes.DATE;
        databaseColumnObj.IncludeInDataGrid = true;
        databaseColumnObj.OrderByColumn     = false;
        databaseColumnObj.Encrypted         = true;
        databaseRowObject.AddColumn(databaseColumnObj);

        databaseColumnObj = new DatabaseRowObject.DatabaseColumnObject();
        databaseColumnObj.DataBaseTableColumnName = "EmailAddress";
        databaseColumnObj.DataGridColumnName      = "Email Address";
        databaseColumnObj.DataType          = MyDataTypes.STRING;
        databaseColumnObj.IncludeInDataGrid = true;
        databaseColumnObj.OrderByColumn     = false;
        databaseColumnObj.Encrypted         = true;
        databaseRowObject.AddColumn(databaseColumnObj);

        databaseColumnObj = new DatabaseRowObject.DatabaseColumnObject();
        databaseColumnObj.DataBaseTableColumnName = "TelephoneNumber";
        databaseColumnObj.DataGridColumnName      = "Telephone Number";
        databaseColumnObj.DataType          = MyDataTypes.STRING;
        databaseColumnObj.IncludeInDataGrid = true;
        databaseColumnObj.OrderByColumn     = false;
        databaseColumnObj.Encrypted         = true;
        databaseRowObject.AddColumn(databaseColumnObj);

        dataGridObject.DatabaseRowObject   = databaseRowObject;
        dataGridObject.FillToCompletePage  = true;
        dataGridObject.PageNumber          = 1;
        dataGridObject.NumberRowsToDisplay = 15;

        pager = new MyDataGridPager();

        pager.AddColumn("Id", 15);
        pager.AddColumn("First Name", 25);
        pager.AddColumn("Last Name", 250);
        pager.AddColumn("Email Address", 250);
        pager.AddColumn("Telephone Number", 100);

        if (txtBoxPatientFirstName.Text.Length > 0)
        {
            dataGridObject.AddWhereClauseArgument("FirstName", txtBoxPatientFirstName.Text);
        }

        if (txtBoxPatientLastName.Text.Length > 0)
        {
            dataGridObject.AddWhereClauseArgument("LastName", txtBoxPatientLastName.Text);
        }

        if (IsPostBack == false)
        {
            dataGridObject.PageNumber         = 1;
            Session["PatientList_PageNumber"] = "1";
        }
        else
        {
            dataGridObject.PageNumber = Int32.Parse(Session["PatientList_PageNumber"].ToString());
        }

        patientlistgridview.DataSource            = dataGridObject.BuildTable();
        patientlistgridview.RowDataBound         += Patientlistgridview_RowDataBound;
        patientlistgridview.SelectedIndexChanged += Patientlistgridview_SelectedIndexChanged;
        patientlistgridview.DataBind();

        if (dataGridObject.NumberOfCompletedPages == 0)
        {
            btnNextPAge.Enabled = false;
        }
        else
        {
            btnNextPAge.Enabled = true;
        }
    }