Exemplo n.º 1
0
        public cPhone()
        {
            PhoneNumberID = -1;

            SortedList sParams = new SortedList();

            DataTable dtPhoneTypes = cUtilities.LoadDataTable("uspGetPhoneTypes", sParams, "LARPortal", "", "cPhone.Creator");

            // Get the list of providers. This is used both for the lookup but also be available for the drop down list.     JBradshaw 5/26/2017
            DataTable dtPhoneProv = cUtilities.LoadDataTable("uspGetPhoneProviders", sParams, "LARPortal", "", "cPhone.Creator.PhoneProviders");

            ProviderList = new List <cPhoneProvider>();
            foreach (DataRow dRow in dtPhoneProv.Rows)
            {
                cPhoneProvider Prov = new cPhoneProvider();
                Prov.ProviderGateway = dRow["ProviderGateway"].ToString();
                Prov.ProviderName    = dRow["ProviderName"].ToString();
                int iTemp;
                if (int.TryParse(dRow["PhoneProviderID"].ToString(), out iTemp))
                {
                    Prov.PhoneProviderID = iTemp;
                }
                ProviderList.Add(Prov);
            }

            PhoneTypes = new List <cPhoneType>();
            if (new DataView(dtPhoneTypes, "PhoneTypeID = 0", "", DataViewRowState.CurrentRows).Count == 0)
            {
                cPhoneType NewPhoneNumber = new cPhoneType();
                NewPhoneNumber.PhoneTypeID = 0;
                NewPhoneNumber.PhoneType   = "Choose...";
                PhoneTypes.Add(NewPhoneNumber);
            }

            foreach (DataRow dRow in dtPhoneTypes.Rows)
            {
                cPhoneType NewPhoneNumber = new cPhoneType();
                NewPhoneNumber.PhoneTypeID = dRow["PhoneTypeID"].ToString().ToInt32();
                NewPhoneNumber.PhoneType   = dRow["PhoneType"].ToString();
                PhoneTypes.Add(NewPhoneNumber);
            }

            PhoneTypeID = 0;
        }
