Example #1
0
        /// <summary>
        /// Check Login
        /// </summary>
        /// <param name="objUI"></param>
        /// <returns></returns>
        public UserAdmin CheckLogin(UserAdmin objUI)
        {
            UserAdmin objRes = null;
            objRes = dbContext.UserAdmins.Where(p => (
                (p.UserName == objUI.UserName) &&
                (p.DeleteFlag == false))).FirstOrDefault<UserAdmin>();

            return objRes;
        }
Example #2
0
        private void btn_delete_Click(object sender, EventArgs e)
        {
            //ELIMINAR LA ROW DE LA GRIDVIEW
            String selected_user = lb_users.GetItemText(lb_users.SelectedItem);

            lb_users.Items.Remove(lb_users.SelectedItem);

            //INSERTAR EN UNA TABLA LOS USUARIOS QUE SE DIERON DE BAJA(BAJA LOGICA)
            //Elimina de la tabla usuarios y deberia eliminar en las asociadas
            User user = new UserAdmin();

            user.setUsername(selected_user);
            user.setYouDown();

            //ELIMINAR DE LA TABLA DE USUARIOS
            //tener una tabla de historia de usuari    os para cuando los demos de baja
            home_db.downUser(user.getUserName());
        }
Example #3
0
        public static List <UserAdmin> SelectAll(SQLiteConnection conn)
        {
            List <UserAdmin> result = new List <UserAdmin>();

            using (SQLiteCommand cmd = new SQLiteCommand(selectAll, conn))
            {
                SQLiteDataReader reader = null;
                try
                {
                    reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        UserAdmin um = new UserAdmin()
                        {
                            Id        = Convert.ToInt32(reader["rowid"].ToString()),
                            FirstName = reader["FirstName"].ToString(),
                            LastName  = reader["LastName"].ToString(),
                            Email     = reader["Email"].ToString(),
                            Phone     = reader["Phone"].ToString(),
                            Street    = reader["Street"].ToString(),
                            City      = reader["City"].ToString(),
                            Zip       = reader["Zip"].ToString(),
                            Active    = Convert.ToBoolean(reader["Active"]),
                            Login     = reader["Login"].ToString(),
                            Password  = reader["Password"].ToString(),
                            CanManageNotifications = Convert.ToBoolean(reader["CanManageNotifications"]),
                            CanManageStations      = Convert.ToBoolean(reader["CanManageStations"]),
                            CanManageUsers         = Convert.ToBoolean(reader["CanManageUsers"])
                        };
                        result.Add(um);
                    }
                }
                catch (Exception e)
                {
                    Trace.WriteLine($"EXCEPTION: UserAdminDbMapper.SelectAll: {e.Message}");
                }
                finally
                {
                    reader?.Close();
                }
            }

            return(result);
        }
Example #4
0
 public static UserAdmin SelectById(SQLiteConnection conn, int id)
 {
     if (id < 0)
     {
         return(null);
     }
     using (SQLiteCommand cmd = new SQLiteCommand(selectById, conn))
     {
         cmd.Parameters.AddWithValue("@Id", id);
         SQLiteDataReader reader = null;
         try
         {
             reader = cmd.ExecuteReader();
             while (reader.Read())
             {
                 UserAdmin um = new UserAdmin()
                 {
                     Id        = Convert.ToInt32(reader["rowid"].ToString()),
                     FirstName = reader["FirstName"].ToString(),
                     LastName  = reader["LastName"].ToString(),
                     Email     = reader["Email"].ToString(),
                     Phone     = reader["Phone"].ToString(),
                     Street    = reader["Street"].ToString(),
                     City      = reader["City"].ToString(),
                     Zip       = reader["Zip"].ToString(),
                     Active    = Convert.ToBoolean(reader["Active"]),
                     Login     = reader["Login"].ToString(),
                     Password  = reader["Password"].ToString(),
                     CanManageNotifications = Convert.ToBoolean(reader["CanManageNotifications"]),
                     CanManageStations      = Convert.ToBoolean(reader["CanManageStations"]),
                     CanManageUsers         = Convert.ToBoolean(reader["CanManageUsers"])
                 };
                 reader.Close();
                 return(um);
             }
         }
         catch (Exception e)
         {
             reader?.Close();
             Trace.WriteLine($"EXCEPTION: UserAdminDbMapper.SelectById: {e.Message}");
         }
     }
     return(null);
 }
