Exemplo n.º 1
0
        protected static string GetUserName(HttpRequest request)
        {
            string strUserName = "";

            strUserName = PH_Utility.GetCookie(request, ConfigurationManager.AppSettings["PH_NameUserCookie"]);
            return(strUserName == "" ? strUserName : PH_EncrptHelper.MD5Decryp(strUserName));
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Session["s_forceChange"] as string))
            {
                if (HttpContext.Current.Request.Url.AbsolutePath.Substring(HttpContext.Current.Request.Url.AbsolutePath.Length - 19, 19) != "changepassword.aspx")
                {
                    Response.Redirect(Session["s_forceChange"].ToString(), false);
                }
            }
            if (!IsPostBack)
            {
                //lnkChangePasswd.HRef = "changepassword.aspx?" + Request.QueryString;
                //lnkDayofExpired.HRef = "dayofexpired.aspx?" + Request.QueryString;

                if (PH_Utility.GetCookie(Request, ConfigurationManager.AppSettings["PH_NameUserCookie"]) == "" && PH_Utility.GetCookie(Request, ConfigurationManager.AppSettings["PH_RoleUserCookie"]) == "")
                {
                    Response.Redirect("login.aspx", false);
                }
                //else if (Request["id"] == null) Response.Redirect("logout.aspx", false);
                else
                {
                    eStatus = new PHCore_Status();
                    string strRoleId = PH_EncrptHelper.MD5Decryp(PH_Utility.GetCookie(Request, ConfigurationManager.AppSettings["PH_RoleUserCookie"]));
                    if (strRoleId != "")
                    {
                        eStatus.RoleId = (PHCore_Status.RoleID)Enum.Parse(typeof(PHCore_Status.RoleID), strRoleId, true);
                    }

                    GenMenu();
                }
            }
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //lnkChangePasswd.HRef = "changepassword.aspx?" + Request.QueryString;
                //lnkDayofExpired.HRef = "dayofexpired.aspx?" + Request.QueryString;

                if (PH_Utility.GetCookie(Request, ConfigurationManager.AppSettings["PH_NameUserCookie"]) == "" && PH_Utility.GetCookie(Request, ConfigurationManager.AppSettings["PH_RoleUserCookie"]) == "")
                {
                    Response.Redirect("login.aspx", false);
                }
                else if (Request["id"] == null)
                {
                    Response.Redirect("logout.aspx", false);
                }
                else
                {
                    eStatus = new PHCore_Status();
                    string strRoleId = PH_EncrptHelper.MD5Decryp(PH_Utility.GetCookie(Request, ConfigurationManager.AppSettings["PH_RoleUserCookie"]));
                    if (strRoleId != "")
                    {
                        eStatus.RoleId = (PHCore_Status.RoleID)Enum.Parse(typeof(PHCore_Status.RoleID), strRoleId, true);
                    }

                    GenMenu();
                }
            }
        }
