示例#1
0
        protected void AuthenticateUser()
        {
            try
            {
                User users = new User();

                string userName = txtUserName.Text;
                string password = txtPassword.Text;
                Guid userID = new Guid();

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

                    if (userID != new Guid())
                    {
                        users.UserId = userID;
                        Session[Constant.SESSION_LOGGEDUSER] = users.Select();
                        Response.Redirect(Diary.Common.Constant.URL_DEFAULTBACKPAGE, false);
                        //Todo
                    }
                }
                else
                {
                    //trMsg.Visible = true;
                    FailureText.Text = Diary.Common.Messages.Invalid_Credentials;
                    FailureText.Visible = true;
                }
            }
            catch (System.Exception)
            {

            }
        }
示例#2
0
        protected void DisplayData()
        {
            try
            {

                Guid currentUserId = new Guid(this.hdnUserId.Value);
                User users = new User();
                users.UserId = currentUserId;
                users = users.Select();
                txtUserName.Text = users.UserName;
                txtFirstName.Text = users.FirstName;
                txtLastName.Text = users.LastName;
                txtEmail.Text = users.EmailAddress;
                txtPassword.Text = users.Password;
                txtContact.Text = users.Contact;
                ddlRoles.SelectedItem = ddlRoles.Items.FindByValue(users.RoleId);
                ddlGrade.SelectedItem = ddlGrade.Items.FindByValue(users.GradeId);
                ddlJob.SelectedItem = ddlJob.Items.FindByValue(users.JobId);
                ddlLocation.SelectedItem = ddlLocation.Items.FindByValue(users.LocationId);
                currentPassword = users.Password;

            }
            catch (System.Exception)
            {

            }
        }
示例#3
0
        public bool Insert(User users)
        {
            Database db = DatabaseFactory.CreateDatabase(Constant.DiaryDBConnectionString);
            DbCommand command = db.GetStoredProcCommand("usp_UserInsert");

            users.UserId = Guid.NewGuid();
            db.AddInParameter(command, "@UserId", DbType.Guid, users.UserId);
            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, "@Contact", DbType.String, users.Contact);
            db.AddInParameter(command, "@LastName", DbType.String, users.LastName);
            db.AddInParameter(command, "@EmailAddress", DbType.String, users.EmailAddress);
            db.AddInParameter(command, "@CreatedBy", DbType.Guid, users.CreatedBy);
            db.AddInParameter(command, "@JobId", DbType.Int32, users.JobId);
            db.AddInParameter(command, "@GradeId", DbType.Int32, users.GradeId);
            db.AddInParameter(command, "@LocationId", DbType.Int32, users.LocationId);
            db.AddInParameter(command, "@RoleId", DbType.Guid, users.RoleId);
            db.AddInParameter(command, "LoginAttempts", DbType.Int32, users.LoginAttempts);
            db.AddInParameter(command, "IsLocked", DbType.Boolean, users.IsLocked);

            db.ExecuteNonQuery(command);

            return true;
        }
示例#4
0
        public bool Delete(User users)
        {
            Database db = DatabaseFactory.CreateDatabase(Constant.DiaryDBConnectionString);
            DbCommand command = db.GetStoredProcCommand("usp_UserDelete");

            db.AddInParameter(command, "@UserId", DbType.Guid, users.UserId);
            db.ExecuteNonQuery(command);

            return true;
        }
示例#5
0
 public bool IsUserInSubModule(string subModule, User user)
 {
     bool returnValue = false;
     int count = user.AllRights.FindAll(e => e.SubModuleName.Trim() == subModule.Trim()).Count();
     if (count > 0)
     {
         returnValue = true;
     }
     return returnValue;
 }
示例#6
0
 public bool IsUserAuthorised(Common.Enum.Rights right, User user)
 {
     bool returnValue = false;
     int count = user.AllRights.FindAll(e => e.RightId == (int)right).Count();
     if (count > 0)
     {
         returnValue = true;
     }
     return returnValue;
 }
示例#7
0
        public bool Update(User users)
        {
            Database db = DatabaseFactory.CreateDatabase(Constant.DiaryDBConnectionString);
            DbCommand command = db.GetStoredProcCommand("usp_UserUpdate");

            db.AddInParameter(command, "@UserId", DbType.Guid, users.UserId.Value);
            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, "@Contact", DbType.String, users.Contact);
            db.AddInParameter(command, "@EmailAddress", DbType.String, users.EmailAddress);
            db.AddInParameter(command, "@UpdatedBy", DbType.Guid, users.UpdatedBy);
            db.AddInParameter(command, "@JobId", DbType.Int32, users.JobId);
            db.AddInParameter(command, "@GradeId", DbType.Int32, users.GradeId);
            db.AddInParameter(command, "@LocationId", DbType.Int32, users.LocationId);
            db.AddInParameter(command, "@RolesId", DbType.Int32, users.RoleId);

            db.ExecuteNonQuery(command);

            return true;
        }
示例#8
0
 public DataSet SelectAll(User users)
 {
     Database db = DatabaseFactory.CreateDatabase(Constant.DiaryDBConnectionString);
     DbCommand command = db.GetStoredProcCommand("usp_UserSelectAll");
     return db.ExecuteDataSet(command);
 }
示例#9
0
        protected bool UpdateData()
        {
            bool result = false;

            try
            {
                User users = new User();
                users.UserId = new Guid(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.UpdatedBy = Master.LoggedUser.UserId.Value;

                users.RoleId = new Guid(ddlRoles.Value.ToString());
                users.JobId = Convert.ToInt32(ddlJob.Value);
                users.LocationId = Convert.ToInt32(ddlLocation.Value);
                users.GradeId = Convert.ToInt32(ddlGrade.Value);

                if (users.Save())
                {
                    this.ClearFormData();
                }

            }
            catch (System.Exception)
            {

            }

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

            try
            {
                User users = new User();

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

                if (!users.IsUserIsDuplicateUserName(users.UserName))
                {
                    users.EmailAddress = txtEmail.Text.Trim();

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

                        users.Password = txtPassword.Text.Trim();
                        users.RoleId = new Guid(ddlRoles.Value.ToString());
                        users.LocationId = Convert.ToInt32(ddlLocation.Value);
                        users.GradeId = Convert.ToInt32(ddlGrade.Value);
                        users.JobId = Convert.ToInt32(ddlJob.Value);
                        users.Contact = txtContact.Text.Trim();

                        users.CreatedBy = Master.LoggedUser.UserId.Value;

                        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;
        }