Example #1
0
        private void DeleteData(string userId)
        {
            using (var context = new PARTSEntities())
            {
                var users = context.SP_UserDetail
                            .Where(u => u.UserID == userId).FirstOrDefault();

                if (users != null)
                {
                    context.SP_UserDetail.Remove(users);
                    context.SaveChanges();
                }
            }
        }
Example #2
0
        private void UpdateData()
        {
            using (var context = new PARTSEntities())
            {
                var users = context.SP_UserDetail
                            .Where(u => u.UserID == TextBoxUserId.Text).FirstOrDefault();

                users.UserName = TextBoxUserName.Text;
                users.Password = TextBoxPassword.Text;
                users.UserFunc = TextBoxFunction.Text;
                users.Show     = _isAvailable;

                context.SaveChanges();
            }
        }
Example #3
0
        private void ReadData()
        {
            using (var context = new PARTSEntities())
            {
                var users = context.SP_UserDetail
                            .Select(u => new
                {
                    u.UserID,
                    u.UserName,
                    u.Password,
                    u.UserFunc
                }).ToList();

                DgvUser.DataSource = users;
            }
        }
Example #4
0
        private void Create()
        {
            using (var context = new PARTSEntities())
            {
                var userDetail = new SP_UserDetail
                {
                    UserID   = TextBoxUserId.Text,
                    UserName = TextBoxUserName.Text,
                    Password = TextBoxPassword.Text,
                    UserFunc = TextBoxFunction.Text,
                    Show     = _isAvailable
                };

                context.SP_UserDetail.Add(userDetail);
                context.SaveChanges();
            }
        }