Exemplo n.º 4
0
        private void InsertUserProfile()
        {
            try
            {
                List <PrimaryHaul_WS.AppCode_DS.PHDS_User.User_VendorRow> drVenders = new List <PrimaryHaul_WS.AppCode_DS.PHDS_User.User_VendorRow>();
                PrimaryHaul_WS.AppCode_DS.PHDS_User.User_ProfileRow       drProfile = new PrimaryHaul_WS.AppCode_DS.PHDS_User.User_ProfileDataTable().NewUser_ProfileRow();


                #region Row Profile
                drProfile.UserType            = GetRoleId();
                drProfile.RoleID              = GetRoleId();//(Request["r"] != null && Request["r"] != "") ? Request["r"].ToString().ToUpper() : GetRoleId().ToString();
                drProfile.UserName            = txtUserName.Text;
                drProfile.Passwd              = PH_EncrptHelper.MD5Encryp(txtPassword.Text);
                drProfile.FullName_En         = txtEngName.Text;
                drProfile.FullName_Th         = txtTHAName.Text;
                drProfile.Mobile              = txtMobile.Text;
                drProfile.EMail_Address       = txtEmail.Text;
                drProfile.User_Status         = rdoStatusA.Checked?"A":"D";
                drProfile.TaxID               = txtHaulierCode.Text;
                drProfile.Contact_Person      = txtContact.Text;
                drProfile.StampTime           = DateTime.Now;
                drProfile.Passwd_Expired_Date = chkForepasswrd.Checked ? DateTime.Now : DateTime.ParseExact(txtPasswrdExpried.Text, ConfigurationManager.AppSettings["PH_Date_format"], null);
                #endregion

                #region Vendor
                if (txtTaxId.Text != "")
                {
                    PrimaryHaul_WS.AppCode_DS.PHDS_User.User_VendorRow drVendor;
                    string[] strVendorsId = txtTaxId.Text.Split(',');
                    foreach (string strVendor in strVendorsId)
                    {
                        if (strVendor.Trim() != "")
                        {
                            drVendor             = new PrimaryHaul_WS.AppCode_DS.PHDS_User.User_VendorDataTable().NewUser_VendorRow();
                            drVendor.Vendor_Code = strVendor.Trim();
                            drVendor.StampTime   = DateTime.Now;
                            drVenders.Add(drVendor);
                        }
                    }
                }
                #endregion

                PHCore_Status status = new PHCore_User().PH_Flow_UserInsert(AppCode.strConnDB, drProfile, drVenders);

                if (status.Status == PHCore_Status.SignInStatus.Success)
                {
                    Response.Redirect("addnew.aspx?" + Request.QueryString, false);
                }
                else
                {
                    lblError.Text = status.Message;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 5
0
 private void storeUser(PrimaryHaul_WSFlow.PHCore_Status status)
 {
     try
     {
         PH_Utility.CreateCookie(PH_EncrptHelper.MD5Encryp(status.UserName), Response, ConfigurationManager.AppSettings["PH_NameUserCookie"], int.Parse(ConfigurationManager.AppSettings["PH_TimeUserCookie"]));
         PH_Utility.CreateCookie(PH_EncrptHelper.MD5Encryp(status.RoleId.ToString()), Response, ConfigurationManager.AppSettings["PH_RoleUserCookie"], int.Parse(ConfigurationManager.AppSettings["PH_TimeUserCookie"]));
         PH_Utility.CreateCookie(PH_EncrptHelper.MD5Encryp(status.Status.ToString()), Response, ConfigurationManager.AppSettings["PH_StatusUserCookie"], int.Parse(ConfigurationManager.AppSettings["PH_TimeUserCookie"]));
     }
     catch (Exception ex)
     {
         throw new Exception("storeUser >>" + ex.Message);
     }
 }
Exemplo n.º 6
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     try
     {
         if (PH_EncrptHelper.MD5Decryp(Request["p"]) == txtPassword.Text)
         {
             lblErr.Text = ConfigurationManager.AppSettings["PH_Error_PasswordExpired"];
         }
         else
         {
             var rtn = PHCore_User.ChangePasswd(AppCode.strConnDB, Request["id"], txtPassword.Text, DateTime.ParseExact(txtPasswordExpired.Text, "dd/MM/yyyy", null));
             if (rtn > 0)
             {
                 Response.Redirect("login.aspx", false);
             }
         }
     }
     catch (Exception ex)
     {
         lblErr.Text = ex.Message;
         PH_ExceptionManager.WriteError(ex.Message);
     }
 }
Exemplo n.º 7
0
 protected void btnLogin_Click(object sender, EventArgs e)
 {
     try {
         PrimaryHaul_WSFlow.PHCore_Status status = PrimaryHaul_WSFlow.PHCore_Login.UserSignIn(AppCode.strConnDB, txtUserName.Text, txtPassword.Text);
         if (status.Status == PrimaryHaul_WSFlow.PHCore_Status.SignInStatus.Success)
         {
             storeUser(status);
             Response.Redirect("index.aspx?r=" + status.RoleId + "&id=" + status.UserId, false);
         }
         else if (status.Status == PrimaryHaul_WSFlow.PHCore_Status.SignInStatus.PasswordExpired)
         {
             storeUser(status);
             Response.Redirect("changepassword.aspx?r=" + status.RoleId + "&p=" + PH_EncrptHelper.MD5Encryp(txtPassword.Text) + "&id=" + status.UserId, false);
         }
     }
     catch (Exception ex)
     {
         lblErr.Text = ex.Message;
         PH_ExceptionManager.WriteError(ex.Message);
     }
 }
Exemplo n.º 8
0
        public static PHCore_Status UserSignIn(string strConnDB, string strUserName, string strPassword)
        {
            try
            {
                PHCore_Status eStatus = new PHCore_Status();
                DataTable     dtUser  = PH_UserProfile.PH_UserProfile_SigIn(strConnDB, strUserName, PH_EncrptHelper.MD5Encryp(strPassword));
                if (dtUser != null && dtUser.Rows.Count > 0)
                {
                    DateTime dtPassExpired = (DateTime)dtUser.Rows[0]["Passwd_Expired_Date"];
                    if (DateTime.Now > dtPassExpired)
                    {
                        eStatus.Status = PHCore_Status.SignInStatus.PasswordExpired;
                    }
                    else
                    {
                        eStatus.Status = PHCore_Status.SignInStatus.Success;
                    }


                    eStatus.UserId     = dtUser.Rows[0]["userid"].ToString();
                    eStatus.UserName   = dtUser.Rows[0]["username"].ToString();
                    eStatus.UserStatus = dtUser.Rows[0]["User_Status"].ToString();
                    eStatus.RoleId     = (PHCore_Status.RoleID)Enum.Parse(typeof(PHCore_Status.RoleID), dtUser.Rows[0]["roleid"].ToString(), true);
                }
                else
                {
                    eStatus.Status = PHCore_Status.SignInStatus.Failure;
                }
                //eStatus = Microsoft.AspNet.Identity.Owin.SignInStatus.Success;
                return(eStatus);
            }
            catch (Exception ex)
            {
                throw new Exception("UserSignIn >> " + ex.Message);
            }
        }
Exemplo n.º 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            main_function PPHfunction = new main_function();

            PPHfunction.QueryExecuteNonQuery("update User_Profile set Passwd_Expired_Date='" + DateTime.Now + "', Passwd='" + PH_EncrptHelper.MD5Encryp("P@ssw0rd") + "' WHERE UserID='" + PPHfunction.decodeBase64(Request.QueryString["Param"].ToString()) + "'");

            Response.Write("<script>alert('Password Reset Already');window.location.href='../../../.." + PPHfunction.decodeBase64(Request.QueryString["url"].ToString()) + "';</script>");
        }
Exemplo n.º 10
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     TextBox1.Text = PH_EncrptHelper.MD5Decryp(TextBox1.Text);
 }
