Exemple #1
0
        private void SetRight()
        {
            try
            {
                c_row_select = dgrUser.SelectedIndex;

                User_Rights frmUser_Rights = new User_Rights();
                frmUser_Rights.Owner = Window.GetWindow(this);

                User_Info _us = new User_Info();
                _us = (User_Info)dgrUser.SelectedItem;
                if (_us != null)
                {
                    frmUser_Rights.c_UsersInfo = _us;
                    frmUser_Rights.ShowDialog();

                    DataGridHelper.NVSFocus(dgrUser, c_row_select, 1);
                }
                else
                {
                    NoteBox.Show("Bạn chưa chọn user để set quyền", "Thông báo", NoteBoxLevel.Error);
                    DataGridHelper.NVSFocus(dgrUser, 0, 1);
                }
            }
            catch (Exception ex)
            {
                CommonData.log.Error(ex.ToString());
            }
        }
Exemple #2
0
        private void btnPhanQuyen_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                User_Info ms = new User_Info();
                ms = (User_Info)dgrUser.SelectedItem;

                c_row_select = dgrUser.SelectedIndex;
                if (ms != null)
                {
                    User_Rights frm_GroupUser_Right = new User_Rights();
                    frm_GroupUser_Right.Owner       = Window.GetWindow(this);
                    frm_GroupUser_Right.c_UsersInfo = ms;
                    frm_GroupUser_Right.ShowDialog();
                    if (frm_GroupUser_Right.c_ok == 1)
                    {
                        DataGridHelper.NVSFocus(dgrUser, c_row_select, 1);
                        frm_GroupUser_Right.c_ok = 0;
                    }
                    else
                    {
                        DataGridHelper.NVSFocus(dgrUser, c_row_select, 1);
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorLog.log.Error(ex.ToString());
            }
        }
        public ActionResult CreateCaretaker(CaretakerViewModel inputData)
        {
            if (ModelState.IsValid)
            {
                using (HomecareDBEntities db = new HomecareDBEntities())
                {
                    var userRights = new User_Rights
                    {
                        user_rights_type = inputData.user_rights
                    };

                    db.User_Rights.Add(userRights);
                    db.SaveChanges();

                    var userRightsID = db.User_Rights.FirstOrDefault(ur => ur.user_rights_type == inputData.user_rights).id_user_rights;

                    var userLogin = new Login
                    {
                        username             = inputData.username,
                        password             = inputData.password,
                        fk_user_rights_login = userRightsID
                    };

                    db.Logins.Add(userLogin);
                    db.SaveChanges();

                    var phonenumber = new Phone
                    {
                        phone_number = inputData.phonenumber
                    };

                    db.Phones.Add(phonenumber);
                    db.SaveChanges();

                    var loginID = db.Logins.FirstOrDefault(login => login.username == inputData.username).id_login;
                    var phoneID = db.Phones.FirstOrDefault(phone => phone.phone_number == inputData.phonenumber).id_phone;


                    var caretaker = new Caretaker
                    {
                        caretaker_name     = inputData.name,
                        fk_login_caretaker = loginID,
                        fk_phone_caretaker = phoneID
                    };

                    db.Caretakers.Add(caretaker);
                    db.SaveChanges();
                }


                ModelState.Clear();
                ViewBag.Message = inputData.name + " was created";
            }

            return(View());
        }
        public User_Rights GetInfoByRightId(int id)
        {
            User_Rights user_right = DbSet.Single(uid => uid.Id.Equals(id));

            return(user_right);
        }
 public virtual void Update(User_Rights obj)
 {
     DbSet.Update(obj);
 }
 public virtual void Add(User_Rights obj)
 {
     DbSet.Add(obj);
 }