using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Data.SqlClient;
using digioz;

/// <summary>
/// Summary description for AbbreviationsManagement
/// </summary>
public class AbbreviationsManagement
{
    private static PortalSettings coPortalSettings;

    public static AbbreviationsList GetAbbreviationsMenuList()
    {
        //selects all abbreviations to display in menu list
        AbbreviationsList loAbbreviationsList = new AbbreviationsList();
        coPortalSettings = PortalSettingsManagement.GetPortalSettings();
        string lsSQL = "";

        if (coPortalSettings.DBRelational == true)
        {
            IDataRelational loDB = DataFactory.GetDataObject(coPortalSettings);
            Abbreviations loAbbreviations;
            DataTable loAbbrData;

            lsSQL = "select abbrv_name, abbrv_desc from tblAbbreviations where abbrv_menu = 'Y'";

            loDB.openConnection();
            loAbbrData = loDB.QueryDBDataset(lsSQL);
            loDB.closeConnection();

            foreach (DataRow loDR in loAbbrData.Rows)
            {
                loAbbreviations = new Abbreviations();
                loAbbreviations.Abbrv_Name = (string)loDR["abbrv_name"];
                loAbbreviations.Abbrv_Desc = (string)loDR["abbrv_desc"];
            }
        }

        return loAbbreviationsList;
    }

    public static AbbreviationsList GetAbbreviationsBoxList()
    {
        //selects all abbreviations to display in box list
        AbbreviationsList loAbbreviationsList = new AbbreviationsList();
        coPortalSettings = PortalSettingsManagement.GetPortalSettings();
        string lsSQL = "";

        if (coPortalSettings.DBRelational == true)
        {
            IDataRelational loDB = DataFactory.GetDataObject(coPortalSettings);
            Abbreviations loAbbreviations;
            DataTable loAbbrData;

            lsSQL = "select abbrv_name, abbrv_desc from tblAbbreviations where abbrv_box = 'Y'";

            loDB.openConnection();
            loAbbrData = loDB.QueryDBDataset(lsSQL);
            loDB.closeConnection();

            foreach (DataRow loDR in loAbbrData.Rows)
            {
                loAbbreviations = new Abbreviations();
                loAbbreviations.Abbrv_Name = (string)loDR["abbrv_name"];
                loAbbreviations.Abbrv_Desc = (string)loDR["abbrv_desc"];
            }
        }

        return loAbbreviationsList;
    }
    public static List<Abbreviations> GetAbbrevList(string lsFlag) 
    {
        List<Abbreviations> retList = new List<Abbreviations>();
        coPortalSettings = PortalSettingsManagement.GetPortalSettings();

        if (coPortalSettings.DBRelational == true)
        {
            IDataRelational loDB = DataFactory.GetDataObject(coPortalSettings);

            loDB.openConnection();
            String lsSQL;
            if (lsFlag == "m")
            {
                lsSQL = "select abbrv_name, abbrv_desc from tblAbbreviations where abbrv_menu = 'Y'";
            }
            else 
            {
                lsSQL = "select abbrv_name, abbrv_desc from tblAbbreviations where abbrv_box = 'Y'";
            }

            DataTable loDT = loDB.QueryDBDataset(lsSQL);

            foreach (DataRow loDR in loDT.Rows)
            {
                Abbreviations a = new Abbreviations();
                a.Abbrv_Name = (string)loDR.ItemArray[0];
                a.Abbrv_Desc = (string)loDR.ItemArray[1];
                
                retList.Add(a);
            }
            loDB.closeConnection();
        }
        
        return retList;
    }

    //public static List<Abbreviations> GetAbbrevBoxList()
    //{
    //    List<Abbreviations> retList = new List<Abbreviations>();
    //    coPortalSettings = PortalSettingsManagement.GetPortalSettings();

    //    if (coPortalSettings.DBRelational == true)
    //    {
    //        IDataRelational loDB = DataFactory.GetDataObject(coPortalSettings);

    //        loDB.openConnection();
    //        String lsSQL;
    //        lsSQL = "select abbrv_name, abbrv_desc from tblAbbreviations where abbrv_box = 'Y'";

    //        DataTable loDT = loDB.QueryDBDataset(lsSQL);

    //        foreach (DataRow loDR in loDT.Rows)
    //        {
    //            Abbreviations a = new Abbreviations();
    //            a.Abbrv_Name = (string)loDR.ItemArray[0];
    //            a.Abbrv_Desc = (string)loDR.ItemArray[1];

    //            retList.Add(a);
    //        }
    //        loDB.closeConnection();
    //    }

    //    return retList;
    //}

}