Example #5
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            int ID;

            if (txtUserID.Text == "")
            {
                MessageBox.Show("请输入账号");
                return;
            }
            if (txtUserPwd.Text == "")
            {
                MessageBox.Show("请输入密码");
                return;
            }
            ID   = Convert.ToInt32(txtUserID.Text.Trim());
            user = UserAdmin.GetUser(ID);

            if (user == null)
            {
                txtUserID.Focus();
                MessageBox.Show("信息:无此用户");
            }
            else
            {
                if (user.Pwd == txtUserPwd.Text)
                {
                    blCanLogin = true;
                    //this.DialogResult = DialogResult.OK;
                    if (main != null)
                    {
                        main.user = user;
                        main.InitMenu();
                        main.Show();
                    }
                    this.Close();
                }
                else
                {
                    txtUserPwd.Text = "";
                    txtUserPwd.Focus();
                    MessageBox.Show("信息:密码错误!");
                }
            }
        }
        private void 登记_3_Click(object sender, EventArgs e)
        {
            if (tb3_3.Text == "")
            {
                MessageBox.Show("请输入完整信息");
                return;
            }

            new_user = UserAdmin.GetUser(Convert.ToInt32(tb3_2.Text));
            if (new_user == null)
            {
                MessageBox.Show("该用户不存在");
                return;
            }

            new_book = BookAdmin.GetBook(Convert.ToInt32(tb3_3.Text));
            if (new_book.Name == null)
            {
                MessageBox.Show("该图书不存在");
                return;
            }

            dt = BorrowAdmin.GetBorrow(Convert.ToInt32(tb3_2.Text));
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                //if (dt.Rows[i][4].ToString() == listBox1.SelectedItems[0].ToString() && Convert.ToInt32(dt.Rows[i][7]) == 0)
                if (dt.Rows[i][3].ToString() == tb3_3.Text && dt.Rows[i][7].ToString() == "False")
                {
                    MessageBox.Show("该图书已借出");
                    return;
                }
            }

            if (SetTextToBorrow())
            {
                borrowBLL.Insert(new_borrow);
                new_book           = BookAdmin.GetBook(new_book.ID);
                new_book.Condition = "借出";
                bookBLL.Updata(new_book);

                MessageBox.Show("状态:登记成功!");
            }
            tb3_3.Text = "";
        }
Example #7
0
    public static void AddBlacklist(int playerId)
    {
        UserAdmin ua = UserAdminList.Find(iter => iter.Id == playerId);

        if (null == ua)
        {
            return;
        }

        ua.RemovePrivileges(AdminMask.AssistRole);
        ua.AddPrivileges(AdminMask.BlackRole);
        OnPrivilegesChanged(ua);

//		if (null != GameGui_N.Instance)
//		{
//			GameGui_N.Instance.mPersonnelManageGui.OnBlackListInfoChange();
//			GameGui_N.Instance.mPersonnelManageGui.OnPersonnelInfoChange();
//		}
    }
        public bool UpdateUserAdmin(UserAdmin userAdmin)
        {
            using (IDbConnection sqlConnection = new SqlConnection(this._connectionString))
            {
                var command = sqlConnection.CreateCommand();
                command.CommandText = "[UpdateUserAdmin]";
                command.CommandType = CommandType.StoredProcedure;
                SqlParameter parameterlogin = new SqlParameter("@login", userAdmin.Login);
                command.Parameters.Add(parameterlogin);
                SqlParameter parameterpass = new SqlParameter("@pass", userAdmin.Pass);
                command.Parameters.Add(parameterpass);
                SqlParameter parameteradminOrUser = new SqlParameter("@adminOrUser", userAdmin.AdminOrUser);
                command.Parameters.Add(parameteradminOrUser);
                sqlConnection.Open();
                command.ExecuteNonQuery();
            }

            return(true);
        }
Example #9
0
 /// <summary>
 /// 判断是否登陆
 /// </summary>
 private void checkOut()
 {
     try
     {
         UserAdmin = JsonConvert.DeserializeObject <UserAdmin>(Cookie.GetCookie("UserAdmin"));
         var model = OnLineUser.OnLineList.FirstOrDefault(p => p.UserID == UserAdmin.UserID);
         if (model == null)
         {
             if (model == null)
             {
                 RedirectUrl("/Login/Error?str=" + "您的账号在别的地方登录,您已被迫下线,是否重新登录!");
             }
         }
     }
     catch (Exception e)
     {
         RedirectUrl("/Login/Error?str=" + e.Message + ",请重新登录!");
     }
 }
