Exemplo n.º 1
0
Arquivo: BLL.cs Projeto: 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));
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 9
0
 public bool UpdateContact(ContactDTO contact)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 10
0
 public string CreateContact(ContactDTO contact)
 {
     contacts.Add(contact);
     return(contact.Id);
 }
Exemplo n.º 11
0
Arquivo: BLL.cs Projeto: diable201/ICT
 public bool UpdateContact(ContactDTO contact)
 {
     return(dal.UpdateContact(contact));
 }