예제 #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
     }
 }
예제 #2
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
            }
        }