Example #10
0
    public static void ProxyPlayerAdmin(PlayerNetwork player)
    {
        if (null == player)
        {
            return;
        }

        UserAdmin ua = UserAdminList.Find(iter => iter.Id == player.Id);

        if (null == ua)
        {
            ua = new UserAdmin(player.Id, player.RoleName, 0);
            UserAdminList.Add(ua);
            OnPrivilegesChanged(ua);
        }

//		if (null != GameGui_N.Instance)
//			GameGui_N.Instance.mPersonnelManageGui.OnPersonnelInfoChange();
    }
Example #11
0
 private void 借阅情况_3_Click(object sender, EventArgs e)
 {
     listBox1.Items.Clear();
     new_user = UserAdmin.GetUser(Convert.ToInt32(tb3_2.Text));
     if (new_user == null)
     {
         MessageBox.Show("该用户不存在");
         return;
     }
     dt = BorrowAdmin.GetBorrow(Convert.ToInt32(tb3_2.Text));
     for (int i = 0; i < dt.Rows.Count; i++)
     {
         //if (Convert.ToInt32(dt.Rows[i][7]) == 0)
         if (dt.Rows[i][7].ToString() == "False")
         {
             listBox1.Items.Add(dt.Rows[i][4]);
         }
     }
 }
        public ActionResult Index(UserAdmin user)
        {
            if (ModelState.IsValid)
            {
                var status = new UserAdminDAO().Login(user.UserName, user.UserPass);
                if (status == "True")
                {
                    Session["Admin"] = user.UserName;
                    return(RedirectToAction("Index", "HomeAd"));
                }
                else
                {
                    ModelState.AddModelError("", status);
                }
            }


            return(View());
        }
Example #13
0
        public bool AddOrEdit(AccountAdminModel accont)
        {
            try
            {
                var XmlImage = new XElement("Image", accont.UserImage);
                if (accont.UserID == 0)
                {
                    ////thêm account
                    UserAdmin userAdmin = new UserAdmin()
                    {
                        UserID         = accont.UserID,
                        UserName       = accont.UserName,
                        UserEmail      = accont.UserEmail,
                        UserDateCreate = accont.UserDateCreate,
                        UserPhone      = accont.UserPhone,
                        UserAddress    = accont.UserAddress,
                        UserLuong      = accont.UserLuong,
                        UserIDQuyen    = accont.IDQuyen,
                        UserImage      = XmlImage.ToString()
                    };
                    data.UserAdmins.Add(userAdmin);
                    data.SaveChanges();
                }
                else
                {
                    ///Sử tai khoản.
                    UserAdmin userAdmin = data.UserAdmins.SingleOrDefault(q => q.UserID == accont.UserID);
                    userAdmin.UserName       = accont.UserName;
                    userAdmin.UserEmail      = accont.UserEmail;
                    userAdmin.UserDateCreate = accont.UserDateCreate;
                    userAdmin.UserPhone      = accont.UserPhone;
                    userAdmin.UserAddress    = accont.UserAddress;
                    userAdmin.UserLuong      = accont.UserLuong;
                    userAdmin.UserIDQuyen    = accont.IDQuyen;
                    userAdmin.UserImage      = XmlImage.ToString();
                    data.SaveChanges();
                }

                return(true);
            }
            catch (Exception) { return(false); }
        }
Example #14
0
    public static void UIAddBlacklist(UserAdmin Player)
    {
        if (null == Player)
        {
            return;
        }

        if (ServerAdministrator.IsAdmin(Player.Id))
        {
            if (_mUserAdmin == null)
            {
                _mUserAdmin = Player;
            }
            return;
        }

        if (PlayerNetwork.mainPlayerId == Player.Id)
        {
            if (null == _mSelfAdmin)
            {
                _mSelfAdmin = Player;
            }
            return;
        }

        ServerAdministrator.RequestAddBlackList(Player.Id);

        /*	UserAdmin ua = ServerAdministrator.UserAdminList.Find(iter => iter.Id == Player.Id);
         *      if (null == ua)
         *      {
         *              ua = new UserAdmin(Player.Id, Player.RoleName, 0);
         *              ServerAdministrator.UserAdminList.Add(ua);
         *
         *      }
         *
         *      UIArrayBlackAdmin.Add(ua);
         *      mUIBalckInfoList.Add(ua);
         *      UIArrayPersonnelAdmin.Remove(ua);
         *      mUIPersonelInfoList.Remove(ua);
         *
         *      ua.AddPrivileges(AdminMask.BlackRole);*/
    }
    void ItemAdminOnClick(object sender, UserAdmin userAdmin)
    {
        UIAdminstratorItem item = sender as UIAdminstratorItem;

        if ((item != null) && (userAdmin != null))
        {
            /*    if(userAdmin.HasPrivileges(AdminMask.BuildLock))//ServerAdministrator.IsBuildLock(userAdmin.Id)
             *      {
             *      userAdmin.RemovePrivileges(AdminMask.BuildLock);
             *      item.mLbForbidden.text="Forbidden";
             *      }
             *  else
             *      {
             *      userAdmin.AddPrivileges(AdminMask.BuildLock);
             *      item.mLbForbidden.text="UnForbidden";
             *      }*/

            Reflsh(UIAdminstratorctr.mUIPersonelInfoList);
        }
    }
