Beispiel #1
0
 /// <summary>
 /// addPhoneNumber - add client's phone number in database
 /// </summary>
 /// <param name="CPF">Client's CPF</param>
 /// <param name="PhoneDescription">Phone's Description</param>
 /// <param name="PhoneNumber">Phone's Number</param>
 public void addPhoneNumber(String CPF, String PhoneDescription, String PhoneNumber)
 {
     if (IsCpf(CPF) && validateString(PhoneDescription) && validateString(PhoneNumber))
     {
         if (getClient(CPF).Tables[0].Rows.Count > 0)
         {
             DataSet ds = getPhoneNumbers(CPF);
             int lastID = Convert.ToInt16(ds.Tables[0].Rows[ds.Tables[0].Rows.Count - 1]["ID"].ToString());
             int ID = lastID + 1;
             if (ID <= Int16.MaxValue)
             {
                 PhoneNumber phone = new PhoneNumber(CPF, ID, PhoneDescription, PhoneNumber);
                 phone.insertPhoneNumber();
             }
         }
         else
         {
             //Usuario Não existe
         }
     }
     else
     {
         //Dados Invalidos
     }
 }
Beispiel #2
0
 /// <summary>
 /// getPhoneNumber - get phone number from database
 /// </summary>
 /// <param name="CPF">Client's CPF</param>
 /// <param name="CPF">Phone Number ID</param>
 /// <returns>Dataset containing phone number data</returns>
 public DataSet getPhoneNumber(String CPF, int ID)
 {
     if (IsCpf(CPF))
     {
         PhoneNumber phone = new PhoneNumber(CPF, ID);
         return phone.getPhoneNumberbyID();
     }
     else
     {
         //CPF invalido
         return null;
     }
 }
Beispiel #3
0
 /// <summary>
 /// updatePhoneNumber - update client's phone number in database
 /// </summary>
 /// <param name="CPF">Client's CPF</param>
 /// <param name="ID">Phone Number's ID</param>  
 /// <param name="PhoneDescription">Phone's Description</param>
 /// <param name="PhoneNumber">Phone's Number</param>
 public void updatePhoneNumber(String CPF, int ID, String PhoneDescription, String PhoneNumber)
 {
     if (IsCpf(CPF) && ID > 0 && validateString(PhoneDescription) && validateString(PhoneNumber))
     {
         Client client = new Client(CPF);
         if (client.getClient().Tables[0].Rows.Count > 0)
         {
             PhoneNumber phone = new PhoneNumber(CPF, ID, PhoneDescription, PhoneNumber);
             phone.updatePhoneNumber();
         }
         else
         {
             //Usuário não existe
         }
     }
     else
     {
         //Dados Invalidos
     }
 }
Beispiel #4
0
        /// <summary>
        /// insertClient - insert client in database
        /// </summary>
        /// <param name="CPF">Client's CPF</param>
        /// <param name="Nome">Client's Nome</param>
        /// <param name="Email">Client's Email</param>
        /// <param name="MaritalStatus">Client's MaritalStatus</param>
        /// <param name="Country">Client's Country</param>
        /// <param name="State">Client's State</param>
        /// <param name="City">Client's City</param>
        /// <param name="Address">Client's Address</param>
        /// <param name="PhoneDescription">Client's Phone's Description</param>
        /// <param name="PhoneNumber">Client's Phone's Number</param>
        public void insertClient(String CPF, String Nome, String Email, String MaritalStatus, String Country, String State, String City, String Address, String PhoneDescription, String PhoneNumber)
        {
            //Clean CPF
            CPF = CPF.Trim();
            CPF = CPF.Replace(".", "").Replace("-", "");

            if (IsCpf(CPF) && validateString(Nome) && validateString(Email) && validateString(MaritalStatus) && validateString(Country) && validateString(State) && validateString(City) && validateString(Address) && validateString(PhoneDescription) && validateString(PhoneNumber))
            {
                Client c = new Client(CPF);
                if (c.getClient().Tables[0].Rows.Count == 0)
                {
                    Client client = new Client(CPF, Nome, Email, MaritalStatus);
                    int afectedLinesClient = client.insertClient();

                    Address address = new Address(CPF, Country, State, City, Address);
                    int afectedLinesAddess = address.insertAddress();

                    PhoneNumber phone = new PhoneNumber(CPF, 0, PhoneDescription, PhoneNumber);
                    int afectedLinesPhoneNumber = phone.insertPhoneNumber();
                }
                else
                {
                    //Usuario ja existe
                }
            }
            else
            {
                //Dados Invalidos
            }
        }
Beispiel #5
0
 /// <summary>
 /// getPhoneNumbers - get client's phone numbers from database
 /// </summary>
 /// <param name="CPF">Client's CPF</param>
 /// <returns>Dataset containing phone number(s) data</returns>
 public DataSet getPhoneNumbers(String CPF)
 {
     if (IsCpf(CPF))
     {
         PhoneNumber phone = new PhoneNumber(CPF);
         return phone.getPhoneNumbersbyClient();
     }
     else
     {
         //CPF invalido
         return null;
     }
 }