Exemplo n.º 11
0
 protected void btnLogin_Click(object sender, EventArgs e)
 {
     Session["s_forceChangeMsg"] = "";
     try {
         PrimaryHaul_WSFlow.PHCore_Status status = PrimaryHaul_WSFlow.PHCore_Login.UserSignIn(AppCode.strConnDB, txtUserName.Text, txtPassword.Text);
         if (status.UserStatus == "D")
         {
             lblErr.Text = "Please contact System Administrator";
         }
         else
         {
             if (status.Status == PrimaryHaul_WSFlow.PHCore_Status.SignInStatus.Success)
             {
                 storeUser(status);
                 Session["s_forceChange"] = "";
                 Session["s_userID"]      = status.UserId;
                 if (status.RoleId.ToString() == "VD")
                 {
                     Response.Redirect("report_venderlog.aspx?r=" + status.RoleId + "&id=" + status.UserId, false);
                 }
                 else if (status.RoleId.ToString() == "HL")
                 {
                     Response.Redirect("haulier_upload.aspx?r=" + status.RoleId + "&id=" + status.UserId, false);
                 }
                 else
                 {
                     Response.Redirect("index.aspx?r=" + status.RoleId + "&id=" + status.UserId, false);
                 }
             }
             else if (status.Status == PrimaryHaul_WSFlow.PHCore_Status.SignInStatus.PasswordExpired)
             {
                 storeUser(status);
                 if (txtPassword.Text == "P@ssw0rd")
                 {
                     Session["s_forceChangeMsg"] = "password was reset. Please enter new password.";
                 }
                 else
                 {
                     Session["s_forceChangeMsg"] = "your password has expired. Please enter new password.";
                 }
                 Session["s_forceChange"] = "changepassword.aspx?r=" + status.RoleId + "&p=" + PH_EncrptHelper.MD5Encryp(txtPassword.Text) + "&id=" + status.UserId;
                 Response.Redirect("changepassword.aspx?r=" + status.RoleId + "&p=" + PH_EncrptHelper.MD5Encryp(txtPassword.Text) + "&id=" + status.UserId, false);
             }
             else
             {
                 lblErr.Text = "User Name or Password incorrect";
             }
         }
     }
     catch (Exception ex)
     {
         lblErr.Text = ex.Message;
         PH_ExceptionManager.WriteError(ex.Message);
     }
 }
