Keep this class simple as possible
示例#1
0
        protected bool UpdateData()
        {
            bool result = false;

            try
            {
                UserMan.Users users = new UserMan.Users();
                users.UsersId      = Convert.ToInt32(this.hdnUserId.Value);
                users.UserName     = txtUserName.Text.Trim();
                users.FirstName    = txtFirstName.Text.Trim();
                users.LastName     = txtLastName.Text.Trim();
                users.EmailAddress = txtEmail.Text.Trim();
                users.Password     = txtPassword.Text.Trim();
                users.CompanyId    = Master.CurrentCompany.CompanyId;
                users.UpdatedUser  = Master.LoggedUser.UsersId;
                users.StatusId     = (int)HBM.Common.Enums.HBMStatus.Active;
                users.RolesId      = Convert.ToInt32(ddlRoles.Value);
                users.DepartmentId = Convert.ToInt32(ddlDepartment.Value);
                if (users.Save())
                {
                    this.ClearFormData();
                }
            }
            catch (System.Exception)
            {
            }

            return(result);
        }
        protected void DisplayData()
        {
            try
            {

                int currentUserId = Convert.ToInt32(this.hdnUserId.Value);
                UserMan.Users users = new UserMan.Users();
                users.UsersId = currentUserId;
                users.CompanyId = Master.CurrentCompany.CompanyId;
                users = users.Select();
                txtUserName.Text = users.UserName;
                txtFirstName.Text = users.FirstName;
                txtLastName.Text = users.LastName;
                txtEmail.Text = users.EmailAddress;
                txtPassword.Text = users.Password;
                ddlRoles.SelectedItem = ddlRoles.Items.FindByValue(users.RolesId);
                ddlDepartment.SelectedItem = ddlDepartment.Items.FindByValue(users.DepartmentId);

                currentPassword = users.Password;

            }
            catch (System.Exception)
            {

            }
        }
示例#3
0
        public bool Delete(Users users)
        {
            Database db = DatabaseFactory.CreateDatabase(Constants.HBMCONNECTIONSTRING);
            DbCommand command = db.GetStoredProcCommand("usp_UsersDelete");

            db.AddInParameter(command, "@UsersId", DbType.String, users.UsersId);
            db.ExecuteNonQuery(command);

            return true;
        }
 public bool IsUserAuthorised(Common.Enums.Rights right,Users user)
 {
     bool returnValue = false;
     int count = user.AllRights.FindAll(e => e.RightId == (int)right).Count();
     if (count > 0)
     {
         returnValue = true;
     }
     return returnValue;
 }
示例#5
0
        protected bool SaveData()
        {
            bool result = false;

            try
            {
                UserMan.Users users = new UserMan.Users();

                ////Check for existing uername
                users.UserName = txtUserName.Text.Trim();

                if (!users.IsUserIsDuplicateUserName(users.UserName, Master.CurrentCompany.CompanyId))
                {
                    users.EmailAddress = txtEmail.Text.Trim();

                    if (!users.IsDuplicateEmail(users.EmailAddress, Master.CurrentCompany.CompanyId))
                    {
                        users.FirstName = txtFirstName.Text.Trim();
                        users.LastName  = txtLastName.Text.Trim();

                        users.Password     = txtPassword.Text.Trim();
                        users.RolesId      = Convert.ToInt32(ddlRoles.Value);
                        users.DepartmentId = Convert.ToInt32(ddlDepartment.Value);
                        users.CreatedUser  = Master.LoggedUser.UsersId;
                        users.CompanyId    = Master.CurrentCompany.CompanyId;
                        users.StatusId     = (int)HBM.Common.Enums.HBMStatus.Active;
                        if (users.Save())
                        {
                            System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowMessage", "javascript:ShowSuccessMessage('" + Messages.Save_Success + "')", true);
                            this.ClearFormData();
                        }
                    }
                    else
                    {
                        System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowMessage", "javascript:ShowInfoMessage('" + Messages.Duplicate_Email + "')", true);
                    }
                }
                else
                {
                    System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowMessage", "javascript:ShowInfoMessage('" + Messages.Duplicate_Username + "')", true);
                }
            }
            catch (System.Exception)
            {
            }

            return(result);
        }