Example #16
0
    //
    public static void BuildUnLock(int id)
    {
        if (!IsBuildLock(id))
        {
            return;
        }

        UserAdmin ua = UserAdminList.Find(iter => iter.Id == id);

        if (null == ua)
        {
            return;
        }

        ua.RemovePrivileges(AdminMask.BuildLock);
        OnPrivilegesChanged(ua);

//		if (null != GameGui_N.Instance)
//			GameGui_N.Instance.mPersonnelManageGui.OnPersonnelInfoChange();
    }
Example #17
0
    public static void DeleteBlacklist(int id)
    {
        if (!IsBlack(id))
        {
            return;
        }

        UserAdmin ua = UserAdminList.Find(iter => iter.Id == id);

        if (null == ua)
        {
            return;
        }

        ua.RemovePrivileges(AdminMask.BlackRole);
        OnPrivilegesChanged(ua);

//		if (null != GameGui_N.Instance)
//			GameGui_N.Instance.mPersonnelManageGui.OnBlackListInfoChange();
    }
Example #18
0
        private bool SetTextToBorrow()
        {
            if (tb3_2.Text == "")
            {
                MessageBox.Show("请输入完整信息");
                return(false);
            }
            new_borrow.UID   = Convert.ToInt32(tb3_2.Text);
            new_user         = UserAdmin.GetUser(new_borrow.UID);
            new_borrow.UName = new_user.Name;

            if (tb3_3.Text != "")
            {
                new_borrow.BID   = Convert.ToInt32(tb3_3.Text);
                new_book         = BookAdmin.GetBook(new_borrow.BID);
                new_borrow.BName = new_book.Name;
            }

            new_borrow.Borrow_time = DateTime.Now;
            new_borrow.Return_time = DateTime.Now;
            if (listBox1.SelectedItems.Count != 0)
            {
                dt = BorrowAdmin.GetBorrow(new_borrow.UID);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    //if (dt.Rows[i][4].ToString() == listBox1.SelectedItems[0].ToString() && Convert.ToInt32(dt.Rows[i][7]) == 0)
                    if (dt.Rows[i][4].ToString() == listBox1.SelectedItems[0].ToString() && dt.Rows[i][7].ToString() == "False")
                    {
                        if (tb3_3.Text == "")
                        {
                            new_borrow.BID   = Convert.ToInt32(dt.Rows[i][3].ToString());
                            new_borrow.BName = listBox1.SelectedItems[0].ToString();
                        }
                        new_borrow.ID        = Convert.ToInt32(dt.Rows[i][0].ToString());
                        new_borrow.Is_return = 1;
                        break;
                    }
                }
            }
            return(true);
        }
        public void Case06()
        {
            var org1    = Utils.CreateOrganization(code: 1, name: "org1", startDate: DateTime.Today, endDate: DateTime.Today);
            var domain1 = new Domain {
                Id = Guid.NewGuid(), Name = "domain1", Organization = org1
            };
            var user1 = new UserAdmin {
                AccountName = "user1", Name = "", Domain = domain1, Password = Utils.HashPassword("user1")
            };
            var availablePeriod1 = new AvailablePeriod {
                StartDate = DateTime.Today, EndDate = DateTime.Today, EndUser = user1
            };

            _context.AddRange(org1, domain1, user1, availablePeriod1);
            _context.SaveChanges();

            var query    = new { organizationCode = 1, domainName = "domain1", userName = "******", password = "******" };
            var response = _client.PostAsync(LoginUrl, Utils.CreateJsonContent(query)).Result;

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
        }
