Example #1
0
 public frmUserPassword()
 {
     InitializeComponent();
     userbal      = new UserBAL();
     err          = new ErrorProviderExtended();
     current_user = new tbl_000_USER();
 }
Example #2
0
 public tbl_000_USER GetByUsername(string username, Boolean IsEncrypted = false)
 {
     try
     {
         if (username == null)
         {
             throw new Exception("Invalid Parameter!");
         }
         tbl_000_USER exist = new tbl_000_USER();
         exist = compdal.GetByUsername(username);
         if (exist == null)
         {
             throw new Exception("Record does not exist!");
         }
         if (!IsEncrypted)
         {
             exist.Password = compdal.BreakPassword(exist.Password, Convert.ToDateTime(exist.DateCreated));
         }
         return(exist);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #3
0
 private void AssignRecord(Boolean IsSave)
 {
     try
     {
         if (IsSave)
         {
             usr.UserID        = usr.UserID;
             usr.Username      = mtxtUsername.Text;
             usr.Password      = mtxtPassword.Text;
             usr.FullName      = mtxtFullName.Text;
             usr.UserGroupCode = mcboUserGroupCode.SelectedValue.ToString();
             usr.UserGroupDesc = mcboUserGroupCode.Text;
             usr.SectionCode   = BPSUtilitiesV1.NZ(mcboSectionCode.SelectedValue, "").ToString();
             usr.SectionDesc   = BPSUtilitiesV1.NZ(mcboSectionCode.Text, "").ToString();
             usr.AccessLevel   = mtxtAccessLevel.Text;
             usr.IsActive      = mcbActive.Checked;
             if (ofdImage.FileName != "")
             {
                 usr.UserPhoto = BPSolutionsTools.BPSUtilitiesV1.ImageToByte(Image.FromFile(ofdImage.FileName));
             }
         }
         else
         {
             usr = userbal.GetByUsername(username);
             if (usr != null)
             {
                 mtxtUsername.Text               = usr.Username;
                 mtxtPassword.Text               = usr.Password;
                 mtxtConfirmPassword.Text        = usr.Password;
                 mtxtFullName.Text               = usr.FullName;
                 mcboUserGroupCode.SelectedValue = usr.UserGroupCode;
                 mcboSectionCode.SelectedValue   = usr.SectionCode;
                 //mcboSectionCode.Text=usr.SectionDesc;
                 mtxtAccessLevel.Text = usr.AccessLevel;
                 mcbActive.Checked    = usr.IsActive;
                 if (usr.UserPhoto != null)
                 {
                     picUser.BackgroundImage = BPSolutionsTools.BPSUtilitiesV1.BytesToImage(usr.UserPhoto);
                 }
             }
             else
             {
                 throw new Exception("Record doesn't exist!");
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
     }
 }
Example #4
0
 private void ChangePass()
 {
     current_user = userbal.GetByUsername(UserSettings.Username);
     err.Clear();
     if (current_user.Password == mtxtOldPass.Text)
     {
         if (mtxtNewPass.Text != "" && mtxtConPass.Text != "")
         {
             if (mtxtNewPass.Text == mtxtConPass.Text)
             {
                 current_user.Password = mtxtConPass.Text;
                 if (MessageHelpers.ShowQuestion("Are you sure want to change your password?") == DialogResult.Yes)
                 {
                     if (userbal.Update(current_user))
                     {
                         MessageHelpers.ShowInfo("Password successfully changed.");
                         this.Close();
                     }
                     else
                     {
                         throw new Exception("Error occured!");
                     }
                 }
             }
             else
             {
                 err.SetError(mtxtConPass, "Passwords entered does not match!");
             }
         }
         else
         {
             if (mtxtNewPass.Text == "")
             {
                 err.SetError(mtxtNewPass, "Required");
             }
             else if (mtxtNewPass.Text == "")
             {
                 err.SetError(mtxtConPass, "Required");
             }
             else
             {
                 err.SetError(mtxtNewPass, "Required");
                 err.SetError(mtxtConPass, "Required");
             }
         }
     }
     else
     {
         err.SetError(mtxtOldPass, "Please enter your old password!");
     }
     err.CheckAndShowSummaryErrorMessage();
 }
Example #5
0
        public frmUserProfile()
        {
            // constructors;
            InitializeComponent();
            userbal      = new UserBAL();
            usergroupbal = new UserGroupBAL();
            sectionbal   = new SectionBAL();
            usr          = new tbl_000_USER();
            err          = new ErrorProviderExtended();

            //get default length for username and password;
            MaxUsernameLenght = PWCOSTINGV1.Properties.Settings.Default.intUsernameLenght;
            MaxPasswordLength = PWCOSTINGV1.Properties.Settings.Default.intPasswordLength;
        }
Example #6
0
 public tbl_000_USER GetByUsername(string username)
 {
     try
     {
         Renew();
         tbl_000_USER record = db.UserList.Where(m => m.Username == username).FirstOrDefault();
         if (record != null)
         {
             record.UserGroup          = db.UserGroupList.Where(n => n.UserGroupCode == record.UserGroupCode).FirstOrDefault();
             record.UserGroup.MenuList = db.UserGroupMenuList.Where(o => o.UserGroupCode == record.UserGroupCode).ToList();
             record.MenuList           = db.MenuList.ToList();
         }
         return(record);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #7
0
 public Boolean Save(tbl_000_USER record)
 {
     try
     {
         if (record == null)
         {
             throw new Exception("Invalid Parameter");
         }
         if (compdal.IsExistUsername(record.Username))
         {
             throw new Exception("Record already exist!");
         }
         return(compdal.Save(record));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #8
0
 public Boolean Delete(tbl_000_USER record)
 {
     try
     {
         if (record == null)
         {
             throw new Exception("Invalid Parameter!");
         }
         if (!compdal.IsExistUsername(record.Username))
         {
             throw new Exception("Record does not exist!");
         }
         return(compdal.Delete(record));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #9
0
 public Boolean Delete(tbl_000_USER record)
 {
     using (var dbContextTransaction = db.Database.BeginTransaction())
     {
         try
         {
             Renew();
             var existrecord = GetByUsername(record.Username);
             db.UserList.Remove(existrecord);
             db.SaveChanges();
             dbContextTransaction.Commit();
             return(true);
         }
         catch (Exception ex)
         {
             dbContextTransaction.Rollback();
             throw ex;
         }
     }
 }
Example #10
0
 public Boolean Save(tbl_000_USER record)
 {
     using (var dbContextTransaction = db.Database.BeginTransaction())
     {
         try
         {
             Renew();
             record.Password = ComputePassword(record.Password, Convert.ToDateTime(record.DateCreated));
             db.UserList.Add(record);
             db.SaveChanges();
             dbContextTransaction.Commit();
             return(true);
         }
         catch (Exception ex)
         {
             dbContextTransaction.Rollback();
             throw ex;
         }
     }
 }
Example #11
0
 public Boolean Update(tbl_000_USER record)
 {
     using (var dbContextTransaction = db.Database.BeginTransaction())
     {
         try
         {
             Renew();
             var existrecord = GetByUsername(record.Username);
             record.Password = ComputePassword(record.Password, Convert.ToDateTime(record.DateCreated));
             db.Entry(existrecord).CurrentValues.SetValues(record);
             db.SaveChanges();
             dbContextTransaction.Commit();
             return(true);
         }
         catch (Exception ex)
         {
             dbContextTransaction.Rollback();
             throw ex;
         }
     }
 }