示例#6
0
 private void LoadCleanedByUsers()
 {
     try
     {
         DataSet dsCleaners = new UserManagement.Users()
         {
             CompanyId = Master.CurrentCompany.CompanyId
         }.SelectAllDataset();
         dsCleaners.Tables[0].Columns["UsersId"].ColumnName = "CleanedBy";
         ((GridViewDataComboBoxColumn)gvDirtyRooms.Columns["CleanedBy"]).PropertiesComboBox.TextField  = "UserName";
         ((GridViewDataComboBoxColumn)gvDirtyRooms.Columns["CleanedBy"]).PropertiesComboBox.ValueField = "CleanedBy";
         ((GridViewDataComboBoxColumn)gvDirtyRooms.Columns["CleanedBy"]).PropertiesComboBox.DataSource = dsCleaners;
     }
     catch (System.Exception)
     {
     }
 }
示例#7
0
        public bool Insert(Users users)
        {
            Database db = DatabaseFactory.CreateDatabase(Constants.HBMCONNECTIONSTRING);
            DbCommand command = db.GetStoredProcCommand("usp_UsersInsert");

            db.AddInParameter(command, "@UserName", DbType.String, users.UserName);
            db.AddInParameter(command, "@Password", DbType.String, users.Password);
            db.AddInParameter(command, "@FirstName", DbType.String, users.FirstName);
            db.AddInParameter(command, "@LastName", DbType.String, users.LastName);
            db.AddInParameter(command, "@EmailAddress", DbType.String, users.EmailAddress);
            db.AddInParameter(command, "@CreatedUser", DbType.Int32, users.CreatedUser);
            db.AddInParameter(command, "@StatusId", DbType.Int32, users.StatusId);
            db.AddInParameter(command, "@RolesId", DbType.Int32, users.RolesId);
            db.AddInParameter(command, "@DepartmentId", DbType.Int32, users.DepartmentId);
            db.AddInParameter(command, "@CompanyId", DbType.Int32, users.CompanyId);

            db.ExecuteNonQuery(command);

            return true;
        }
        protected void AuthenticateUser()
        {
            try
            {
                UserMan.Users users = new UserMan.Users();

                string userName = txtUserName.Text;
                string password = txtPassword.Text;
                int userID = 0;
                int companyId = 0;

                if (users.IsUserAuthenticated(userName, password, out userID, out companyId))
                {

                    if (userID > 0)
                    {
                        users.UsersId = userID;
                        users.CompanyId = companyId;
                        Session[Constants.SESSION_LOGGEDUSER] = users.Select();

                        Company company=new Company();
                        company.CompanyId=users.CompanyId;
                        Session[Constants.SESSION_CURRENTCOMPANY] = company.Select();
                        Response.Redirect(HBM.Common.Constants.URL_DEFAULTBACKPAGE, false);
                    }
                }
                else
                {
                    //trMsg.Visible = true;
                    lblError.Text = HBM.Common.Messages.Invalid_Credentials;
                    lblError.Visible = true;
                }
            }
            catch (System.Exception )
            {

            }
        }
示例#9
0
        protected void DisplayData()
        {
            try
            {
                int           currentUserId = Convert.ToInt32(this.hdnUserId.Value);
                UserMan.Users users         = new UserMan.Users();
                users.UsersId              = currentUserId;
                users.CompanyId            = Master.CurrentCompany.CompanyId;
                users                      = users.Select();
                txtUserName.Text           = users.UserName;
                txtFirstName.Text          = users.FirstName;
                txtLastName.Text           = users.LastName;
                txtEmail.Text              = users.EmailAddress;
                txtPassword.Text           = users.Password;
                ddlRoles.SelectedItem      = ddlRoles.Items.FindByValue(users.RolesId);
                ddlDepartment.SelectedItem = ddlDepartment.Items.FindByValue(users.DepartmentId);

                currentPassword = users.Password;
            }
            catch (System.Exception)
            {
            }
        }
示例#10
0
        protected void AuthenticateUser()
        {
            try
            {
                UserMan.Users users = new UserMan.Users();

                string userName  = txtUserName.Text;
                string password  = txtPassword.Text;
                int    userID    = 0;
                int    companyId = 0;


                if (users.IsUserAuthenticated(userName, password, out userID, out companyId))
                {
                    if (userID > 0)
                    {
                        users.UsersId   = userID;
                        users.CompanyId = companyId;
                        Session[Constants.SESSION_LOGGEDUSER] = users.Select();

                        Company company = new Company();
                        company.CompanyId = users.CompanyId;
                        Session[Constants.SESSION_CURRENTCOMPANY] = company.Select();
                        Response.Redirect(HBM.Common.Constants.URL_DEFAULTBACKPAGE, false);
                    }
                }
                else
                {
                    //trMsg.Visible = true;
                    lblError.Text    = HBM.Common.Messages.Invalid_Credentials;
                    lblError.Visible = true;
                }
            }
            catch (System.Exception)
            {
            }
        }
