public UserCookieInfo(User u) { id = u.Id; name = u.Name; email = u.Email; Write(); }
/// <summary> /// ���û�ע�� /// </summary> private void DoUserJoin() { string _email = httpContext.Request.Form["email"] == null ? "" : httpContext.Request.Form["email"].Trim(); string _name = httpContext.Request.Form["cname"] == null ? "" : httpContext.Request.Form["cname"].Trim(); string _pwd = httpContext.Request.Form["pwd"] == null ? "" : httpContext.Request.Form["pwd"].Trim(); string _pwdCfm = httpContext.Request.Form["pwdcfm"] == null ? "" : httpContext.Request.Form["pwdcfm"].Trim(); if (!Util.IsValidEmail(_email)) { Html.Append("1"); return; } if (String.IsNullOrEmpty(_name)) { Html.Append("2"); return; } if (_pwd.Length<6) { Html.Append("3"); return; } if (_pwd != _pwdCfm) { Html.Append("4"); return; } if (User.IsExistEmail(_email)) { Html.Append("5"); return; } User u = new User(_email, _pwd, _name); int newid=User.AddNew(u, httpContext.Request.Form["autologin"]!=null); if (newid > 0) { SmtpMail sm = MailInstance; sm.Subject = _name+"����ӭ����ͱȱ��������ģ�"; sm.AddRecipient(new string[] { _email }); StringBuilder _body = new StringBuilder(); _body.AppendLine(_name + ",��ã�<br/>"); _body.AppendLine("��ӭ�����ͱȱ��������ģ�<a href=\"http://invite.kebibi.com/help\">�����������Ѱ�ҷ���Ӧ�̣�������ҵ�ͻ�</a>��������ѻ�����Ĵ�м�����Ҳ����˻�÷��ı��꣡<br/><br/>"); _body.AppendLine("��ĵ�¼�ʼ��ǣ�" + _email + "<br/>"); _body.AppendLine("��ĵ�¼�����ǣ�" + _pwd + "<br/><br/>"); _body.AppendLine("�ͱȱ�����������ʱ��ӭ����ʣ�http://invite.kebibi.com<br/>"); _body.AppendLine("<p style=\"color:#666;\">�ͱȱȽ����㱣����ʼ����Է����ǵ�¼�ʺź�������Ϣ��</p>"); sm.Body = MailBody(_body.ToString()); sm.Send(); Html.Append("0"); return; } Html.Append("99"); }
/// <summary> /// ������ϵ����Ϣ /// </summary> private void DoSaveContactInfo() { string _name = request.Form["cname"] == null ? "" : request.Form["cname"].Trim(); string _telephone = request.Form["telephone"] == null ? "" : request.Form["telephone"].Trim(); string _cellphone = request.Form["cellphone"] == null ? "" : request.Form["cellphone"].Trim(); bool _userSave = false; int _payId = 0; if (UserCookieInfo.Get() == null) { return; } int _uid=UserCookieInfo.Get().Id; User u = new User(_uid); u.Name = _name; u.Telephone = _telephone; u.Cellphone = _cellphone; _userSave = u.Update(); if (!_userSave) { return; } _payId = request.Form["paymentModeId"] == null ? 0 : Convert.ToInt32(request.Form["paymentModeId"]); PaymentModeEnum payModeEnum = request.Form["paymentMode"] == null ? PaymentModeEnum.PostOffice : (PaymentModeEnum)(Convert.ToInt16(request.Form["paymentMode"])); PayMode payMode = new PayMode(payModeEnum, _uid, "�ʾֻ����Ϣ"); PaymentModeDetails _details=null; switch (payModeEnum) { case PaymentModeEnum.PostOffice: _details = new PaymentModePostOffice(); ((PaymentModePostOffice)_details).Name = request.Form["payName"] == null ? "" : request.Form["payName"].Trim(); ((PaymentModePostOffice)_details).Phone = request.Form["payPhone"] == null ? "" : request.Form["payPhone"].Trim(); ((PaymentModePostOffice)_details).Address = request.Form["payAddress"] == null ? "" : request.Form["payAddress"].Trim(); ((PaymentModePostOffice)_details).Postcode = request.Form["payPostcode"] == null ? "" : request.Form["payPostcode"].Trim(); break; case PaymentModeEnum.Online: _details = new PaymentModeOnline(); ((PaymentModeOnline)_details).Provider = request.Form["payProvider"] == null ? "" : request.Form["payProvider"].Trim(); ((PaymentModeOnline)_details).UserId = request.Form["payUserId"] == null ? "" : request.Form["payUserId"].Trim(); break; case PaymentModeEnum.ElectricityBill: _details = new PaymentModeElectricityBill(); ((PaymentModeElectricityBill)_details).Bank = request.Form["payBank"] == null ? "" : request.Form["payBank"].Trim(); ((PaymentModeElectricityBill)_details).BankName = request.Form["payBankName"] == null ? "" : request.Form["payBankName"].Trim(); ((PaymentModeElectricityBill)_details).CardNumber = request.Form["payCardNumber"] == null ? "" : request.Form["payCardNumber"].Trim(); ((PaymentModeElectricityBill)_details).Name = request.Form["payName"] == null ? "" : request.Form["payName"].Trim(); break; } if (_details != null) { payMode.Details = _details; } payMode.IsActive = true; payMode.Save(_payId); Html.Append("true"); }
/// <summary> /// ��ȡ�û��б� /// </summary> /// <param name="keywords">�ؼ���</param> /// <param name="pager">��ҳ</param> /// <returns></returns> public static List<User> List(string keywords,Pager pager) { /* INV_UserList @keywords varchar(50)='', @pageIndex int=1, @pageSize int=20, @sort int=0 */ List<User> list = new List<User>(); using (SqlDataReader reader = Database.ExecuteReader(CommandType.StoredProcedure, "INV_UserList", new SqlParameter[] { Database.MakeInParam("@keywords",SqlDbType.VarChar,50,keywords), Database.MakeInParam("@pageIndex",SqlDbType.Int,pager.PageIndex), Database.MakeInParam("@pageSize",SqlDbType.Int,pager.PageSize), Database.MakeInParam("@sort",SqlDbType.Int,pager.SortNum) })) { if (reader.Read()) { pager.RecordCount = reader.GetInt32(0); if (reader.NextResult()) { User u; while (reader.Read()) { u = new User(); u.id = reader.GetInt32(0); u.email = reader.GetString(1); u.name = reader.GetString(2); u.telephone = reader.GetString(3); u.cellphone = reader.GetString(4); u.joinDate = reader.GetDateTime(5); u.status = (UserStatus)(reader.GetInt16(6)); u.activePayModeId = reader.GetInt32(7); list.Add(u); } } } reader.Close(); } return list; }
/// <summary> /// ��ȡ�û�ʵ�� /// </summary> /// <param name="emailOrId">�����ʼ���ַ����ID�ַ���</param> /// <returns>User</returns> public static User Get(string emailOrId) { /* INV_UserGet @id varchar(50) */ //[Id],[Email],[Name],[Telephone],[CellPhone],[JoinDate],[Status],[ActivePayMode] User u = null; using (SqlDataReader reader = Database.ExecuteReader(CommandType.StoredProcedure, "INV_UserGet", new SqlParameter[] { Database.MakeInParam("@id",SqlDbType.VarChar,50,emailOrId)})) { if (reader.Read()) { u = new User(); u.id = reader.GetInt32(0); u.email = reader.GetString(1); u.name = reader.GetString(2); u.telephone = reader.GetString(3); u.cellphone = reader.GetString(4); u.joinDate = reader.GetDateTime(5); u.status = (UserStatus)(reader.GetInt16(6)); u.activePayModeId = reader.GetInt32(7); } reader.Close(); } return u; }
/// <summary> /// ���һ�����û� /// </summary> /// <param name="u">�û�ʵ��</param> /// <returns>���û�ID</returns> public static int AddNew(User u) { return AddNew(u, false); }
/// <summary> /// ���һ�����û� /// </summary> /// <param name="u">�û�ʵ��</param> /// <param name="autoLogin">��ӳɹ����Ƿ��Զ���¼</param> /// <returns>���û�ID</returns> public static int AddNew(User u,bool autoLogin) { /* INV_UserAddNew @email varchar(50), @pass varchar(50), @name varchar(10), @telephone varchar(20)='', @cellphone varchar(15)='', @status smallint=1 */ SqlParameter[] prams = new SqlParameter[] { Database.MakeReturnValueParam("@returnValue"), Database.MakeInParam("@email",SqlDbType.VarChar,50,u.email), Database.MakeInParam("@pass",SqlDbType.VarChar,50,Util.MD5(u.password)), Database.MakeInParam("@name",SqlDbType.VarChar,10,u.name), Database.MakeInParam("@telephone",SqlDbType.VarChar,20,u.telephone), Database.MakeInParam("@cellphone",SqlDbType.VarChar,15,u.cellphone), Database.MakeInParam("@status",SqlDbType.SmallInt,u.status) }; int ret = Database.ExecuteNonQuery(CommandType.StoredProcedure, "INV_UserAddNew", prams); u.id = ret; if (ret>0 && autoLogin) { UserCookieInfo uc = new UserCookieInfo(u); } return ret; }