Пример #1
0
 /// <summary>
 /// getClient - get client from database
 /// </summary>
 /// <param name="CPF">Client's CPF</param>
 /// <returns>Dataset containing client data</returns>
 public DataSet getClient(String CPF)
 {
     if (IsCpf(CPF))
     {
         Client client = new Client(CPF);
         return client.getClient();
     }
     else
     {
         //CPF invalido
         return null;
     }
 }
Пример #2
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
     }
 }
Пример #3
0
 /// <summary>
 /// updateClient - update client's address in database
 /// </summary>
 /// <param name="CPF">Client's CPF</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>  
 public void updateAddress(String CPF, String Country, String State, String City, String Address)
 {
     if (IsCpf(CPF) && validateString(Country) && validateString(State) && validateString(City) && validateString(Address))
     {
         Client client = new Client(CPF);
         if(client.getClient().Tables[0].Rows.Count > 0)
         {
             Address address = new Address(CPF, Country, State, City, Address);
             address.updateAddress();
         }
         else
         {
             //Usuario não existe
         }
     }
     else
     {
         //Dados Invalidos
     }
 }
Пример #4
0
 /// <summary>
 /// updateClient - update 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 Marital Status</param>      
 public void updateClient(String CPF, String Nome, String Email, String MaritalStatus)
 {
     if (IsCpf(CPF) && validateString(Nome) && validateString(Email) && validateString(MaritalStatus))
     {
         Client client = new Client(CPF);
         if(client.getClient().Tables[0].Rows.Count > 0)
         {
             client = new Client(CPF, Nome, Email, MaritalStatus);
             int afectedLines = client.updateClient();
         }
         else
         {
             //Usuario não existe
         }
     }
     else
     {
         //Dados Invalidos
     }
 }
Пример #5
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
            }
        }