示例#11
0
        protected bool UpdateData()
        {
            bool result = false;

            try
            {
                UserMan.Users users = new UserMan.Users();
                users.UsersId = Convert.ToInt32(this.hdnUserId.Value);
                users.UserName = txtUserName.Text.Trim();
                users.FirstName = txtFirstName.Text.Trim();
                users.LastName = txtLastName.Text.Trim();
                users.EmailAddress = txtEmail.Text.Trim();
                users.Password = txtPassword.Text.Trim();
                users.CompanyId = Master.CurrentCompany.CompanyId;
                users.UpdatedUser = Master.LoggedUser.UsersId;
                users.StatusId = (int)HBM.Common.Enums.HBMStatus.Active;
                users.RolesId = Convert.ToInt32(ddlRoles.Value);
                users.DepartmentId = Convert.ToInt32(ddlDepartment.Value);
                if (users.Save())
                {
                    this.ClearFormData();
                }

            }
            catch (System.Exception)
            {

            }

            return result;
        }
示例#12
0
        protected bool SaveData()
        {
            bool result = false;

            try
            {
                UserMan.Users users = new UserMan.Users();

                ////Check for existing uername
                users.UserName = txtUserName.Text.Trim();

                if (!users.IsUserIsDuplicateUserName(users.UserName, Master.CurrentCompany.CompanyId))
                {
                    users.EmailAddress = txtEmail.Text.Trim();

                    if (!users.IsDuplicateEmail(users.EmailAddress, Master.CurrentCompany.CompanyId))
                    {
                        users.FirstName = txtFirstName.Text.Trim();
                        users.LastName = txtLastName.Text.Trim();

                        users.Password = txtPassword.Text.Trim();
                        users.RolesId = Convert.ToInt32(ddlRoles.Value);
                        users.DepartmentId = Convert.ToInt32(ddlDepartment.Value);
                        users.CreatedUser = Master.LoggedUser.UsersId;
                        users.CompanyId = Master.CurrentCompany.CompanyId;
                        users.StatusId = (int)HBM.Common.Enums.HBMStatus.Active;
                        if (users.Save())
                        {
                            System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowMessage", "javascript:ShowSuccessMessage('" + Messages.Save_Success + "')", true);
                            this.ClearFormData();
                        }
                    }
                    else
                    {
                        System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowMessage", "javascript:ShowInfoMessage('" + Messages.Duplicate_Email + "')", true);
                    }
                }
                else
                {
                    System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowMessage", "javascript:ShowInfoMessage('" + Messages.Duplicate_Username + "')", true);
                }

            }
            catch (System.Exception)
            {

            }

            return result;
        }
        private void LoadCleanedByUsers()
        {
            try
            {
                DataSet dsCleaners = new UserManagement.Users() { CompanyId = Master.CurrentCompany.CompanyId }.SelectAllDataset();
                dsCleaners.Tables[0].Columns["UsersId"].ColumnName = "CleanedBy";
                ((GridViewDataComboBoxColumn)gvDirtyRooms.Columns["CleanedBy"]).PropertiesComboBox.TextField = "UserName";
                ((GridViewDataComboBoxColumn)gvDirtyRooms.Columns["CleanedBy"]).PropertiesComboBox.ValueField = "CleanedBy";
                ((GridViewDataComboBoxColumn)gvDirtyRooms.Columns["CleanedBy"]).PropertiesComboBox.DataSource = dsCleaners;

            }
            catch (System.Exception)
            {

            }
        }
示例#14
0
        public DataSet SelectAll(Users users)
        {
            Database db = DatabaseFactory.CreateDatabase(Constants.HBMCONNECTIONSTRING);
            DbCommand dbCommand = db.GetStoredProcCommand("usp_UsersSelectAll");

            db.AddInParameter(dbCommand, "@CompanyId", DbType.Int32, users.CompanyId);
            return db.ExecuteDataSet(dbCommand);
        }