private void xpButton18_Click(object sender, EventArgs e)
 {
     if (txtPassword.Text == txtConfirm.Text)
     {
         User us = new User();
         if (userId != 0)
         {
             us.LoadByPrimaryKey(userId);
             string userName = us.UserName;
             us.GetUserByAccountInfo(userName, txtOldPass.Text);// .LoadByPrimaryKey(userId);
             if (us.RowCount > 0)
             {
                 if (txtPassword.Text != "")
                 {
                     us.SavePassword(txtPassword.Text);
                 }
                 //us.Password = txtPassword.Text;
                 us.Save();
                 XtraMessageBox.Show(@"Password changed!", @"Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 XtraMessageBox.Show("Old Password is not correct!", "Invaild Password", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     else
     {
         MessageBox.Show("Password doesnt match!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        /// <summary>
        /// Saves the password change.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void xpButton18_Click(object sender, EventArgs e)
        {
            if (txtPassword.Text == txtConfirm.Text)
            {
                var us = new User();
                if (userId != 0)
                {
                    us.LoadByPrimaryKey(userId);
                    if (us.UserName != "admin")
                    {
                        XtraMessageBox.Show("You have no administative privilage to change password!", "Warning");
                        return;
                    }
                    if (us.Password == txtOldPass.Text)
                        {
                            us.Password = txtPassword.Text;
                            us.Save();
                            XtraMessageBox.Show("The password have been changed!", "Succcess");
                        }
                        else
                        {
                            XtraMessageBox.Show("Old Password is not correct!", "Invaild Password", MessageBoxButtons.OK,
                                                MessageBoxIcon.Error);
                        }

                }
            }
            else
            {
                XtraMessageBox.Show("Password doesnt match!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            bool isNew = false;
            if (txtConfirm.Text == txtPassword.Text && cboUserType.SelectedValue != null)
            {
                User us = new User();
                if (userId != 0)
                {
                    us.LoadByPrimaryKey(userId);
                }
                else
                {
                    us.AddNew();
                    isNew = true;
                }

                us.UserName = txtUsername.Text;
                us.FullName = txtFullName.Text;
                us.Address = txtAddress.Text;
                us.Mobile = txtMobile.Text;
                us.Active = ckActive.Checked;
                us.UserType = Convert.ToInt32(cboUserType.SelectedValue);
                us.Save();
                int userID = us.ID;
                // DO MD5
                if (txtPassword.Text != "")
                {
                    us.SavePassword(txtPassword.Text);
                }

                RefreshUserStoreGrid(userID);
                PopulateUser();
                XtraMessageBox.Show("Your changes have been saved!", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
                XtraMessageBox.Show("Password doesnt match or you didnt select User Type!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
 /// <summary>
 /// Save user information
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (txtConfirm.Text == txtPassword.Text)
     {
         User us = new User();
         if (_userId != 0)
             us.LoadByPrimaryKey(_userId);
         else
         {
             us.AddNew();
             us.UserName = txtUsername.Text;
             us.Password = txtPassword.Text;
         }
         us.FullName = txtFullName.Text;
         us.Address = txtAddress.Text;
         us.Mobile = txtMobile.Text;
         us.Active = ckActive.Checked;
         us.UserType = Convert.ToInt32(cboUserType.SelectedValue);
         us.Save();
         PopulateUser();
     }
     else
         XtraMessageBox.Show("Password doesnt match!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
 }