protected void Button1_Click(object sender, EventArgs e) { MemberDA da = new MemberDA(); if (!string.IsNullOrEmpty(TextBox1.Text) && !string.IsNullOrEmpty(TextBox2.Text)) { if (da.mem_Login(TextBox1.Text, TextBox2.Text) == 1) { Session["m_id"] = da.m_id.ToString(); Session["name"] = da.name.ToString(); Session["birthday"] = da.birthday.ToString(); Session["phone"] = da.phone.ToString(); Session["cellphone"] = da.cellphone.ToString(); Session["city"] = da.city.ToString(); Session["district"] = da.district.ToString(); Session["address"] = da.address.ToString(); Session["email"] = da.email.ToString(); Response.Redirect("~/index.aspx"); } else { Response.Write("<script>alert('帳號密碼錯誤!')</script>"); } } else { Response.Write("<script>alert('請輸入帳號密碼!')</script>"); } }
public int mem_verify(string password) { int count = 0; MemberDA memDA = new MemberDA(); count = memDA.mem_verify(password); return(count); }
public int mem_new(string username, string password, string name, string sex, DateTime birthday, string phone, string cellphone, string address, string email) { int count = 0; MemberDA memDA = new MemberDA(); count = memDA.mem_new(username, password, name, sex, birthday, phone, cellphone, address, email); return(count); }
public int check_username(string username) { int count = 0; MemberDA memDA = new MemberDA(); count = memDA.check_username(username); return(count); }
public int mem_update(string id, string name, string sex, string phone, string cellphone, string address, string email) { int count = 0; MemberDA memDA = new MemberDA(); count = memDA.mem_update(id, name, sex, phone, cellphone, address, email); return(count); }
public int order_Del(string orderID) { int count = 0; MemberDA memDA = new MemberDA(); count = memDA.order_Del(orderID); return(count); }
public int modify_pw(string username, string password, string newpassword) { int count = 0; MemberDA memDA = new MemberDA(); count = memDA.modify_pw(username, password, newpassword); return(count); }
public int forget_pw(string password, string username, string birthday, string email) { int count = 0; MemberDA memDA = new MemberDA(); count = memDA.forget_pw(password, username, birthday, email); return(count); }
/* PayPal IPN 及時付款通知設定 當user付完款項後PayPal IPN會回傳自訂屬性"oid"訂單編號, 並比對資料庫欄位將欄位修改為"已付款" */ #region PayPal_IPN public void PayPal_IPN() { //傳送資訊至PayPal伺服器 HttpWebRequest req = (HttpWebRequest)WebRequest.Create(GetPayPalUrl()); //設定要請求的資料 req.Method = "POST";//以POST方式傳送資料 req.ContentType = "application/x-www-form-urlencoded";//以x-www-form-urlencoded的編碼方式把form轉換成字串 System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;//加入Tls12安全協定 byte[] param = HttpContext.Current.Request.BinaryRead(HttpContext.Current.Request.ContentLength); string strRequest = Encoding.ASCII.GetString(param);//解碼為字串 strRequest += "&cmd=_notify-validate"; req.ContentLength = strRequest.Length;//HTTP 標頭。 //發送請求到PayPal伺服器 StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);//以ASCII編碼方式將req變數資料寫入資料流 streamOut.Write(strRequest); streamOut.Close(); //取得PayPal回傳的資訊 StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream()); string strResponse = streamIn.ReadToEnd(); streamIn.Close(); /* PayPal回傳的訂單資訊 string item_name = HttpContext.Current.Request.Form["item_name"]; string item_number = HttpContext.Current.Request.Form["item_number"]; string payment_amount = HttpContext.Current.Request.Form["mc_gross"]; string payment_currency = HttpContext.Current.Request.Form["mc_currency"]; string txn_id = HttpContext.Current.Request.Form["txn_id"]; string receipt_id = HttpContext.Current.Request.Form["receipt_id"]; string receiver_email = HttpContext.Current.Request.Form["receiver_email"]; string payer_email = HttpContext.Current.Request.Form["payer_email"]; string fee = HttpContext.Current.Request.Form["payment_fee"]; */ string payment_status = HttpContext.Current.Request.Form["payment_status"].ToString();//支付狀態 string oid = HttpContext.Current.Request.Form["custom"];//訂單編號 /* strResponse == "VERIFIED" 代表驗證成功,就會進行付款狀態比對 payment_status == "Completed" 表示是已經完成付款的動作,系統 就會將IPN所回傳oid訂單編號進行資料庫比對,將欄位改為"已付款" */ if (strResponse == "VERIFIED")//驗證成功 { //付款成功 if (payment_status == "Completed") { //將資料庫Pay欄位改為"已付款" MemberDA mem = new MemberDA(); mem.payment_status(oid); } } }
public bool FormAuth_Login(string username, string password, int expireTime, Label error) { bool allow = false; MemberDA da = new MemberDA(); if (da.FormAuth_Login(username, password)) { if (da.level == "1") { FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, da.username, //註冊會員帳號 DateTime.Now, //起始時間 DateTime.Now.AddMinutes(expireTime), //到期時間 false, "Login", FormsAuthentication.FormsCookiePath);//cookie路徑 //加密 string encTicket = FormsAuthentication.Encrypt(ticket); HttpContext.Current.Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket)); HttpCookie cookie = new HttpCookie(da.username); cookie.Values["mID"] = HttpContext.Current.Server.UrlEncode(da.mID); cookie.Values["username"] = HttpContext.Current.Server.UrlEncode(da.username); cookie.Values["name"] = HttpContext.Current.Server.UrlEncode(da.name); cookie.Values["sex"] = HttpContext.Current.Server.UrlEncode(da.sex); cookie.Values["birthday"] = HttpContext.Current.Server.UrlEncode(Convert.ToDateTime(da.birthday).ToShortDateString()); cookie.Values["phone"] = HttpContext.Current.Server.UrlEncode(da.phone); cookie.Values["cellphone"] = HttpContext.Current.Server.UrlEncode(da.cellphone); cookie.Values["address"] = HttpContext.Current.Server.UrlEncode(da.address); cookie.Values["email"] = HttpContext.Current.Server.UrlEncode(da.email); cookie.Expires = DateTime.Now.AddMinutes(expireTime); HttpContext.Current.Response.Cookies.Add(cookie); allow = true; } else { error.Text = "會員驗證未通過"; allow = false;//會員驗證未通過 } } else { error.Text = "帳號密碼有誤"; allow = false;//帳號密碼有誤 } return(allow); }
/// <summary> /// Login member to app /// </summary> /// <param name="username"></param> /// <param name="password"></param> /// <returns></returns> public MemberVO LoginMember(string username, string password) { MemberVO member; try { if (string.IsNullOrWhiteSpace(username)) { throw new InvalidOperationException(Resource.Er0005); } Regex rx = new Regex(@"^(?:(?=.*[a-z])(?:(?=.*[A-Z])(?=.*[\d\W])|(?=.*\W)(?=.*\d))|(?=.*\W)(?=.*[A-Z])(?=.*\d)).{8,}$"); if (!rx.IsMatch(password)) { throw new InvalidOperationException(Resource.PasswordErrorMessage); } if (string.IsNullOrWhiteSpace(password)) { throw new InvalidOperationException(Resource.Er0006); } if (password.Length < 7) { throw new InvalidOperationException(Resource.Er0004); } using (var ctx = new MemberContext()) { member = new MemberDA().FindMemberByUserName(ctx, username); if (member == null || member.Id == 0) { throw new Exception(Resource.Er0003); } bool success = Password.ConfirmPassword(password, member.Password); if (!success) { throw new Exception(Resource.Er0004); } else { IRoleBL blRole = new RoleBL(); member.Role = blRole.GetRoleById(member.RoleId); MemberStateBL.SetMemberState(member.Id); } } } catch (Exception ex) { throw ex; } return(member); }
/// <summary> /// Get Member by this id /// </summary> /// <param name="id">id to search member</param> /// <returns></returns> public MemberVO GetMemberById(int id) { MemberVO member = null; try { using (var ctx = new MemberContext()) { IMemberDA da = new MemberDA(); member = da.FindMemberById(ctx, id); } } catch { throw; } return(member); }
public UrlVO GetUrlByUrl(string url) { UrlVO model = new UrlVO(); try { using (var ctx = new AdminContext()) { IAdminDA da = new AdminDA(); model = da.FindUrlByUrl(ctx, url); using (var ctxM = new MemberContext()) { IMemberDA mDa = new MemberDA(); } } } catch { throw; } return(model); }
protected void Button1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(TextBox1.Text) && string.IsNullOrEmpty(TextBox2.Text)) { Response.Write("<script>alert('請輸入資料');</script>"); } else { if (TextBox1.Text != TextBox2.Text) { Response.Write("<script>alert('新密碼和確認新密碼不一樣');</script>"); } else { MemberDA da = new MemberDA(); if (da.update_new_pw(Request.QueryString["checkId"].ToString(), FormsAuthentication.HashPasswordForStoringInConfigFile(TextBox1.Text, "MD5")) == 1) { Response.Write("<script>alert('新密碼設定成功');location.href='/Vote/index.aspx'</script>"); } } } }
/// <summary> /// Add new admin Member /// </summary> /// <param name="person"></param> /// <returns></returns> public MemberVO AddAdminMember(MemberVO member) { try { member.Person.CreationDate = member.CreationDate = TimeZone.CurrentTimeZone.ToUniversalTime(DateTime.UtcNow); member.DefaultCultrure = CultureInfo.CurrentUICulture.TextInfo.CultureName; member.Password = Password.ComputeHash("a12345678A", null); member.ConfirmPassword = member.Password; RoleVO adminRole = new RoleBL().GetAdminRole(); if (adminRole == null) { throw new Exception(Resource.ErSomethingWrong); } member.RoleId = adminRole.Id; #if SuperUser member.UrlId = 1; member.RoleId = 2; #endif using (var ctx = new MemberContext()) { IMemberDA da = new MemberDA(); member = da.RegisterMember(ctx, member); member.Id = da.FindIdByUsername(ctx, member.Username); if (member == null) { throw new Exception(Resource.ErSomethingWrong); } } return(member); } catch { throw; } }
public DataTable order_select(string mID) { MemberDA memDA = new MemberDA(); return(memDA.order_select(mID)); }