protected void btnLogin_Click(object sender, EventArgs e)
        {
            UsersClass user = new UsersClass();
            lblErrorMessage.Text = string.Empty;
            user = UM.FindUser(txtUserName.Text);
            if (user == null)
            {
                lblErrorMessage.Text = "ERROR : USER NAME DOESN'T EXIST!";
                return;
            }

            if (UM.ConfirmPassword(txtPassword.Text) == false)
            {
                lblErrorMessage.Text = "ERROR : EMPTY OR WRONG PASSWORD!";
                return;
            }

            Session["USER_ID"] = txtUserName.Text;
            Session["CURRENT_DATE"] = DateTime.Now;
            Session["NET_SESSION_ID"] = Session.SessionID;
            Session["CLASSIC_SESSION_ID"] = "";
            Session["SHOW_CLASSIC_WINDOW"] = "FALSE";
            Session.Timeout = 30;

            SendToBridge(ref user);
        }
        protected void btnLogIn_Click(object sender, EventArgs e)
        {
            UsersClass user = new UsersClass();
            lblErrorMessage.Text = string.Empty;
            user = UM.FindUser(txtUsername.Text);
            if (user == null)
            {
                pnlError.Visible = true;
                lblErrorMessage.Text = "ERROR : USER NAME DOESN'T EXIST!";
                return;
            }

            if (UM.ConfirmPassword(txtPassword.Text) == false)
            {
                pnlError.Visible = true;
                lblErrorMessage.Text = "ERROR :WRONG PASSWORD!";
                return;
            }

            Session["USER_ID"] = txtUsername.Text;
            Session["CURRENT_DATE"] = DateTime.Now;
            Session["NET_SESSION_ID"] = Session.SessionID;
            Session["CLASSIC_SESSION_ID"] = "";
            Session["SHOW_CLASSIC_WINDOW"] = "FALSE";
            Session.Timeout = 30;

            SendToBridge(ref user);
               // Redirector.Redirect("~/Accounting/DashBoardPanel.aspx");
        }
        protected void btnLogIn_Click(object sender, EventArgs e)
        {
            UsersClass user = new UsersClass();

            if (Session["USER_ACCOUNT"] != null)
            {
                Redirector.Redirect("~/Accounting/DashBoardPanel.aspx");
            }
            else
            {
                lblErrorMessage.Text = string.Empty;

                user = UM.CheckUserAccount(txtUsername.Text, txtPassword.Text);

                if (user == null )
                {
                    pnlError.Visible = true;
                    lblErrorMessage.Text = "ERROR : USER ACCOUNT DOESN'T EXIST!";
                    return;
                }

                if (user.IsOnline == true)
                {
                    UM.UpdateOnlineStatus(user.ID, false);
                    //pnlError.Visible = true;
                    //lblErrorMessage.Text = "WARNING : USER ACCOUNT ALREADY ONLINE!";
                    //return;
                }
                Session["USER_ACCOUNT"] = user;
                Session["USER_ID"] = user.ID;
                Session["USER_NAME"] = user.Username;
                UM.UpdateOnlineStatus(user.ID, true);
                Session.Timeout = 30;
                Session["USER_ROLES"] = UserRoleManager.GetUserRolesByUserId((int)user.ID);

                #region init log action
                UM.SaveTransactionLog(user,TransactionType.LOGIN);
                #endregion
                Redirector.Redirect("~/Accounting/DashBoardPanel.aspx");
            }
            //Session["CURRENT_DATE"] = DateTime.Now;
            //Session["NET_SESSION_ID"] = Session.SessionID;
            //Session["CLASSIC_SESSION_ID"] = "";
            //Session["SHOW_CLASSIC_WINDOW"] = "FALSE";

            //SendToBridge(ref user);
        }
        private void SendToBridge(ref UsersClass user)
        {
            string sBridgeLocation = ConfigurationManager.AppSettings["BridgeLocation"];
            string sDefaultPage = ConfigurationManager.AppSettings["DefaultPage"];

            //string sLocation = ConfigurationManager.AppSettings["BridgeLocation"];
            //Response.Write("<form name='bridge' action='http://irms-svr:82/irmsbridge.asp' method='POST' Target='_blank'>");
            Response.Write("<form name='bridge' action='" + sBridgeLocation + "' method='POST'>");
            Response.Write("<input type=hidden name='sessionid' value='" + Session.SessionID + "' >");
            Response.Write("<input type=hidden name='unameid' value='" +  this.txtUsername.Text + "' >");
            Response.Write("<input type=hidden name='ulevelid' value='" + user.UserLevelID + "' >");
            Response.Write("<input type=hidden name='udeptid' value='" + user.DeptID + "' >");
            Response.Write("<input type=hidden name='defaultpage' value='" + sDefaultPage + "' >");
            Response.Write("</form>");
            Response.Write("<script>window.document.bridge.submit();</script>");
            Response.End();
        }
 protected void Page_Init(object sender, EventArgs e)
 {
     UsersClass user = new UsersClass();
     user = (UsersClass)Session["USER_ACCOUNT"];
     if (user != null)
     {
         UM.UpdateOnlineStatus(user.ID, false);
         Session.Clear();
         Session.Abandon();
     }
     else
     {
         Session.Clear();
         Session.Abandon();
         Redirector.Redirect("~/Accounting/Login.aspx");
     }
 }
        protected void btnYes_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(rdioGender.SelectedValue))
            {
                lblErrorMessage.Text = "Please Select user gender!";
                lblErrorModalHandler_ModalPopupExtender.Show();
                return;
            }
            if (string.IsNullOrEmpty(hfAvatarFileName.Value))
            {
                    if (rdioGender.SelectedValue == "Male")
                    {
                        hfAvatarFileName.Value = "maleicon.png";
                    }
                    else
                    {
                        hfAvatarFileName.Value = "femaleicon.png";
                    }
            }
            UsersClass NewUser = new UsersClass
            {
                 Avatar = hfAvatarFileName.Value,
                 ContactNumber = txtContactNumber.Text,
                 DeptID =int.Parse(DDLDepartments.SelectedValue),
                 Email = txtEmailAddress.Text ,
                 FullName = txtFullName.Text,
                 Gender = rdioGender.SelectedValue ,
                 UserLevelID = int.Parse(lboxUserLevel.SelectedValue),
                 Username = txtUserName.Text ,
                 UserPass = Security.EncryptStringAES(txtPassword.Text,Security.SECURITY_PASSWORD),
                  IsActive = true,
                   IsOnline =false
            };

               hfUserID.Value= UserManager.SaveaAndGetIdentity(NewUser).ToString();
               #region log
               UserManager.Identity = int.Parse(hfUserID.Value);
               UserManager.SaveTransactionLog(Permission.PERMITTED_USER, TransactionType.INSERT);
               #endregion
               SaveUserRoles();
            lblSuccessModalHandler_ModalPopupExtender.Show();
        }
        protected void btnDoneEditing_Click(object sender, EventArgs e)
        {
            btnUpdate.Visible = true;
            btnCancel.Visible = false;
            btnDoneEditing.Visible = false;
            pnlUploadAvatar.Visible = false;
            txtFullName.ReadOnly = true;
            txtEmailAddress.ReadOnly = true;
            txtContactNumber.ReadOnly = true;
            //update user account
            UsersClass UpdatedUserAccount = new UsersClass();
            UpdatedUserAccount.ID = USER.ID;
            UpdatedUserAccount.Username = USER.Username;
            UpdatedUserAccount.UserPass = USER.UserPass;
            UpdatedUserAccount.IsActive = USER.IsActive;
            UpdatedUserAccount.ContactNumber = txtContactNumber.Text;
            UpdatedUserAccount.DeptID = USER.DeptID;
            UpdatedUserAccount.Email = txtEmailAddress.Text;
            UpdatedUserAccount.Gender = USER.Gender;
            UpdatedUserAccount.UserLevelID = USER.UserLevelID;
            if (string.IsNullOrEmpty(hfAvatarFileName.Value))
            {
                UpdatedUserAccount.Avatar = USER.Avatar;
            }
            else
            {
                UpdatedUserAccount.Avatar = hfAvatarFileName.Value;
            }
            UpdatedUserAccount.FullName = txtFullName.Text;
            UserManager.Save(UpdatedUserAccount);

            #region log
            Permission.PERMITTED_USER = USER;
            UserManager.Identity =(int)USER.ID;
            UserManager.SaveTransactionLog(Permission.PERMITTED_USER, TransactionType.UPDATE);
            #endregion
            //reset UserAccount Session
            Session["USER_ACCOUNT"] = UpdatedUserAccount;
        }
 public UsersClass FindUser(string UserName)
 {
     systemuser = Accessor.FindUser(UserName);
     return systemuser;
 }