Example #20
0
        public IHttpActionResult CreateAdmin(UserAdmin userAdmin)
        {
            var admin = db.UserAdmins.FirstOrDefault(x => x.Name == userAdmin.Name || x.Email == userAdmin.Email);

            if (admin != null)
            {
                return(BadRequest("Ya existe un Administrador con este nombre o correo."));
            }

            if (userAdmin.Email == null || userAdmin.Name == null || userAdmin.Password == null || userAdmin.Phone == null || userAdmin.IdUserType.ToString() == null)
            {
                return(BadRequest("Todos los campos deben estar llenos."));
            }

            userAdmin.State = true;

            db.UserAdmins.Add(userAdmin);
            db.SaveChanges();

            return(Ok(new { message = "Usuario administrador creado exitosamente" }));
        }
Example #21
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            DirectoryHelper directoryHelper = new DirectoryHelper("C:\\", "SiparisOtomasyonuDb");

            if (!directoryHelper.DirectoryExists())
            {
                directoryHelper.Create();
            }
            UserAdminManager manager = UserAdminManager.CreateAsSingleton(PathHelper.UserAdminPathModel);
            UserAdmin        admin   = manager.Entities.Find(I => I.UserName == "admin" && I.Password == "12345");

            if (admin == null)
            {
                manager.Add(new UserAdmin {
                    UserName = "******", Password = "******"
                });
            }
            Application.Run(new MDIForm());
        }
        public async Task <IActionResult> Create([Bind("EmployeeId,StaffName,MobileNo,JoiningDate,LeavingDate,IsWorking,Category")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                _context.Add(employee);
                await _context.SaveChangesAsync();

                if (employee.Category == EmpType.StoreManager)
                {
                    await UserAdmin.AddUserAsync(_userManager, employee.StaffName, true);
                }
                else
                {
                    await UserAdmin.AddUserAsync(_userManager, employee.StaffName, false);
                }
                //TODO: Implement add employee level security and permissions

                return(RedirectToAction(nameof(Index)));
            }
            return(PartialView(employee));
        }
Example #23
0
    public static void ChangeAssistant(UserAdmin player)
    {
        ArrayList ArrayPersonnel = UIArrayPersonnelAdmin;

        for (int i = 0; i < ArrayPersonnel.Count; i++)
        {
            if (ArrayPersonnel[i] == player)
            {
                if (player.HasPrivileges(AdminMask.BlackRole))
                {
                    UIArrayPersonnelAdmin.Remove(ArrayPersonnel[i]);
                    UIArrayBlackAdmin.Add(player);
                }
                else
                {
                    UIArrayPersonnelAdmin[i] = player;
                }
                break;
            }
        }
    }
Example #24
0
        public ActionResult <UserAdmin> UpdateUser(UserAdmin userAdmin, int id)
        {
            var item = _context.UserAdmins.Find(id);

            if (item == null)
            {
                return(NotFound());
            }
            if (_context.UserAdmins.Any(users => users.UserName == userAdmin.UserName))
            {
                return(Ok("Username already exists!!"));
            }
            item.Name     = userAdmin.Name;
            item.UserName = userAdmin.UserName;
            item.Password = userAdmin.Password;
            item.Email    = userAdmin.Email;
            item.Phone    = userAdmin.Phone;
            _context.UserAdmins.Update(item);
            _context.SaveChanges();
            return(Ok("Successfully updated!!"));
        }
Example #25
0
        public static async Task AddEmployeeLoginAsync(eStoreDbContext db, Employee employee, UserManager <AppUser> userManager)
        {
            if (employee != null)
            {
                if (employee.IsWorking)
                {
                    await UserAdmin.AddUserAsync(userManager, employee);
                }

                //{


                //    //TODO:    await UserAdmin.AddEmployeeUserAsync(db, employee.StaffName, employee.EmployeeId);

                //}
            }
            else
            {
                throw new Exception();
            }
        }
