Ejemplo n.º 1
0
        //{
        //    get { return "http://maps.google.com/preview?q=" + _StrGoogleString; }
        //}

        /// <summary>
        /// Creates Empty caddress class object
        /// </summary>
        public cAddress()
        {
            AddressID = -1;

            SortedList sParams = new SortedList();

            DataTable dtAddressTypes = cUtilities.LoadDataTable("uspGetAddressTypes", sParams, "LARPortal", "", "cAddress.Creator");

            AddressTypes = new List <cAddressType>();
            if (new DataView(dtAddressTypes, "AddressTypeID = 0", "", DataViewRowState.CurrentRows).Count == 0)
            {
                cAddressType NewAddress = new cAddressType();
                NewAddress.AddressTypeID = 0;
                NewAddress.AddressType   = "Choose...";
                AddressTypes.Add(NewAddress);
            }

            foreach (DataRow dRow in dtAddressTypes.Rows)
            {
                cAddressType NewAddress = new cAddressType();
                NewAddress.AddressTypeID = dRow["AddressTypeID"].ToString().ToInt32();
                NewAddress.AddressType   = dRow["AddressType"].ToString();
                AddressTypes.Add(NewAddress);
            }

            AddressTypeID = 0;
        }
Ejemplo n.º 2
0
        private void LoadAddresses(DataTable AddressInfo, DataTable AddressType, string sLoginName)
        {
            MethodBase lmth          = MethodBase.GetCurrentMethod();
            string     lsRoutineName = lmth.DeclaringType + "." + lmth.Name;

            // First create a list of address types. This will be copied into each record.
            List <cAddressType> AddTypes = new List <cAddressType>();

            foreach (DataRow dRow in AddressType.Rows)
            {
                cAddressType NewType = new cAddressType();
                NewType.AddressType = dRow["AddressType"].ToString();
                int iTemp;
                if (int.TryParse(dRow["AddressTypeID"].ToString(), out iTemp))
                {
                    NewType.AddressTypeID = iTemp;
                }
                AddTypes.Add(NewType);
            }

            UserAddresses  = new List <cAddress>();
            PrimaryAddress = new cAddress();

            foreach (DataRow dRow in AddressInfo.Rows)
            {
                cAddress NewAdd = new cAddress();
                NewAdd.AddressTypes.AddRange(AddTypes);
                NewAdd.Address1   = dRow["Address1"].ToString();
                NewAdd.Address2   = dRow["Address2"].ToString();
                NewAdd.City       = dRow["City"].ToString();
                NewAdd.StateID    = dRow["StateID"].ToString();
                NewAdd.PostalCode = dRow["PostalCode"].ToString();
                NewAdd.Country    = dRow["Country"].ToString();
                NewAdd.UserName   = sLoginName;

                int iTemp;
                if (int.TryParse(dRow["AddressID"].ToString(), out iTemp))
                {
                    NewAdd.AddressID = iTemp;
                }
                if (int.TryParse(dRow["AddressTypeID"].ToString(), out iTemp))
                {
                    NewAdd.AddressTypeID = iTemp;
                }

                bool bTemp;
                if (bool.TryParse(dRow["PrimaryAddress"].ToString(), out bTemp))
                {
                    NewAdd.IsPrimary = true;
                    PrimaryAddress   = NewAdd;
                }
                else
                {
                    NewAdd.IsPrimary = false;
                }

                UserAddresses.Add(NewAdd);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a caddress class object from data stored in the database with the Address ID provided
        /// </summary>
        /// <param name="intAddressID">ID for Address</param>
        /// <param name="userName">User ID</param>
        ///
        public cAddress(Int32 intAddressID, string strUserNameParam, int intuserID)
        {
            UserName = strUserNameParam;
            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;


            //so lets say we wanted to load data into this class from a sql query called uspGetSomeData thats take two paraeters @Parameter1 and @Parameter2
            SortedList slParams = new SortedList(); // I use a sortedlist  wich is a C# hash table to store the paramter and value

            slParams.Add("@intAddressID", intAddressID);

            try
            {
                DataSet lds = cUtilities.LoadDataSet("uspGetAddress", slParams, "LARPortal", UserName, lsRoutineName);

                if (lds.Tables[0].Rows.Count > 0)
                {
                    DataRow dRow = lds.Tables[0].Rows[0];
                    AddressID = intAddressID;//Table MDBAddresses
                    if (dRow["Address1"] != null)
                    {
                        Address1 = dRow["Address1"].ToString();
                    }
                    if (dRow["Address2"] != null)
                    {
                        Address2 = dRow["Address2"].ToString();
                    }
                    if (dRow["City"] != null)
                    {
                        City = dRow["City"].ToString();
                    }
                    if (dRow["StateID"] != null)
                    {
                        StateID = dRow["StateID"].ToString();
                    }
                    if (dRow["AddressTypeID"] != null)
                    {
                        AddressTypeID = (Int32)dRow["AddressTypeID"];
                    }
                    if (dRow["PrimaryAddress"] != null)
                    {
                        IsPrimary = (bool)dRow["PrimaryAddress"];
                    }
                    if (dRow["PostalCode"] != null)
                    {
                        PostalCode = dRow["PostalCode"].ToString();
                    }
                    if (dRow["Country"] != null)
                    {
                        Country = dRow["Country"].ToString();
                    }
                    //if (ldt.Rows[0]["MDBStatesStateName"] != null) { _StateName = ldt.Rows[0]["MDBStatesStateName"].ToString(); } //Table Table MDBStates
                    DateTime dtTemp;
                    if (DateTime.TryParse(dRow["DateAdded"].ToString(), out dtTemp))
                    {
                        DateAdded = dtTemp;
                    }
                    if (DateTime.TryParse(dRow["DateChanged"].ToString(), out dtTemp))
                    {
                        DateChanged = dtTemp;
                    }
                    if (DateTime.TryParse(dRow["DateDeleted"].ToString(), out dtTemp))
                    {
                        DateDeleted = dtTemp;
                    }
                    GoogleString = Address1 + "+" + Address2 + "+" + City + "+" + StateID + "+" + PostalCode;
                }

                if (lds.Tables.Count > 1)
                {
                    AddressTypes = new List <cAddressType>();
                    foreach (DataRow dRow in lds.Tables[1].Rows)
                    {
                        cAddressType NewAddress = new cAddressType();
                        NewAddress.AddressTypeID = dRow["AddressTypeID"].ToString().ToInt32();
                        NewAddress.AddressType   = dRow["AddressType"].ToString();
                        AddressTypes.Add(NewAddress);
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorAtServer lobjError = new ErrorAtServer();
                lobjError.ProcessError(ex, lsRoutineName, UserName + lsRoutineName);
            }
        }