Пример #1
0
        private void BtnImport2_Click(object sender, EventArgs e)
        {
            var db = new AppG2Context();

            foreach (Contact ct in listContact)
            {
                var result = db.ContactDbset.SingleOrDefault(a => a.phoneContact.Equals(ct.phoneContact));
                if (result != null)
                {
                    result.nameContact  = ct.nameContact;
                    result.phoneContact = ct.phoneContact;
                    result.emailContact = ct.emailContact;
                    db.SaveChanges();
                }
                else
                {
                    var cre = db.ContactDbset.Create();
                    cre.iDContact    = Guid.NewGuid().ToString();
                    cre.nameContact  = ct.nameContact;
                    cre.phoneContact = ct.phoneContact;
                    cre.emailContact = ct.emailContact;
                    cre.userName     = userName;
                    db.ContactDbset.Add(cre);
                    db.SaveChanges();
                }
            }
            this.Hide();
            frmContacts frmContacts = new frmContacts(userName);

            frmContacts.ShowDialog();
            this.Close();
        }
Пример #2
0
 private void BtnLogin_Click(object sender, EventArgs e)
 {
     if (UserService.checkUser(txtUserName.Text, txtPassword.Text) != null)
     {
         frmContacts frmContacts = new frmContacts(txtUserName.Text);
         this.Hide();
         frmContacts.ShowDialog();
         this.Close();
     }
     else
     {
         MessageBox.Show("Sai tên tài khoản hoặc mật khẩu");
     }
 }