Example #26
0
        public async Task <IActionResult> GenerateMyUsersReport()
        {
            if (User.Identity != null && (User.HasClaim("UserAdmin", "IsUserAdmin") || User.HasClaim("SystemAdmin", "IsSystemAdmin")))
            {
                UserAdmin currentuser = new UserAdmin();

                if (User.HasClaim("SystemAdmin", "IsSystemAdmin"))
                {
                    currentuser = await _dataAccess.SystemAdmins.GetCurrentUserAdmin(User.Identity.Name);
                }
                else
                {
                    currentuser = await _dataAccess.UserAdmins.GetSingleUserAdminAsync(User.Identity.Name);
                }

                var report = _reportGenerator.GenerateReport(currentuser.Users);

                return(File(report.Content, report.Format, report.FileName));
            }
            return(Unauthorized());
        }
Example #27
0
 public ActionResult Login(UserAdmin user)
 {
     if (ModelState.IsValid)
     {
         var results = new AdminLoginModel().Login(user.id, user.Password);
         if (results == 1)
         {
             SessionHelper.SetSession(new AdminSession()
             {
                 Username = user.id
             });
             return(Redirect("~/AdminArea/Admin/Index"));
         }
         else
         {
             ModelState.AddModelError("", "Ten dang nhap hoac mat khau khong dung");
         }
         return(View(user));
     }
     return(View("IndexLogin"));
 }
Example #28
0
        public static int Delete(SQLiteConnection conn, UserAdmin ua)
        {
            if (ua == null)
            {
                return(-2);
            }
            if (ua.Id < 0)
            {
                return(-3);
            }

            using (SQLiteCommand cmd = new SQLiteCommand(deleteUB, conn))
            {
                cmd.Parameters.AddWithValue("@Id", ua.Id);
                try
                {
                    cmd.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    Trace.WriteLine($"EXCEPTION: UserAdminDbMapper.Delete: {e.Message}");
                    return(-1);
                }
            }

            using (SQLiteCommand cmd = new SQLiteCommand(deleteU, conn))
            {
                cmd.Parameters.AddWithValue("@Id", GetUserIdFromBossId(conn, ua.Id));
                try
                {
                    cmd.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    Trace.WriteLine($"EXCEPTION: UserAdminDbMapper.Delete: {e.Message}");
                    return(-1);
                }
            }
            return(0);
        }
