예제 #1
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);
            }
        }
예제 #2
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);
     }
 }
예제 #3
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);
     }
 }
예제 #4
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);
            }
        }
예제 #5
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>");
        }
예제 #6
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);
     }
 }
예제 #7
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);
     }
 }
예제 #8
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>");
        }