예제 #1
0
 //Элемент меню - создание карточки
 public static Card NewCard()
 {
     var card = new Card();
     Console.WriteLine("Введите id карточки");
     card.SetId(Convert.ToInt64(Console.ReadLine()));
     Console.WriteLine("Введите название");
     card.SetName(Console.ReadLine());
     Console.WriteLine("Введите SynCode ");
     card.SetSynCode(Convert.ToInt64(Console.ReadLine()));
     return card;
 }
예제 #2
0
 partial void DeleteCard(Card instance);
예제 #3
0
 partial void UpdateCard(Card instance);
예제 #4
0
 partial void InsertCard(Card instance);
예제 #5
0
 /// <summary>
 /// (Лекция 5.2) Клонирует две карточки. 
 /// </summary>
 public object Clone()
 {
     var newCard = new Card();
     newCard.Name = (string)this.Name.Clone();
     newCard.Id = this.Id;
     newCard.SynCode = this.SynCode;
     foreach (var contact in ContactsList)
     {
         newCard.ContactsList.Add((Contact)contact.Clone());
     }
     return newCard;
 }
예제 #6
0
		private void detach_Cards(Card entity)
		{
			this.SendPropertyChanging();
			entity.CardType1 = null;
		}
예제 #7
0
		private void attach_Cards(Card entity)
		{
			this.SendPropertyChanging();
			entity.CardType1 = this;
		}
예제 #8
0
        public void RunCardApp()
        {
            //для клонирования
            var card1 = new Card("23", 23423, 1);
            card1.AddContact(new EmailContact("123", "2342"));
            var card2 = (Card)card1.Clone();
            card1.ContactsList[0].Name = "2345";
            Console.WriteLine(card1.Print());
            Console.WriteLine(card2.Print());
            var cardList = new List<Card>();
            long id = 0;

            //основное меню
            var card = new Card();
            while (true)
            {
                Console.WriteLine(
                    "Выберите действие:\n0 - Создание новой карточки\n1 - Добавление контакта  карточку\n2 - Вывод списка контактов на экран\n3 - Удаление выбранного контакта\n4 - Вывод информации о карточки в Xml\n5 - Выход");
                try
                {
                    var cardNumber = 0;
                    switch (Convert.ToInt32(Console.ReadLine()))
                    {
                        case 0:
                            cardList.Add(NewCard());
                            break;

                        case 1:
                            cardNumber = GetCardNumber(cardList);
                            cardList[cardNumber].AddContact(NewContact());
                            break;
                        case 2:
                            cardNumber = GetCardNumber(cardList);
                            Console.WriteLine(cardList[cardNumber].Print());
                            break;
                        case 3:
                            cardNumber = GetCardNumber(cardList);
                            Console.WriteLine("Введите контакт для удаления ");

                            if (cardList[cardNumber].DelContact(Console.ReadLine()) == false)
                                Console.WriteLine("Такого контакта нет в списке");
                            break;
                        case 4:
                            cardNumber = GetCardNumber(cardList);
                            Console.WriteLine(cardList[cardNumber].ToXml());
                            break;

                        case 5: return;
                        default:
                            Console.WriteLine("\nТакой команды нет в списке\n");
                            break;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);

                }
            }
            Console.ReadKey();
        }
예제 #9
0
        public void Lecture6_1()
        {
            var card = new Card();
            var contactsList = card.ContactsList;

            var contact1 = new PhoneContact("Ivan", "383" + "." + "3963222");
            card.AddContact(contact1);
            var contact2 = new PhoneContact("Mary", "913" + "." + "1233211");
            card.AddContact(contact2);
            var contact3 = new EmailContact("Ars", "*****@*****.**");
            card.AddContact(contact3);

            const string path = "contacts.txt";

            StreamWriter sw = new StreamWriter(path);
            foreach (Contact item in contactsList)
            {
                sw.WriteLine(item.ToString());
            }

            sw.Close();

            using (StreamReader sr = new StreamReader(path))
            {
                String line = sr.ReadToEnd();
                Console.WriteLine(line);
                sr.Close();
            }

            Console.ReadKey();
        }
예제 #10
0
 private void UpdateCard(Card c)
 {
     SqlConnection.Instance.Connection.Open();
     MySqlCommand command = new MySqlCommand();
     command.Connection = SqlConnection.Instance.Connection;
     command.Parameters.AddWithValue("?ID", c.Id);
     command.Parameters.AddWithValue("?NAME", c.Name);
     command.Parameters.AddWithValue("?DESC", c.Desc);
     command.Parameters.AddWithValue("?ID_BOARD", c.IdBoard);
     command.Parameters.AddWithValue("?ID_LIST", c.IdList);
     command.Parameters.AddWithValue("?DATE", c.DueDate);
     command.CommandText = "UPDATE `CARDS` SET `NAME`=?NAME,`DESC`=?DESC,`ID_BOARD`=?ID_BOARD,`ID_LIST`=?ID_LIST,`DATE`=?DATE WHERE TRELLO_ID=?ID";
     command.ExecuteNonQuery();
     SqlConnection.Instance.Connection.Close();
 }
예제 #11
0
 private void AddCard(Card c)
 {
     SqlConnection.Instance.Connection.Open();
     MySqlCommand command = new MySqlCommand();
     command.Connection = SqlConnection.Instance.Connection;
     command.Parameters.AddWithValue("?ID", c.Id);
     command.Parameters.AddWithValue("?NAME", c.Name);
     command.Parameters.AddWithValue("?DESC", c.Desc);
     command.Parameters.AddWithValue("?ID_BOARD", c.IdBoard);
     command.Parameters.AddWithValue("?ID_LIST", c.IdList);
     command.Parameters.AddWithValue("?DATE", c.DueDate);
     command.CommandText = "INSERT INTO CARDS VALUES(?ID, ?NAME, ?DESC, ?ID_BOARD, ?ID_LIST, ?DATE)";
     command.ExecuteNonQuery();
     SqlConnection.Instance.Connection.Close();
 }