/// <summary>
        /// Updating the user information
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btSave_FormSubmit(object sender, EventArgs e)
        {
            bool bSavePassword = false, bSavePIN = false;
            string salt;
            try
            {
                user = new clsUsers();
                user.cAction = "U";
                user.iOrgId = OrgId;
                user.iId = UserId;

                if(tbNewPassword.Text.Length > 0 && tbConfirmPassword.Text.Length > 0)
                {
                    if(tbNewPassword.Text != tbConfirmPassword.Text)
                    {
                        lblComfirmPassword.Visible = true;
                        if(tbNewPIN.Text != tbConfirmPIN.Text)
                            lblConfirmPIN.Visible = true;
                        return;
                    }
                    else
                    {
                        bSavePassword = true;
                        lblConfirmPIN.Visible = false;
                    }
                }

                if(tbNewPIN.Text.Length > 0 && tbConfirmPIN.Text.Length > 0)
                {
                    if(tbNewPIN.Text != tbConfirmPIN.Text)
                    {
                        lblConfirmPIN.Visible = true;
                        return;
                    }
                    else
                    {
                        bSavePIN = true;
                        lblConfirmPIN.Visible = false;
                    }
                }

                user.sFirstName = tbFirstName.Text;
                user.sLastName = tbLastName.Text;
                user.sInitials = tbInitial.Text.ToUpper();
                user.sTypeName = ddlType.SelectedValue;
                user.sEmail = tbEmail.Text;
                user.iLoginId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true);
                user.daCreated = DateTime.Now;
                user.dmHourlyRate = Convert.ToDecimal(tbHourlyRate.Text);
                if(user.UserDetails() == -1)
                {
                    Session["lastpage"] = "admin_user_detail_edit.aspx?id=" + UserId.ToString();
                    Session["error"] = _functions.ErrorMessage(134);
                    Response.Redirect("error.aspx", false);
                    return;
                }

                if(bSavePassword || UserId == 0)
                {
                    // set a new password
                    salt = _functions.CreateSalt(5);
                    string passwordHash = _functions.CreatePasswordHash(tbNewPassword.Text, salt);

                    user.sPass = passwordHash;
                    user.sSalt = salt;
                    if(user.SetPassword() == -1)
                    {
                        Header.ErrorMessage = _functions.ErrorMessage(134);
                        return;
                    }
                }

                if(bSavePIN || UserId == 0)
                {
                    // set a new PIN code
                    user.sPIN = tbNewPIN.Text;
                    if(user.SetPIN() == -1)
                    {
                        Header.ErrorMessage = _functions.ErrorMessage(134);
                        return;
                    }
                }

                bool bRedirect = false;
                string sText = "";

                if(UserId == 0)
                {
                    bRedirect = true;
                    sText = "A new user has been added successfully!";
                    // adding group to user
                    user.cAction = "I";
                    user.iGroupId = Convert.ToInt32(ddlGroup.SelectedValue);
                    if(user.UsersGroupsDetail() == -1)
                    {
                        Session["lastpage"] = "admin_user_detail_edit.aspx?id=" + UserId.ToString();
                        Session["error"] = _functions.ErrorMessage(117);
                        Response.Redirect("error.aspx", false);
                        return;
                    }
                }
                else
                {
                    if(bSavePassword || bSavePIN)
                    {
                        bRedirect = true;
                        if(bSavePassword && bSavePIN)
                            sText = "The user's password and PIN Code have been sucessfully updated.";
                        else if(bSavePassword && !bSavePIN)
                            sText = "The user's password have been sucessfully updated.";
                        else if(!bSavePassword && bSavePIN)
                            sText = "The PIN Code have been sucessfully updated.";
                    }
                    else bRedirect = false;
                }
                if(bRedirect)
                {
                    // redirect to the finish screen
                    BackFinishScreen finish = new BackFinishScreen();

                    finish.sMainText = sText;

                    finish.bMainMenuVisible = true;
                    finish.sMainMenuText = "[Return to Main Menu]";
                    finish.sMainMenuURL = "selectMode.aspx";

                    finish.bContinueVisible = false;

                    finish.bViewVisible = true;
                    finish.sViewText = "[View the User Detail]";
                    finish.sViewURL = "admin_user_detail.aspx?id=" + user.iId.Value.ToString();

                    finish.bAdditionalVisible = false;

                    finish.bPrintVisible = false;

                    Session["BackFinish"] = finish;

                    Response.Redirect("wo_finish.aspx", false);
                }
                else
                    Response.Redirect("admin_user_detail.aspx?id=" + user.iId.Value.ToString(), false);
            }
            catch(FormatException fex)
            {
                Header.ErrorMessage = _functions.ErrorMessage(108);
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = "admin_user_detail_edit.aspx?id=" + UserId.ToString();
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(user != null)
                    user.Dispose();
            }
        }