Exemplo n.º 12
0
 /// <summary>
 /// ChangePasswd
 /// </summary>
 /// <param name="strConnDB"></param>
 /// <param name="strUserId"></param>
 /// <param name="strPasswd"></param>
 /// <param name="dtPasswdExp"></param>
 /// <returns></returns>
 public static int ChangePasswd(string strConnDB, string strUserId, string strPasswd, DateTime dtPasswdExp)
 {
     try
     {
         return(PH_UserProfile.PH_UserProfile_ChangePasswd(strConnDB, strUserId, PH_EncrptHelper.MD5Encryp(strPasswd), dtPasswdExp));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemplo n.º 13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    /*eStatus = new PHCore_Status();
                     * string strRoleId = PH_EncrptHelper.MD5Decryp(PH_Utility.GetCookie(Request, ConfigurationManager.AppSettings["PH_RoleUserCookie"]));
                     * if( strRoleId != "" )
                     * eStatus.RoleId = (PHCore_Status.RoleID)Enum.Parse(typeof(PHCore_Status.RoleID), strRoleId, true);*/

                    #region Check Type
                    string[] type = (Request["type"] != null) ? Request["type"].Split(',') : null;
                    if (type != null && type[0] == PHCore_Status.RoleID.A1.ToString())
                    {
                        divContact.Visible = false;
                        divHaulier.Visible = false;
                        divVender.Visible  = false;
                    }
                    else if (type != null && type[0] == PHCore_Status.RoleID.HL.ToString())
                    {
                        divVender.Visible = false;
                        divRole.Visible   = false;
                    }
                    else if (type != null && type[0] == PHCore_Status.RoleID.VD.ToString())
                    {
                        divHaulier.Visible = false;
                        divRole.Visible    = false;
                        divVender.Visible  = false;
                    }
                    else if (type != null && type[0] == PHCore_Status.RoleID.B1.ToString())
                    {
                        divContact.Visible = false;
                        divHaulier.Visible = false;
                        divVender.Visible  = false;
                    }
                    else if (type != null && type[0] == PHCore_Status.RoleID.F1.ToString())
                    {
                        divContact.Visible = false;
                        divHaulier.Visible = false;
                        divVender.Visible  = false;
                    }
                    else if (type != null && type[0] == PHCore_Status.RoleID.I1.ToString())
                    {
                        divContact.Visible = false;
                        divHaulier.Visible = false;
                        divVender.Visible  = false;
                    }
                    else if (type != null && type[0] == PHCore_Status.RoleID.BH.ToString())
                    {
                        divHaulier.Visible = false;
                        divRole.Visible    = false;
                        divVender.Visible  = false;
                    }
                    else
                    {
                        Response.Redirect("logout.aspx", false);
                    }
                    #endregion


                    if (PH_EncrptHelper.MD5Decryp(Request.Cookies["PH_RoleUserCookie"].Value) == "A2" && Request.QueryString["type"].ToString() != "VD")
                    {
                        btnSubmit.Style["visibility"] = "hidden";
                    }
                    lblHeader.Text         = (type != null) ? ConfigurationManager.AppSettings["PH_AddNew_" + type[0]] : "";
                    txtPasswrdExpried.Text = DateTime.Now.AddDays(AppCode.GetDayofPasswdExp(Page)).ToString("dd/MM/yyyy");
                }

                catch (Exception ex)
                {
                    lblError.Text = ex.Message;
                    PH_ExceptionManager.WriteError(ex.Message);
                }
            }
        }
Exemplo n.º 14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            main_function PPHfunction = new main_function();

            //Response.Write(Request.QueryString["force"].ToString());
            if (Request.QueryString["force"].ToString() == "Y")
            {
                PPHfunction.QueryExecuteNonQuery("update User_Profile set User_Status='" + Request.QueryString["status"].ToString() + "', Passwd_Expired_Date='" + DateTime.Now + "', Passwd='" + PH_EncrptHelper.MD5Encryp("P@ssw0rd") + "' WHERE UserID='" + Request.QueryString["id"].ToString() + "'");
            }
            else
            {
                PPHfunction.QueryExecuteNonQuery("update User_Profile set User_Status='" + Request.QueryString["status"].ToString() + "' WHERE UserID='" + Request.QueryString["id"].ToString() + "'");
            }
            Response.Write("<script>alert('Status Updated Success');window.location.href='../../../.." + PPHfunction.decodeBase64(Request.QueryString["url"].ToString()) + "';</script>");
        }