示例#1
1
        public Customer getCustomer(String customerId)
        {
            eConnectMethods eConnect = new eConnectMethods();
            String address1 = "";
            String address2 = "";
            Customer result = new Customer();
            result.CustomerID = customerId;
            try
            {

                eConnectType myEConnectType = new eConnectType();
                RQeConnectOutType myReqType = new RQeConnectOutType();
                eConnectOut myeConnectOut = new eConnectOut();
                myeConnectOut.ACTION = 1;
                myeConnectOut.DOCTYPE = "Customer";
                myeConnectOut.OUTPUTTYPE = 2;
                myeConnectOut.INDEX1FROM = customerId;
                myeConnectOut.INDEX1TO = customerId;
                myeConnectOut.FORLIST = 1;
                // Add the eConnectOut XML node object to the RQeConnectOutType schema object
                myReqType.eConnectOut = myeConnectOut;

                // Add the RQeConnectOutType schema object to the eConnect document object
                RQeConnectOutType[] myReqOutType = { myReqType };
                myEConnectType.RQeConnectOutType = myReqOutType;

                // Serialize the eConnect document object to a memory stream
                MemoryStream myMemStream = new MemoryStream();
                XmlSerializer mySerializer = new XmlSerializer(myEConnectType.GetType());
                mySerializer.Serialize(myMemStream, myEConnectType);
                myMemStream.Position = 0;

                // Load the serialized eConnect document object into an XML document object
                XmlTextReader xmlreader = new XmlTextReader(myMemStream);
                XmlDocument myXmlDocument = new XmlDocument();
                myXmlDocument.Load(xmlreader);

                // Call the eConnect_Requester method of the eConnectMethods object to retrieve specified XML data
                string reqDoc = eConnect.eConnect_Requester(sConnectionString, EnumTypes.ConnectionStringType.SqlClient, myXmlDocument.OuterXml);
                XmlDocument resultDocument = new XmlDocument();
                resultDocument.LoadXml(reqDoc);

                XmlNodeList customerNodeList = resultDocument.GetElementsByTagName("Customer");

                if (customerNodeList.Count == 0) return null;
                else
                {
                    //Here we have retrieved the customer document
                    foreach (XmlNode node in customerNodeList[0])
                    {
                        if (node.Name.Equals("ADDRESS1"))
                            address1 = node.InnerText;
                        if (node.Name.Equals("ADDRESS2"))
                            address2 = node.InnerText;
                        else if (node.Name.Equals("ADRSCODE"))
                            result.CustomerAddress.AddressCode = node.InnerText;
                        else if (node.Name.Equals("CITY"))
                            result.CustomerAddress.City = node.InnerText;
                        else if (node.Name.Equals("CNTCPRSN"))
                            result.CustomerAddress.AddressContact = node.InnerText;
                        else if (node.Name.Equals("COUNTRY"))
                            result.CustomerAddress.Country = node.InnerText;
                        else if (node.Name.Equals("CUSTCLAS"))
                            result.CustomerClass = node.InnerText;
                        else if (node.Name.Equals("CUSTNAME"))
                            result.CustomerName = node.InnerText;
                        else if (node.Name.Equals("PHONE1"))
                            result.CustomerAddress.PhoneNumber1 = node.InnerText;
                        else if (node.Name.Equals("PHONE2"))
                            result.CustomerAddress.PhoneNumber2 = node.InnerText;
                        else if (node.Name.Equals("FAX"))
                            result.CustomerAddress.FaxNumber = node.InnerText;
                        else if (node.Name.Equals("STATE"))
                            result.CustomerAddress.State = node.InnerText;
                        else if (node.Name.Equals("ZIP"))
                            result.CustomerAddress.Zipcode = node.InnerText;
                        else if (node.Name.Equals("STMTNAME"))
                            result.StatementName = node.InnerText;
                        else if (node.Name.Equals("SHRTNAME"))
                            result.ShortName = node.InnerText;
                        else if (node.Name.Equals("PRBTADCD"))
                            result.BillTo = node.InnerText;
                        else if (node.Name.Equals("PRSTADCD"))
                            result.ShipTo = node.InnerText;
                        else if (node.Name.Equals("STADDRCD"))
                            result.StatementTo = node.InnerText;
                        else if (node.Name.Equals("USERDEF1"))
                            result.Type = node.InnerText;
                        else if (node.Name.Equals("USERDEF2"))
                            result.StudentStatus = node.InnerText;
                        else if (node.Name.Equals("INACTIVE"))
                            if (node.InnerText.Equals("1")) result.Inactive = true;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            result.CustomerAddress.AddressString = address1 + address2;
            return result;
        }
示例#2
0
 public bool saveCustomer(Customer c)
 {
     bool result = true;
     result = EConnectData.getInstance().createOrUpdateCustomer(c);
     result = SQLData.getInstance().saveOrUpdate(c);
     return result;
 }
示例#3
0
        /*This SQL statement uses one SQL query to get a customer as long as they are in
         the Constants.STUDENTCLASSES string array
         */
        public List<Customer> getAllCustomers()
        {
            /* Queries that can be used
             * SELECT CUSTNMBR, CUSTNAME FROM RM00101
            SELECT * FROM RM00101 WHERE INACTIVE=0 AND CUSTCLAS='STUDENTS'*/

            /* Build the WHERE section using IN (Student classes)*/
            String studentClasses = "(";
            for (int i = 0; i < Constants.STUDENTCLASSES.Length; i++)
            {
                if (i != 0) studentClasses += ",";
                studentClasses += "'" + Constants.STUDENTCLASSES[i] + "'";
            }
            studentClasses += ")";
            /*This comes out with (STUDENT,IB,COLLEGE) etc */
            List<Customer> result = null;

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                String sqlGetAllCustomers = "SELECT CUSTNMBR, CUSTNAME, CUSTCLAS, USERDEF1, USERDEF2, STMTNAME, ADDRESS1, CITY, PHONE1, PHONE2  FROM RM00101 WHERE CUSTCLAS IN " + studentClasses + " ORDER BY CUSTNAME";
                result = new List<Customer>();
                SqlDataReader reader = null;

                try
                {
                    SqlCommand cmd = new SqlCommand(sqlGetAllCustomers, connection);
                    reader = null;
                    reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        Customer c = new Customer();
                        c.CustomerID = reader["CUSTNMBR"].ToString().Trim();
                        c.CustomerName = reader["CUSTNAME"].ToString().Trim();
                        c.CustomerClass = reader["CUSTCLAS"].ToString().Trim();
                        c.Type = reader["USERDEF1"].ToString().Trim();
                        c.StudentStatus = reader["USERDEF2"].ToString().Trim();
                        c.BillTo = reader["STMTNAME"].ToString().Trim();
                        c.CustomerAddress.AddressString = reader["ADDRESS1"].ToString().Trim() + " " + reader["CITY"].ToString().Trim();
                        c.CustomerAddress.PhoneNumber1 = reader["PHONE1"].ToString().Trim();
                        c.CustomerAddress.PhoneNumber2 = reader["PHONE2"].ToString().Trim();
                        result.Add(c);
                    }
                }
                catch (Exception e)
                {
                    System.Windows.Forms.MessageBox.Show(e.Message);
                }
                finally
                {
                    reader.Close();
                }
            }

            return result;
        }
示例#4
0
        public bool createOrUpdateCustomer(Customer c)
        {
            bool status = false;
            if ((c.CustomerName == null) || (c.CustomerID == null) || (c.CustomerClass == null)) return false;
            eConnectMethods eConnect = new eConnectMethods();
            try
            {
                StringBuilder xml = new StringBuilder();
                xml.Append("<eConnect>");
                xml.Append("<RMCustomerMasterType>");
                xml.Append("<taUpdateCreateCustomerRcd>");
                xml.Append("<CUSTNMBR><![CDATA[" + c.CustomerID + "]]></CUSTNMBR>");
                xml.Append("<CUSTNAME><![CDATA[" + c.CustomerName + "]]></CUSTNAME>");
                xml.Append("<CUSTCLAS><![CDATA[" + c.CustomerClass + "]]></CUSTCLAS>");
                xml.Append("<INACTIVE><![CDATA[" + c.Inactive.GetHashCode() + "]]></INACTIVE>");

                if (c.ShortName != null) xml.Append("<SHRTNAME><![CDATA[" + c.ShortName + "]]></SHRTNAME>");
                if (c.StatementName != null) xml.Append("<STMTNAME><![CDATA[" + c.StatementName + "]]></STMTNAME>");
                if (c.ShipTo != null) xml.Append("<PRSTADCD><![CDATA[" + c.ShipTo + "]]></PRSTADCD>");
                if (c.StatementTo != null) xml.Append("<STADDRCD><![CDATA[" + c.StatementTo + "]]></<STADDRCD>");
                if (c.BillTo != null) xml.Append("<PRBTADCD><![CDATA[" + c.BillTo + "]]></PRBTADCD>");
                if (c.Type != null) xml.Append("<USERDEF1><![CDATA[" + c.Type + "]]></USERDEF1>");
                if (c.StudentStatus != null) xml.Append("<USERDEF2><![CDATA[" + c.StudentStatus + "]]></USERDEF2>");

            /*
             *  This data is part of the address
             */
                if (c.CustomerAddress.AddressString != null)
                {
                    if (c.CustomerAddress.AddressString.Length < 50)
                    {
                        xml.Append("<ADDRESS1><![CDATA[" + c.CustomerAddress.AddressString + "]]></ADDRESS1>");
                    }
                    else
                    {
                        xml.Append("<ADDRESS1><![CDATA[" + c.CustomerAddress.AddressString.Substring(0, 50) + "]]></ADDRESS1>");
                        xml.Append("<ADDRESS2><![CDATA[" + c.CustomerAddress.AddressString.Substring(50, c.CustomerAddress.AddressString.Length - 50) + "]]></ADDRESS2>");
                    }
                }
                if (c.CustomerAddress.AddressCode != null) xml.Append("<ADRSCODE><![CDATA[" + c.CustomerAddress.AddressCode + "]]></ADRSCODE>");
                if (c.CustomerAddress.AddressContact != null) xml.Append("<CNTCPRSN><![CDATA[" + c.CustomerAddress.AddressContact + "]]></CNTCPRSN>");
                if (c.CustomerAddress.City != null) xml.Append("<CITY><![CDATA[" + c.CustomerAddress.City + "]]></CITY>");
                if (c.CustomerAddress.State != null) xml.Append("<STATE><![CDATA[" + c.CustomerAddress.State + "]]></STATE>");
                if (c.CustomerAddress.Country != null) xml.Append("<COUNTRY><![CDATA[" + c.CustomerAddress.Country + "]]></COUNTRY>");
                if (c.CustomerAddress.Zipcode != null) xml.Append("<ZIPCODE><![CDATA[" + c.CustomerAddress.Zipcode + "]]></ZIPCODE>");
                if (c.CustomerAddress.PhoneNumber1 != null) xml.Append("<PHNUMBR1><![CDATA[" + c.CustomerAddress.PhoneNumber1 + "]]></PHNUMBR1>");
                if (c.CustomerAddress.PhoneNumber2 != null) xml.Append("<PHNUMBR2><![CDATA[" + c.CustomerAddress.PhoneNumber2 + "]]></PHNUMBR2>");
                if (c.CustomerAddress.FaxNumber != null) xml.Append("<FAX><![CDATA[" + c.CustomerAddress.FaxNumber + "]]></FAX>");
                //CAUSES ERRORS IF COUNTRYCODE DOESNT EXIST
                //if (c.CustomerAddress.CountryCode != null) xml.Append("<CCODE>" + c.CustomerAddress.CountryCode + "</CCODE>");

                xml.Append("<UseCustomerClass>1</UseCustomerClass>");
                xml.Append("<UpdateIfExists>1</UpdateIfExists>");
                xml.Append("</taUpdateCreateCustomerRcd>");
                xml.Append("</RMCustomerMasterType>");
                xml.Append("</eConnect>");

                status = eConnect.eConnect_EntryPoint(sConnectionString, EnumTypes.ConnectionStringType.SqlClient,
                    xml.ToString(), EnumTypes.SchemaValidationType.None, "");
            }
            catch (eConnectException ex)
            {
                Console.WriteLine(ex.ToString());
            }
            return status;
        }
示例#5
0
文件: Main.cs 项目: orette/southville
 private void loadCustomer(Customer c)
 {
     firstnameTextbox.Text = c.FirstName;
     middlenameTextbox.Text = c.MiddleName;
     lastnameTextbox.Text = c.LastName;
     emailTextbox.Text = c.EmailAddress;
     nicknameTextbox.Text = c.ShortName;
     inactiveCheckbox.Checked = c.Inactive;
     if (c.Birthday != null && !(c.Birthday.Equals(defaultDateTime))) birthdayDatetimePicker.Value = Convert.ToDateTime(c.Birthday);
     if (c.LastEnrolledDate != null && !(c.LastEnrolledDate.Equals(defaultDateTime))) lastEnrolledDateTimePicker.Value = c.LastEnrolledDate;
     nationalityComboBox.Text = c.Nationality;
     levelCombobox.Text = c.Level;
     sectionTextbox.Text = c.Section;
     religionComboBox.Text = c.Religion;
     lastSchoolcb.Text = c.LastSchAttended;
     placeOfBirthTextbox.Text = c.PlaceOfBirth;
     if (c.Type != null) setComboboxValue(typeCombobox, c.Type, TYPE_COMBOBOXDEFAULT);
     if (c.Gender != null) setComboboxValue(genderCombobox, c.Gender, GENDER_COMBOBOXDEFAULT);
     if (c.OfficiallyEnrolled != null) setComboboxValue(statusCombobox, c.OfficiallyEnrolled, STATUS_COMBOBOXDEFAULT);
     if (c.StudentStatus != null) setComboboxValue(studentStatusCombobox, c.StudentStatus, STUDENTSTATUS_COMBOBOXDEFAULT);
     if (c.CustomerClass != null) setComboboxValue(classComboBox, c.CustomerClass, STUDENTCLASS_COMBOBOXDEFAULT);
     billingContactTextbox.Text = c.CustomerAddress.AddressContact;
     addressTextbox.Text = c.CustomerAddress.AddressString;
     cityTextbox.Text = c.CustomerAddress.City;
     stateTextbox.Text = c.CustomerAddress.State;
     zipcodeTextbox.Text = c.CustomerAddress.Zipcode;
     countryTextbox.Text = c.CustomerAddress.Country;
     phoneNumberTextbox.Text = c.CustomerAddress.PhoneNumber1;
     mobileNumberTextbox.Text = c.CustomerAddress.PhoneNumber2;
     faxNumberTextbox.Text = c.CustomerAddress.FaxNumber;
 }
示例#6
0
文件: Main.cs 项目: orette/southville
        private Customer getCustomer()
        {
            Customer c = new Customer();
            if ((idTextbox.Text != null) && !(idTextbox.Text.Equals("")))
                c.CustomerID = idTextbox.Text;
            if ((firstnameTextbox.Text != null) && !(firstnameTextbox.Text.Equals("")))
                c.FirstName = firstnameTextbox.Text;
            if ((middlenameTextbox.Text != null) && !(middlenameTextbox.Text.Equals("")))
                c.MiddleName = middlenameTextbox.Text;
            if ((lastnameTextbox.Text != null) && !(lastnameTextbox.Text.Equals("")))
                c.LastName = lastnameTextbox.Text;
            if ((emailTextbox.Text != null) && !(emailTextbox.Text.Equals("")))
                c.EmailAddress = emailTextbox.Text;
            if ((nicknameTextbox.Text != null) && !(nicknameTextbox.Text.Equals("")))
                c.ShortName = nicknameTextbox.Text;
            c.Inactive = inactiveCheckbox.Checked;
            c.Birthday = Convert.ToDateTime(birthdayDatetimePicker.Value);
            c.LastEnrolledDate = lastEnrolledDateTimePicker.Value;
            if ((nationalityComboBox.Text != null) && !(nationalityComboBox.Text.Equals("")))
                c.Nationality = nationalityComboBox.Text;
            if ((levelCombobox.Text != null) && !(levelCombobox.Text.Equals("")))
                c.Level = levelCombobox.Text;
            if ((sectionTextbox.Text != null) && !(sectionTextbox.Text.Equals("")))
                c.Section = sectionTextbox.Text;
            if ((religionComboBox.Text != null) && !(religionComboBox.Text.Equals("")))
                c.Religion = religionComboBox.Text;
            if ((placeOfBirthTextbox.Text != null) && !(placeOfBirthTextbox.Text.Equals("")))
                c.PlaceOfBirth = placeOfBirthTextbox.Text;
            if ((lastSchoolcb.Text != null) && !(lastSchoolcb.Text.Equals("")))
                c.LastSchAttended = lastSchoolcb.Text;
            c.Type = typeCombobox.Text;
            c.Gender = genderCombobox.Text;
            c.OfficiallyEnrolled = statusCombobox.Text;
            c.StudentStatus = studentStatusCombobox.Text;
            c.CustomerClass = classComboBox.Text;
            if ((billingContactTextbox.Text != null) && !(billingContactTextbox.Text.Equals("")))
                c.CustomerAddress.AddressContact = billingContactTextbox.Text;
            if ((addressTextbox.Text != null) && !(addressTextbox.Text.Equals("")))
                c.CustomerAddress.AddressString = addressTextbox.Text;
            if ((cityTextbox.Text != null) && !(cityTextbox.Text.Equals("")))
                c.CustomerAddress.City = cityTextbox.Text;
            if ((stateTextbox.Text != null) && !(stateTextbox.Text.Equals("")))
                c.CustomerAddress.State = stateTextbox.Text;
            if ((zipcodeTextbox.Text != null) && !(zipcodeTextbox.Text.Equals("")))
                c.CustomerAddress.Zipcode = zipcodeTextbox.Text;
            if ((countryTextbox.Text != null) && !(countryTextbox.Text.Equals("")))
                c.CustomerAddress.Country = countryTextbox.Text;
            if ((phoneNumberTextbox.Text != null) && !(phoneNumberTextbox.Text.Equals("")))
                c.CustomerAddress.PhoneNumber1 = phoneNumberTextbox.Text;
            if ((mobileNumberTextbox.Text != null) && !(mobileNumberTextbox.Text.Equals("")))
                c.CustomerAddress.PhoneNumber2 = mobileNumberTextbox.Text;
            if ((faxNumberTextbox.Text != null) && !(faxNumberTextbox.Text.Equals("")))
                c.CustomerAddress.FaxNumber = faxNumberTextbox.Text;

            return c;
        }
示例#7
0
 private List<Customer> getSelectedCustomer()
 {
     List<Customer> selectedStudents = new List<Customer>();
     foreach(DataGridViewRow dr in dataGridView1.Rows)
     {
         if (dr.Cells[0].Value != null)
         {
             Customer c = new Customer();
             c.CustomerID = dr.Cells[1].Value.ToString();
             selectedStudents.Add(c);
         }
     }
     return selectedStudents;
 }
示例#8
0
        //This transaction appends several extender sql statements into one transaction
        public bool saveOrUpdate(Customer c)
        {
            bool status = true;
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                //DONT PROCESS IF THIS IS FALSE
                if (c.OfficiallyEnrolled == null) return false;

                //Create Extender SQLString
                string sqlString = SQLData.beginExtenderTransaction(c.CustomerID);
                if (c.FirstName != null)
                    sqlString += SQLData.addExtenderString(c.FirstName, Constants.WINDOW_EXT_ID,
                        c.CustomerID, Constants.FIRSTNAME_FIELD_ID);
                if (c.MiddleName != null)
                    sqlString += SQLData.addExtenderString(c.MiddleName, Constants.WINDOW_EXT_ID,
                        c.CustomerID, Constants.MIDDLENAME_FIELD_ID);
                if (c.LastName != null)
                    sqlString += SQLData.addExtenderString(c.LastName, Constants.WINDOW_EXT_ID,
                        c.CustomerID, Constants.LASTNAME_FIELD_ID);
                if (c.EmailAddress != null)
                    sqlString += SQLData.addExtenderString(c.EmailAddress, Constants.WINDOW_EXT_ID,
                        c.CustomerID, Constants.EMAIL_FIELD_ID);
                if ((c.Birthday != null) && !(c.Birthday.Equals(new DateTime())))
                    sqlString += SQLData.addExtenderDate(Convert.ToDateTime(c.Birthday), Constants.WINDOW_EXT_ID,
                        c.CustomerID, Constants.BIRTHDAY_FIELD_ID);
                if ((c.LastEnrolledDate != null) && !(c.LastEnrolledDate.Equals(new DateTime())))
                    sqlString += SQLData.addExtenderDate(c.LastEnrolledDate, Constants.WINDOW_EXT_ID,
                        c.CustomerID, Constants.LASTENROLLEDDATE_FIELD_ID);
                if (c.OfficiallyEnrolled != null)
                    sqlString += SQLData.addExtenderString(c.OfficiallyEnrolled, Constants.WINDOW_EXT_ID,
                        c.CustomerID, Constants.ENROLLED_FIELD_ID);
                if (c.Level != null)
                    sqlString += SQLData.addExtenderString(c.Level, Constants.WINDOW_EXT_ID,
                        c.CustomerID, Constants.LEVEL_FIELD_ID);
                if (c.Section != null)
                    sqlString += SQLData.addExtenderString(c.Section, Constants.WINDOW_EXT_ID,
                        c.CustomerID, Constants.SECTION_FIELD_ID);
                if (c.Nationality != null)
                    sqlString += SQLData.addExtenderString(c.Nationality, Constants.WINDOW_EXT_ID,
                        c.CustomerID, Constants.NATIONALITY_FIELD_ID);
                if (c.LastSchAttended != null)
                    sqlString += SQLData.addExtenderString(c.LastSchAttended, Constants.WINDOW_EXT_ID,
                        c.CustomerID, Constants.LASTSCHOOL_FIELD_ID);
                if (c.Gender != null)
                    sqlString += SQLData.addExtenderString(c.Gender, Constants.WINDOW_EXT_ID,
                        c.CustomerID, Constants.GENDER_FIELD_ID);
                if (c.Religion != null)
                    sqlString += SQLData.addExtenderString(c.Religion, Constants.WINDOW_EXT_ID,
                        c.CustomerID, Constants.RELIGION_FIELD_ID);
                if (c.PlaceOfBirth != null)
                    sqlString += SQLData.addExtenderString(c.PlaceOfBirth, Constants.WINDOW_EXT_ID,
                        c.CustomerID, Constants.PLACEOFBIRTH_FIELD_ID);

                sqlString += SQLData.endExtenderTransaction();
                try
                {
                    SqlCommand cmd = new SqlCommand(sqlString, connection);
                    cmd.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    status = false;
                    Console.WriteLine(e);
                }
            }
            return status;
        }