Exemplo n.º 2
0
        public cPhone(Int32 intPhoneNumberID, Int32 intUserID, string strUserName)
        {
            MethodBase lmth          = MethodBase.GetCurrentMethod(); // this is where we use refelection to store the name of the method and class to use it to report errors
            string     lsRoutineName = lmth.DeclaringType + "." + lmth.Name;

            _PhoneNumberID = intPhoneNumberID;
            _UserID        = intUserID;
            _UserName      = strUserName;
            try
            {
                SortedList slParams = new SortedList(); // I use a sortedlist  wich is a C# hash table to store the paramter and value
                slParams.Add("@intPhoneNumberID", _PhoneNumberID);
                DataSet lds = cUtilities.LoadDataSet("uspGetPhoneNumber", slParams, "LARPortal", _UserName, lsRoutineName);
                if (lds.Tables[0].Rows.Count > 0)
                {
                    DataRow dRow = lds.Tables[0].Rows[0];
                    _PhoneTypeID = dRow["PhoneTypeID"].ToString().Trim().ToInt32();
                    if (dRow["PrimaryPhone"] != null)
                    {
                        IsPrimary = (bool)dRow["PrimaryPhone"];
                    }

                    _PhoneTypeDescription = dRow["PhoneType"].ToString();
                    _IDD         = dRow["IDD"].ToString();
                    _CountryCode = dRow["CountryCode"].ToString();
                    _AreaCode    = dRow["AreaCode"].ToString();
                    _PhoneNumber = dRow["PhoneNumber"].ToString();
                    _Extension   = dRow["Extension"].ToString();
                    _Comments    = dRow["Comments"].ToString();
                    int iTemp;
                    if (int.TryParse(dRow["ProviderID"].ToString(), out iTemp))
                    {
                        _ProviderID = iTemp;
                    }
                    else
                    {
                        _ProviderID = null;
                    }
                }
                if (lds.Tables.Count > 1)
                {
                    PhoneTypes = new List <cPhoneType>();
                    foreach (DataRow dRow in lds.Tables[1].Rows)
                    {
                        cPhoneType NewPhoneNumber = new cPhoneType();
                        NewPhoneNumber.PhoneTypeID = dRow["PhoneTypeID"].ToString().ToInt32();
                        NewPhoneNumber.PhoneType   = dRow["PhoneType"].ToString();
                        PhoneTypes.Add(NewPhoneNumber);
                    }
                }
                if (lds.Tables.Count > 2)
                {
                    ProviderList = new List <cPhoneProvider>();
                    foreach (DataRow dRow in lds.Tables[2].Rows)
                    {
                        cPhoneProvider Prov = new cPhoneProvider();
                        Prov.ProviderGateway = dRow["ProviderGateway"].ToString();
                        Prov.ProviderName    = dRow["ProviderName"].ToString();
                        int iTemp;
                        if (int.TryParse(dRow["PhoneProviderID"].ToString(), out iTemp))
                        {
                            Prov.PhoneProviderID = iTemp;
                        }
                        ProviderList.Add(Prov);
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorAtServer lobjError = new ErrorAtServer();
                lobjError.ProcessError(ex, lsRoutineName, _UserName + lsRoutineName);
            }
        }
Exemplo n.º 3
0
        private void LoadPhones(DataTable dtPhoneNumbers, DataTable dtPhoneTypes, DataTable dtPhoneProviders)
        {
            MethodBase lmth          = MethodBase.GetCurrentMethod();
            string     lsRoutineName = lmth.DeclaringType + "." + lmth.Name;

            List <cPhoneType> PhoneTypes = new List <cPhoneType>();

            foreach (DataRow dRow in dtPhoneTypes.Rows)
            {
                cPhoneType NewType = new cPhoneType();
                NewType.PhoneType = dRow["PhoneType"].ToString();
                int iTemp;
                if (int.TryParse(dRow["PhoneTypeID"].ToString(), out iTemp))
                {
                    NewType.PhoneTypeID = iTemp;
                }
                if (int.TryParse(dRow["SortOrder"].ToString(), out iTemp))
                {
                    NewType.SortOrder = iTemp;
                }
                PhoneTypes.Add(NewType);
            }

            List <cPhoneProvider> Providers = new List <cPhoneProvider>();

            foreach (DataRow dRow in dtPhoneProviders.Rows)
            {
                cPhoneProvider NewProv = new cPhoneProvider();
                NewProv.ProviderGateway = dRow["ProviderGateway"].ToString();
                NewProv.ProviderName    = dRow["ProviderName"].ToString();
                int iTemp;
                if (int.TryParse(dRow["PhoneProviderID"].ToString(), out iTemp))
                {
                    NewProv.PhoneProviderID = iTemp;
                }
                if (int.TryParse(dRow["SortOrder"].ToString(), out iTemp))
                {
                    NewProv.SortOrder = iTemp;
                }
                Providers.Add(NewProv);
            }

            UserPhones = new List <cPhone>();

            foreach (DataRow dRow in dtPhoneNumbers.Rows)
            {
                cPhone NewPhone = new cPhone
                {
                    IDD         = dRow["IDD"].ToString(),
                    CountryCode = dRow["CountryCode"].ToString(),
                    AreaCode    = dRow["AreaCode"].ToString(),
                    PhoneNumber = dRow["PhoneNumber"].ToString(),
                    Extension   = dRow["Extension"].ToString(),
                    Comments    = dRow["Comments"].ToString()
                };

                NewPhone.PhoneTypes   = PhoneTypes;
                NewPhone.ProviderList = Providers;

                int iTemp;
                if (int.TryParse(dRow["PhoneNumberID"].ToString(), out iTemp))
                {
                    NewPhone.PhoneNumberID = iTemp;
                }
                if (int.TryParse(dRow["PhoneTypeID"].ToString(), out iTemp))
                {
                    NewPhone.PhoneTypeID = iTemp;
                }
                if (int.TryParse(dRow ["ProviderID"].ToString(), out iTemp))
                {
                    NewPhone.ProviderID = iTemp;
                }
                bool bTemp;
                NewPhone.IsPrimary = false;
                if (bool.TryParse(dRow["PrimaryPhone"].ToString(), out bTemp))
                {
                    if (bTemp)
                    {
                        NewPhone.IsPrimary   = true;
                        PrimaryPhone         = NewPhone;
                        PrimaryPhoneNumberID = NewPhone.PhoneNumberID;
                    }
                }
                UserPhones.Add(NewPhone);
            }
        }