Example #29
0
    public void SetPlayerInfo(UserAdmin ud)
    {
        mName.text = ud.RoleName;
        mRoleId    = ud.Id;

        if (ServerAdministrator.IsAdmin(mRoleId))
        {
            mManagerMask.spriteName = "AdministratorMask";
            mIsAssistantText.text   = "Set";
            mBuildEnableText.text   = "Forbidden";

            mIsAssistant.isChecked = false;
            mBuildEnable.isChecked = true;
        }
        else
        {
            if (ServerAdministrator.IsAssistant(mRoleId))
            {
                mManagerMask.spriteName = "AssistantMask";
                mIsAssistantText.text   = "Dismiss";
            }
            else
            {
                mManagerMask.spriteName = "Null";
                mIsAssistantText.text   = "Set";
            }

            if (ServerAdministrator.IsBuildLock(mRoleId))
            {
                mBuildEnableText.text = "Allow";
            }
            else
            {
                mBuildEnableText.text = "Forbidden";
            }

            mIsAssistant.isChecked = ServerAdministrator.IsAssistant(mRoleId);
            mBuildEnable.isChecked = !ServerAdministrator.IsBuildLock(mRoleId);
        }
    }
        public void AddUserAdmin_Expected_succes()
        {
            var admin = new UserAdmin()
            {
                Name             = "Tester3",
                PaymentMethod    = "Cash",
                FinancialBalance = 1200,
                PaymentDueDate   = new DateTime(2021 - 08 - 08),
                Email            = "*****@*****.**",
                UserName         = "******",
                EmailConfirmed   = true
            };

            _uut.UserAdmins.AddUserAdmin(admin);
            _uut.Complete();

            var temp = _uut.UserAdmins.GetAllUserAdmins();

            Assert.That(temp.Count == 3);

            Dispose();
        }
        private bool SetTextToBorrow()
        {
            if (tb3_2.Text == "")
            {
                MessageBox.Show("请输入完整信息");
                return(false);
            }
            new_borrow.UID = Convert.ToInt32(tb3_2.Text);
            new_user       = UserAdmin.GetUser(new_borrow.UID);

            if (tb3_3.Text != "")
            {
                new_borrow.BID       = Convert.ToInt32(tb3_3.Text);
                new_book             = BookAdmin.GetBook(new_borrow.BID);
                new_borrow.Is_return = "NO";
            }

            new_borrow.Borrow_time = DateTime.Now;
            new_borrow.Return_time = DateTime.Now;
            if (listBox1.SelectedItems.Count != 0)
            {
                dt = BorrowAdmin.GetBorrow(new_borrow.UID);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string bname = BookAdmin.GetBook(int.Parse(dt.Rows[i][2].ToString())).Name;
                    if (bname == listBox1.SelectedItems[0].ToString() && dt.Rows[i][5].ToString() == "NO")
                    {
                        if (tb3_3.Text == "")
                        {
                            new_borrow.BID = Convert.ToInt32(dt.Rows[i][2].ToString());
                        }
                        new_borrow.ID        = Convert.ToInt32(dt.Rows[i][0].ToString());
                        new_borrow.Is_return = "YES";
                        break;
                    }
                }
            }
            return(true);
        }
 private void btnConfirm_Click(object sender, EventArgs e)
 {
     if(txtNewPassword.Text == txtNewPasswordConfirm.Text)
     {
         //Testing fields
         foreach(UserNamePath tempTest in UserNamePathList)
         {
             if(txtNewUsername.Text == tempTest.Name)
             {
                 MessageBox.Show("User already exists!", "Warning!");
                 txtNewUsername.Focus();
                 return;
             }
         }
         foreach (Control tempTest in gNewUser.Controls)
         {
             if (tempTest is TextBox && tempTest.Text.Trim() == string.Empty)
             {
                 MessageBox.Show("Please fill out all the entries!", "Warning!");
                 tempTest.Focus();
                 return;
             }
         }
         if (alphanumericTest(txtNewUsername.Text) == true)
         {
             MessageBox.Show("Username must be alphanumeric!", "Warning!");
             txtNewUsername.Focus();
             return;
         }
         if (alphanumericTest(txtNewPassword.Text) == true)
         {
             MessageBox.Show("Password must be alphanumeric!", "Warning!");
             txtNewPassword.Text = string.Empty;
             txtNewPasswordConfirm.Text = string.Empty;
             txtNewPassword.Focus();
             return;
         }
         if(txtNewPassword.Text.Length < 8)
         {
             MessageBox.Show("Password length must be at least 8 characters!", "Warning!");
         }
         //Get new user information
         UserAdmin newUser = new UserAdmin();
         newUser.Name = txtNewUsername.Text;
         newUser.IC = txtNewIC.Text;
         newUser.HomeAddress = txtNewAddress.Text;
         newUser.HouseNumber = txtNewHouseNo.Text;
         newUser.PhoneNumber = txtNewPhoneNo.Text;
         newUser.Email = txtNewEmail.Text;
         newUser.Password = txtPassword.Text;
         //Create a temporary unencrypted user database
         string tmpNewUser = newUser.Name + ".tmp";
         XmlWriterSettings writer_settings = new XmlWriterSettings();
         writer_settings.Indent = true; ;
         writer_settings.OmitXmlDeclaration = true;
         writer_settings.Encoding = Encoding.ASCII;
         using (XmlWriter writer = XmlWriter.Create(tmpNewUser, writer_settings))
         {
             writer.WriteStartDocument();
             writer.WriteStartElement("Database");//Database
             //----------
             writer.WriteStartElement("Details"); //Details
             //----------
             writer.WriteElementString("UserName", newUser.Name);
             writer.WriteElementString("IC", newUser.IC);
             writer.WriteElementString("Address", newUser.HomeAddress);
             writer.WriteElementString("HouseNo", newUser.HouseNumber);
             writer.WriteElementString("PhoneNo", newUser.PhoneNumber);
             writer.WriteElementString("Email", newUser.Email);
             //----------
             writer.WriteEndElement(); //Details
             //----------
             writer.WriteEndElement();//Database
             writer.WriteEndDocument();
             writer.Flush();
             writer.Close();
         }
         string tempFileDir = CurrentPath + "\\" + tmpNewUser;
         string outFileDir = CurrentPath + Database + "\\" + newUser.Name + ".db";
         Console.WriteLine(tempFileDir.ToString());
         EncryptFile(tempFileDir, outFileDir, txtNewPassword.Text);
         Console.WriteLine("Creating user tenant directory");
         Directory.CreateDirectory(CurrentPath + Database + newUser.Name);
         //Delete files
         System.IO.File.Delete(tempFileDir);
         //Success
         MessageBox.Show("User " + newUser.Name + " successfully created!", "Success");
         //Hide the create user dialog
         HideUserCreate();
         //Show new UserName in field
         txtUserName.Text = newUser.Name;
         txtPassword.Focus();
         //Clear textboxes
         clearChildren(gNewUser);
         //Reload database
         DatabaseCheck();
     }
     else
     {
         MessageBox.Show("Passwords do not match!", "Warning");
         txtNewPassword.Text = string.Empty;
         txtNewPasswordConfirm.Text = string.Empty;
         txtNewPassword.Focus();
     }
 }