示例#9
0
 //This is optimized to only do one SQL statement
 public Customer getCustomer(Customer c)
 {
     using (SqlConnection connection = new SqlConnection(connectionString))
     {
         connection.Open();
         if (c.CustomerID == null) return null;
         //Pre: Customer has been loaded with a customerId
         string sqlGetStrings = "SELECT STRGA255, PT_UD_Number FROM EXT00101 WHERE PT_Window_ID='" +
             Constants.WINDOW_EXT_ID + "' AND PT_UD_Key='" + c.CustomerID + "'";
         string sqlGetDates = "SELECT DATE1, PT_UD_Number FROM EXT00102 WHERE PT_Window_ID='" +
             Constants.WINDOW_EXT_ID + "' AND PT_UD_Key='" + c.CustomerID + "'";
         SqlDataReader reader = null;
         try
         {
             SqlCommand cmd = new SqlCommand(sqlGetStrings, connection);
             reader = cmd.ExecuteReader();
             while (reader.Read())
             {
                 string str_value = reader["STRGA255"].ToString().Trim();
                 string field_num = reader["PT_UD_Number"].ToString().Trim();
                 if ((str_value != null) && !(str_value.Equals("")))
                 {
                     if (field_num.Equals(Constants.FIRSTNAME_FIELD_ID))
                         c.FirstName = str_value;
                     else if (field_num.Equals(Constants.MIDDLENAME_FIELD_ID))
                         c.MiddleName = str_value;
                     else if (field_num.Equals(Constants.LASTNAME_FIELD_ID))
                         c.LastName = str_value;
                     else if (field_num.Equals(Constants.LEVEL_FIELD_ID))
                         c.Level = str_value;
                     else if (field_num.Equals(Constants.SECTION_FIELD_ID))
                         c.Section = str_value;
                     else if (field_num.Equals(Constants.NATIONALITY_FIELD_ID))
                         c.Nationality = str_value;
                     else if (field_num.Equals(Constants.ENROLLED_FIELD_ID))
                         c.OfficiallyEnrolled = str_value;
                     else if (field_num.Equals(Constants.GENDER_FIELD_ID))
                         c.Gender = str_value;
                     else if (field_num.Equals(Constants.RELIGION_FIELD_ID))
                         c.Religion = str_value;
                     else if (field_num.Equals(Constants.PLACEOFBIRTH_FIELD_ID))
                         c.PlaceOfBirth = str_value;
                     else if (field_num.Equals(Constants.EMAIL_FIELD_ID))
                         c.EmailAddress = str_value;
                     else if (field_num.Equals(Constants.LASTSCHOOL_FIELD_ID))
                         c.LastSchAttended = str_value;
                 }
             }
         }
         catch (Exception e)
         {
             Console.WriteLine(e.ToString());
         }
         finally
         {
             reader.Close();
         }
         try
         {
             SqlCommand cmd = new SqlCommand(sqlGetDates, connection);
             reader = null;
             reader = cmd.ExecuteReader();
             while (reader.Read())
             {
                 string str_value = reader["DATE1"].ToString().Trim();
                 string field_num = reader["PT_UD_Number"].ToString().Trim();
                 if ((str_value != null) && !(str_value.Equals("")))
                 {
                     if (field_num.Equals(Constants.BIRTHDAY_FIELD_ID))
                         c.Birthday = Convert.ToDateTime(str_value);
                     if (field_num.Equals(Constants.LASTENROLLEDDATE_FIELD_ID))
                         c.LastEnrolledDate = DateTime.Parse(str_value);
                 }
             }
         }
         catch (Exception e)
         {
             Console.WriteLine(e.ToString());
         }
         finally
         {
             reader.Close();
         }
     }
     return c;
 }