Esempio n. 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            CondominiumManagementSystemDBEntities entity = new Condominium_Management_System.CondominiumManagementSystemDBEntities();
            tblUser user = new Condominium_Management_System.tblUser();

            user.Fullname = txtFullname.Text;
            user.Username = txtUsername.Text;
            user.Password = txtPassword.Text;

            entity.tblUsers.Add(user);
            entity.SaveChanges();

            MessageBox.Show("User Saved");
        }
Esempio n. 2
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            CondominiumManagementSystemDBEntities entity = new Condominium_Management_System.CondominiumManagementSystemDBEntities();
            int userID = int.Parse(listViewUser.Items[listViewUser.SelectedIndices[0]].SubItems[0].Text);

            tblUser oldUser = entity.tblUsers.Where(x => x.ID == userID).FirstOrDefault();

            tblUser newUser = new Condominium_Management_System.tblUser();

            newUser.ID       = userID;
            newUser.Fullname = txtFullname.Text;
            newUser.Username = txtUsername.Text;
            newUser.Password = txtPassword.Text;

            entity.Entry(oldUser).CurrentValues.SetValues(newUser);
            entity.SaveChanges();

            MessageBox.Show("User Updated");
        }