Example #33
0
        public List<UserAdmin> GetUserAdminByRole(int WF)
        {
            List<UserAdmin> list = new List<UserAdmin>();
            var entities = from e in dbContext.UserAdmin_WFRoles
                           join f in dbContext.UserAdmins on e.UserAdminId equals f.UserAdminId
                           where e.IsActive == true && e.WFRoleID == WF && f.DeleteFlag == false
                           orderby f.UserName ascending

                           select new
                           {
                               ID = f.UserAdminId,
                               Name = f.UserName
                           };

            foreach (var e in entities)
            {
                UserAdmin admin = new UserAdmin();
                admin.UserAdminId = e.ID;
                admin.UserName = e.Name;
                list.Add(admin);
            }

            return list;
        }
Example #34
0
        /// <summary>
        /// Update user group
        /// </summary>
        /// <param name="objUI"></param>
        /// <returns></returns>
        public Message Update(string id, string userName, string groupId, bool isActive, AuthenticationProjectPrincipal principal)
        {
            Message msg = null;
            try
            {
                if (auDao.CheckExistInAD(userName))
                {
                    UserAdmin user = GetByUserName(userName);
                    if (user == null)
                    {
                        user = new UserAdmin();
                        user.UserName = userName;
                        user.DeleteFlag = false;
                        user.CreateDate = DateTime.Now;
                        user.UpdateDate = DateTime.Now;
                        user.CreatedBy = principal.UserData.UserName;
                        user.UpdatedBy = principal.UserData.UserName;

                        dbContext.UserAdmins.InsertOnSubmit(user);
                        dbContext.SubmitChanges();
                    }

                    int _groupId = int.Parse(groupId);

                    User_Group user_group = GetUser_Group(user.UserAdminId, _groupId);

                    if (user_group == null)
                    {
                        user_group = GetUser_Group(int.Parse(id));
                    }
                    else if(user_group.ID.ToString() != id)
                    {
                        msg = new Message(MessageConstants.E0020, MessageType.Error, "User " + userName + " belong group " + user_group.Group.GroupName, "database");
                    }

                    if (msg == null)
                    {
                        if (user_group != null)
                        {
                            user_group.UserAdminId = user.UserAdminId;
                            user_group.GroupId = int.Parse(groupId);
                            user_group.IsActive = isActive;

                            user_group.UpdateDate = DateTime.Now;
                            user_group.UpdatedBy = principal.UserData.UserName;
                            //Write Log
                            new UserAdminLogDao().WriteLogForUserAdmin(null, user_group, ELogAction.Update);

                            dbContext.SubmitChanges();
                            msg = new Message(MessageConstants.I0001, MessageType.Info, "User " + userName + " belong group " + user_group.Group.GroupName, "updated");
                        }
                        else
                        {
                            msg = new Message(MessageConstants.E0020, MessageType.Error, "User " + userName + " belong group " + user_group.Group.GroupName + " does not", "database");
                        }
                    }
                }
                else
                {
                    msg = new Message(MessageConstants.E0005, MessageType.Error, "User " + userName, "Active Directory");
                }
            }
            catch (Exception)
            {
                msg = new Message(MessageConstants.E0007, MessageType.Error);
            }
            return msg;
        }
Example #35
0
        /// <summary>
        /// Get By Role
        /// </summary>
        /// <param name="userAdminId"></param>
        /// <returns></returns>
        public List<UserAdmin> GetByRequestor()
        {
            List<UserAdmin> list = new List<UserAdmin>();
            var entities = from e in dbContext.UserAdmin_WFRoles
                           join f in dbContext.UserAdmins on e.UserAdminId equals f.UserAdminId
                           where e.WFRoleID == Constants.REQUESTOR_ID

                           select new
                           {
                               ID = e.UserAdminId,
                               Name = f.UserName
                           };

            foreach (var e in entities)
            {
                UserAdmin admin = new UserAdmin();
                admin.UserAdminId = e.ID;
                admin.UserName = e.Name;
                list.Add(admin);
            }

            return list;
        }