示例#1
0
    private void BindGrid()
    {
        MasterUserLogDAL _dalMasterUserLog = null;
        Hashtable        _htParameters     = null;

        try
        {
            _dalMasterUserLog = new MasterUserLogDAL();
            _htParameters     = new Hashtable();

            _htParameters["p_keywords"] = txtSearch.Text;

            gvwList.DataSource = _dalMasterUserLog.GetRows(_htParameters);
            gvwList.DataBind();
        }
        catch (Exception ex)
        {
            Utility.ShowMessageBox(this, Utility.LOAD_DATA_FAIL_MESSAGE, ex, null, null);
        }
    }
示例#2
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        MasterUserDAL    _dalMasterUser    = null;
        MasterUserLogDAL _dalMasterUserLog = null;


        Hashtable htParameters = null;

        try
        {
            //System.Diagnostics.Debugger.Break();
            _dalMasterUser    = new MasterUserDAL();
            _dalMasterUserLog = new MasterUserLogDAL();

            htParameters = new Hashtable();

            htParameters["p_user_id"]       = txtUID.Text;
            htParameters["p_user_password"] = txtUPass.Text;

            DataTable dt = _dalMasterUser.ValidateLogin(htParameters);

            if (dt.Rows[0]["is_active_flag"].ToString().Equals("1"))
            {
                Session[SessionKey.CURRENT_USER_SESSION_KEY]      = dt.Rows[0];
                Session[SessionKey.CURRENT_ENTITY_SESSION_KEY]    = ddlCompany.SelectedItem.Value;
                Session[SessionKey.CURRENT_ENTITY_SESSION_XDESCS] = ddlCompany.SelectedItem.Text;
                Session[SessionKey.CURRENT_PASSWORD_SESSION_KEY]  = txtUPass.Text;
                Session[SessionKey.CURRENT_USER_HRMS_ROLE]        = dt.Rows[0].Field <string>(3);
                Session[SessionKey.CURRENT_USER_HRMS_EMP_CODE]    = dt.Rows[0].Field <string>(4);
                Session[SessionKey.CURRENT_USER_HRMS_EMP_NAME]    = dt.Rows[0].Field <string>(5);
                Session[SessionKey.CURRENT_USER_HRMS_ROLE_DESC]   = dt.Rows[0].Field <string>(6);


                if (String.IsNullOrEmpty(dt.Rows[0].Field <string>(4)))
                {
                    Utility.ShowMessageBoxAnas(this, "Pengguna belum terdaftar !!!", "Information");
                    return;
                }
                htParameters["ddlValue"] = ddlCompany.SelectedItem.Value;

                if (Request.ServerVariables["HTTP_X_FORWARDED_FOR"] == null)
                {
                    Session[SessionKey.CURRENT_USER_IP_ADDRESS_SESSION_KEY] = Request.ServerVariables["REMOTE_ADDR"];
                }
                else
                {
                    Session[SessionKey.CURRENT_USER_IP_ADDRESS_SESSION_KEY] = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
                }


                #region Insert into log
                htParameters.Clear();
                htParameters["p_user_id"]          = txtUID.Text;
                htParameters["p_login_date"]       = DateTime.Now;
                htParameters["p_login_ip_address"] = Utility.CurrentIPAddress;
                _dalMasterUserLog.Insert(htParameters);
                #endregion


                #region Update Last Login Date
                htParameters.Clear();
                htParameters["p_user_id"]         = txtUID.Text;
                htParameters["p_last_login_date"] = DateTime.Now;
                _dalMasterUser.UpdateLastLoginDate(htParameters);
                #endregion


                #region Retrive User Roles
                GetUserRoles();
                #endregion

                Response.Redirect("main.aspx");
            }
            else
            {
                Utility.ShowMessageBox(this, "User ID is not active", null, null, null);
            }
        }
        catch (Exception ex)
        {
            Utility.ShowMessageBox(this, "Fail to login to system", ex, null, null);
        }
    }