예제 #1
0
파일: BLL.cs 프로젝트: diable201/ICT
        public string CreateContact(CreateContactCommand contact)
        {
            ContactDTO contact1 = new ContactDTO();

            contact1.Id      = Guid.NewGuid().ToString();
            contact1.Name    = contact.Name;
            contact1.Address = contact.Address;
            contact1.Phone   = contact.Phone;
            return(dal.CreateContact(contact1));
        }
예제 #2
0
        public bool DelecteContactById(string id)
        {
            ContactDTO contact = contacts.Find(x => x.Id == id);

            if (contact != null)
            {
                contacts.Remove(contact);
                return(true);
            }
            return(false);
        }
예제 #3
0
        public string CreateContact(ContactDTO contact)
        {
            string text = string.Format("INSERT INTO contacts(id, name, phone, address) VALUES('{0}', '{1}', '{2}', '{3}')"
                                        , contact.Id,
                                        contact.Name,
                                        contact.Phone,
                                        contact.Addr);

            ExecuteNonQuery(text);
            return(contact.Id);
        }
예제 #4
0
        private void UpdateContact(object sender, EventArgs e)
        {
            int        row     = Convert.ToInt32(bindingNavigatorPositionItem.Text) - 1;
            var        text    = dataGridView1.Rows[row];
            ContactDTO contact = new ContactDTO();

            contact.Id      = text.Cells[0].Value.ToString();
            contact.Name    = text.Cells[1].Value.ToString();
            contact.Phone   = text.Cells[2].Value.ToString();
            contact.Address = text.Cells[3].Value.ToString();
            bll.UpdateContact(contact);
        }
예제 #5
0
        public string CreateContact(ContactDTO contact)
        {
            var text = string.Format("INSERT INTO contacts(id, name, phone, address) " +
                                     "VALUES('{0}', '{1}', '{2}', '{3}');",
                                     contact.Id,
                                     contact.Name,
                                     contact.Phone,
                                     contact.Address);

            ExecuteNonQuery(text);
            MessageBox.Show("Contact Created!");
            return(contact.Id);
        }
예제 #6
0
        public bool UpdateContact(ContactDTO contact)
        {
            var command = string.Format("UPDATE contacts SET id = " +
                                        "\"{0}\", name = \"{1}\", " +
                                        "phone = \"{2}\", " +
                                        "address = \"{3}\"  " +
                                        "WHERE id = \"{0}\"",
                                        contact.Id,
                                        contact.Name,
                                        contact.Phone,
                                        contact.Address);

            ExecuteNonQuery(command);
            MessageBox.Show("Update of contact with id:" + contact.Id);
            return(true);
        }
예제 #7
0
        public List <ContactDTO> GetContacts(string selectSQL)
        {
            List <ContactDTO> res = new List <ContactDTO>();

            using (SQLiteCommand command = new SQLiteCommand(selectSQL, connection))
            {
                var reader = command.ExecuteReader();
                while (reader.Read())
                {
                    var item = new ContactDTO
                    {
                        Id      = reader.GetString(0),
                        Name    = reader.GetString(1),
                        Phone   = reader.GetString(2),
                        Address = reader.GetString(3)
                    };
                    res.Add(item);
                }
            }
            return(res);
        }
예제 #8
0
        public List <ContactDTO> GetAllContacts()
        {
            List <ContactDTO> res = new List <ContactDTO>();

            string selectSql = @"select * from contacts";

            using (SQLiteCommand command = new SQLiteCommand(selectSql, con))
            {
                var reader = command.ExecuteReader();
                while (reader.Read())
                {
                    var item = new ContactDTO
                    {
                        Id    = reader.GetString(0),
                        Name  = reader.GetString(1),
                        Phone = reader.GetString(2),
                        Addr  = reader.GetString(3)
                    };

                    res.Add(item);
                }
            }
            return(res);
        }
예제 #9
0
 public bool UpdateContact(ContactDTO contact)
 {
     throw new NotImplementedException();
 }
예제 #10
0
 public string CreateContact(ContactDTO contact)
 {
     contacts.Add(contact);
     return(contact.Id);
 }
예제 #11
0
파일: BLL.cs 프로젝트: diable201/ICT
 public bool UpdateContact(ContactDTO contact)
 {
     return(dal.UpdateContact(contact));
 }