Beispiel #1
0
        static void PlayWithContact()  //PlayWithContact static because Main is static so it must exist when Main runs
        {
            var ch = new ContactHelper <Person>();

            ch.Add(new Person());

            // Console.WriteLine("\nEntering a new person:");
            // Person p = Person.EnterPersonInfo();
            // ch.Add(p);

            Company c = new Company("Revature");

            ch.Add(c);

            Console.WriteLine("\nEnter a new Company name: ");
            string name = Console.ReadLine();
            var    cc   = new Company(name);

            ch.Add(cc);

            Console.WriteLine("\n\nPrinting out all Persons.");
            foreach (var item in ch.Read())  // Iterates to completion, some people call it the "exhaustive loop"
            {
                System.Console.WriteLine(item);
            }
            Console.WriteLine("\n\n");
            ch.WriteToText();
            ch.WriteToXml();

            Person p3 = ch.ReadPersonFromTxt();

            Console.WriteLine(p3);

            Person p4 = ch.ReadFromXml();

            Console.WriteLine(p4);

            //Person p2 = Person.ReadPersonFromTxt();

            Console.WriteLine("Before Delete: {0}", ch.Size());
            ch.Delete();
            Console.WriteLine("After Delete: {0}", ch.Size());



            // for (int a = 0; a < length; a += 1)   // For each is pretty much same as for
            // {
            //     list[a];
            // }
            // for (;;)  //can
            // {
            // }
            // while(true)
            // {
            // }
        }
Beispiel #2
0
 /// <summary>
 /// Delete items one by one.
 /// </summary>
 private void DeleteItems()
 {
     while (!DataHelper.DataSourceIsEmpty(ds))
     {
         // Delete the contacts
         foreach (DataRow dr in ds.Tables[0].Rows)
         {
             var ci = new ContactInfo(dr);
             AddLog((ci.ContactLastName + " " + ci.ContactFirstName).Trim());
             ContactHelper.Delete(ci, chkChildren.Checked, chkMoveRelations.Checked);
         }
         ds = ContactInfoProvider.GetContacts(WhereCondition, "ContactLastName", 500, null);
     }
 }
Beispiel #3
0
    /// <summary>
    /// Delete items one by one.
    /// </summary>
    private void DeleteItems()
    {
        var connectionString = new SqlConnectionStringBuilder(ConnectionHelper.GetConnection().DataConnection.ConnectionString);

        connectionString.ConnectTimeout = SQL_TIMEOUT;

        while (!DataHelper.DataSourceIsEmpty(ds))
        {
            using (new CMSConnectionScope(connectionString.ToString(), true))
            {
                // Delete the contacts
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    var ci = new ContactInfo(dr);
                    AddLog((ci.ContactLastName + " " + ci.ContactFirstName).Trim());
                    ContactHelper.Delete(ci, chkChildren.Checked, chkMoveRelations.Checked);
                }
            }
            ds = ContactInfoProvider.GetContacts(WhereCondition, "ContactLastName", 500, null);
        }
    }