Esempio n. 1
0
        private void Button2_Click(object sender, EventArgs e)
        {
            // save vào database
            String FullName, Phone, Email, IdUser;

            DataTable dtItem = (DataTable)(dgItems.DataSource);

            foreach (DataRow dr in dtItem.Rows)
            {
                ContactModel ctselect = new ContactModel();

                FullName = Convert.ToString(dr["FullName"]);
                Phone    = Convert.ToString(dr["Phone"]);
                Email    = Convert.ToString(dr["Email"]);



                var db = new ContactsContext();
                if (FullName != null && Phone != null && Email != null && FullName != "" && Phone != "" && Email != "")
                {
                    ctselect.FullName = FullName;
                    ctselect.Phone    = int.Parse(Phone);
                    ctselect.Email    = Email;
                    ctselect.IdUser   = frmContact.idUser;
                    ContactController.CheckImp(ctselect);
                }
            }
            MessageBox.Show("Đã Lưu vào DataBase !!");
            dgItems.DataSource       = null;
            dataGridView1.DataSource = dgItems;
            frmContact.Update_tableContact();
        }
Esempio n. 2
0
        private void Button1_Click(object sender, EventArgs e)
        {
            String name  = txtten.Text;
            String phone = txtsdt.Text;
            String email = txtemail.Text;

            if (name != null || phone != null || email != null)
            {
                ContactModel contact = new ContactModel();
                contact.FullName  = name;
                contact.Phone     = int.Parse(phone);
                contact.Email     = email;
                contact.IdContact = int.Parse(frmContact1.idContact);

                ContactController.updateContactDb(contact);
                MessageBox.Show("Sửa thành công: " + contact.FullName);
                frmContact1.Update_tableContact();
            }
            this.Close();
        }
        private void Button1_Click(object sender, EventArgs e)
        {
            name  = txtten.Text;
            phone = txtsdt.Text;
            email = txtemail.Text;

            if (name != null || phone != null || email != null)
            {
                ContactModel contact = new ContactModel();
                contact.FullName = name;
                contact.Phone    = int.Parse(phone);
                contact.Email    = email;
                contact.IdUser   = frmContact1.idUser;
                //ContactController.addContact(contact, frmContact1.path);
                ContactController.addContactDb(contact, frmContact1.idUser);
                MessageBox.Show("Thêm Thành Công: " + contact.FullName);
                frmContact1.Update_tableContact();
            }
            this.Close();
        }