public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { // 注册用户 bool ok = false; int UID = 0; //添加买家账号信息 SOSOshop.BLL.MemberAccount aBll = new SOSOshop.BLL.MemberAccount(); SOSOshop.Model.MemberAccount a = new SOSOshop.Model.MemberAccount(); if (string.IsNullOrEmpty(model.Captcha) || !model.Captcha.Equals(Convert.ToString(Session["Captcha"]), StringComparison.CurrentCultureIgnoreCase)) { ModelState.AddModelError("", "提供的验证码不正确。"); } else { if (!string.IsNullOrEmpty(model.UserName) && !string.IsNullOrEmpty(model.PassWord) && model.PassWord.Equals(model.ConfirmPassword) && !string.IsNullOrEmpty(model.LinkMan) && !string.IsNullOrEmpty(model.Email)) { int i = new SOSOshop.BLL.MemberAccount().GetUserIdNameClass(model.UserName); if (i == 2) { a.UserId = ""; a.MobilePhone = model.UserName; a.Email = model.Email; } //else if (i == 3) //{ // a.UserId = ""; // a.MobilePhone = ""; // a.Email = model.UserName; //} //else //{ // a.UserId = model.UserName; // a.MobilePhone = ""; // a.Email = model.Email; //} //Response.Write(model.PassWord+" "+i); a.PassWord = ChangeHope.Common.DEncryptHelper.Encrypt(model.PassWord, 1); a.Email_QQ = model.Email.EndsWith("@qq.com") ? model.Email : ""; a.Question = ""; a.Answer = ""; a.RegisterDate = DateTime.Now; a.RegisterIP = ChangeHope.WebPage.PageRequest.GetIP(); a.PeriodOfValidity = a.RegisterDate.AddYears(20); a.State = 1; a.CompanyClass = model.CompanyClass; UID = aBll.Add(a); } //添加买家联系信息 if (UID > 0) { SOSOshop.BLL.MemberInfo bBll = new SOSOshop.BLL.MemberInfo(); SOSOshop.Model.MemberInfo b = new SOSOshop.Model.MemberInfo(); b.UID = UID; b.TrueName = model.LinkMan; b.Member_Class = -1; b.Member_Type = 0; int area = 0; int.TryParse(Request["province"], out area); b.Province = area; area = 0; int.TryParse(Request["city"], out area); b.City = area; area = 0; int.TryParse(Request["county"], out area); b.Borough = area; if (model.CompanyClass == "生产企业" || model.CompanyClass == "商业公司" || model.CompanyClass == "民营医院") { b.Member_Class = 0; } else { b.Member_Class = 1; } //通知交易人员 //int tId = 0;//交易员ID 取消//改为数据库设置默认值 2014/2/12 //string tname = new SOSOshop.BLL.Administrators().GetTraderIdByRegion(b.Province, b.City, b.Borough, out tId, model.CompanyClass);//交易员姓名 int oId = 0; //外销人员(线下推广人员)ID string oName = new SOSOshop.BLL.Administrators().GetOutSellPersonIdByRegion(b.Province, b.City, b.Borough, out oId, model.CompanyClass); //外销人员(线下推广人员)姓名 //if (tId != 0) //{ // string jyphone = string.Format(" SELECT zyphone FROM zhiyzl WHERE is_czy='是' and beactive='是' and zhiyname='{0}'", tname); // SOSOshop.BLL.DbBase db = new SOSOshop.BLL.Db(); // db.ChangeDB("ConnectionStringERP"); // DataTable dt = db.ExecuteTable(jyphone); // if (dt.Rows.Count > 0) // { // string phone = dt.Rows[0][0].ToString().Trim(); // if (!string.IsNullOrEmpty(phone)) // { // ok = SOSOshop.BLL.Sms.SendAndSaveDataBase(phone, "手机号为" + model.UserName + "的用户,已经在101商城前台进行注册,请尽快联系完成后续注册审核。", "系统", phone); // } // } //} //b.Editer = tId; b.OSPId = oId; b.HandPhone = a.MobilePhone; ok = bBll.Add(b); //添加权限 if (ok) { SOSOshop.BLL.MemberPermission cBll = new SOSOshop.BLL.MemberPermission(); SOSOshop.Model.MemberPermission c = new SOSOshop.Model.MemberPermission(); c.UID = UID; c.IsMoneyAndShipping = true;//款到发货权限 ok = cBll.Add(c); } if (!ok) { aBll.Delete(UID); } } if (ok) { //发送注册成功的短信 取消//彭宴负责交易员分配工作,后台操作后发送短信 2014/2/12 var sms = new SOSOshop.MSG.Sms(); object phone = aBll.ExecuteScalar("select OfficePhone from yxs_administrators where adminid=(select Editer from memberaccount a inner join memberinfo b on a.UID=b.UID where a.UID='" + UID + "')"); //string SmsMsg = "尊敬的" + model.LinkMan + ",您已完成注册第一步,立即致电您的专属采购顾问" + phone + "开通查看价格权限"; string CompanyShortName = ConfigurationManager.AppSettings["CompanyShortName"]; string SmsMsg = string.Format("尊敬的用户,您在{0}医药网注册已成功,您的账户名为", CompanyShortName) + model.UserName + ",请留意保存,祝您采购愉快!"; string from = "系统"; string to = model.UserName; ok = SOSOshop.BLL.Sms.SendAndSaveDataBase(model.UserName, SmsMsg, from, to); //写入登陆日志 new SOSOshop.BLL.MemberLoginLog().Add(UID, model.UserName, a.PassWord); Session["Captcha"] = null; DateTime expiration = DateTime.Now.AddHours(12); FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, model.UserName, DateTime.Now, expiration, false, UID.ToString(), FormsAuthentication.FormsCookiePath); string encTicket = FormsAuthentication.Encrypt(ticket); HttpCookie tk = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket); Response.Cookies.Add(tk); return(RedirectToAction("RegisterOK")); } else { ModelState.AddModelError("", "注册失败!"); } } } // 如果我们进行到这一步时某个地方出错,则重新显示表单 return(View(model)); }
public ActionResult LogOn(LogOnModel model, string returnUrl) { //Response.Write(returnUrl); returnUrl = Request["referrer"]; if (ModelState.IsValid) { if (model.UserName != null) { model.UserName = model.UserName.Trim(); } SOSOshop.BLL.MemberAccount bll = new SOSOshop.BLL.MemberAccount(); SOSOshop.Model.MemberAccount obj = null; if ((string.IsNullOrEmpty(model.Captcha) || !model.Captcha.Equals(Convert.ToString(Session["Captcha"]), StringComparison.CurrentCultureIgnoreCase))) { ModelState.AddModelError("", "您输入的验证码不正确。"); } else { string loginname = model.UserName; string loginpwd = model.PassWord; if (!string.IsNullOrEmpty(model.UserName) && !string.IsNullOrEmpty(model.PassWord)) { model.PassWord = ChangeHope.Common.DEncryptHelper.Encrypt(model.PassWord, 1); obj = bll.GetModelByNameAndPassword(model.UserName, model.PassWord); } if (obj != null) { if (obj.State == 2) { ModelState.AddModelError("", "用户已经被冻结,请联系客服。"); } else if (obj.PeriodOfValidity <= DateTime.Now) { ModelState.AddModelError("", "用户过期时间已到,请联系客服。"); } //else if (bll.GetMember_Class(obj.UID) == SOSOshop.Model.Member.Member_Class.无) //{ // ModelState.AddModelError("", "用户属未知买家类别,请联系客服。"); //} else { //写入登陆日志 new SOSOshop.BLL.MemberLoginLog().Add(obj.UID, model.UserName, model.PassWord); Session["Captcha"] = null; DateTime expiration = DateTime.Now.AddHours(12); FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, model.UserName, DateTime.Now, expiration, false, obj.UID.ToString(), FormsAuthentication.FormsCookiePath); string encTicket = FormsAuthentication.Encrypt(ticket); HttpCookie tk = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket); Response.Cookies.Add(tk); //普通会员引导去升级 SOSOshop.BLL.MemberPermission mpb = new SOSOshop.BLL.MemberPermission(); SOSOshop.BLL.MemberInfo mifo = new SOSOshop.BLL.MemberInfo();//判断用户类型 SOSOshop.Model.MemberInfo obj2 = mifo.GetModel(obj.UID); int memberClass = obj2.Member_Class; //判断用户是否GSP建档 //未建档用户跳转到会员建档资料提交页面 if (!mpb.GetBuyFilingStatus(obj.UID)) { if (1 == (int)mpb.ExecuteScalar("SELECT IsSpecialTrade FROM dbo.memberpermission WHERE UID=" + obj.UID)) { #region 短信提醒 string phone = obj.MobilePhone; string CompanyShortName = ConfigurationManager.AppSettings["CompanyShortName"]; SOSOshop.BLL.Sms.SendAndSaveDataBase(phone, "尊敬的" + obj2.TrueName + string.Format(",快捷交易权限仅7天内有效,请尽快邮寄合法的首营资料到{0}审核,享永久会员权益", CompanyShortName), "系统", phone); int tId = obj2.Editer; if (tId > 0) { string jyphone = (string)new SOSOshop.BLL.Administrators().ExecuteScalar("select MobilePhone from yxs_administrators where adminid=" + tId); if (!string.IsNullOrEmpty(jyphone)) { SOSOshop.BLL.Sms.SendAndSaveDataBase(phone, "手机号为" + model.UserName + "的快捷开通客户已登录,请及时联系跟进,督促首营资质到位。", "系统", phone); } } #endregion return(RedirectToAction("Upgrade", "MemberCenter")); } else { return(RedirectToAction("registerok", "account")); } } else { if (returnUrl.Length > 10) { int pos = returnUrl.LastIndexOf("/"); int outs = 0; if (pos != -1) { pos++; } int.TryParse(returnUrl.Substring(pos).Replace(".html", ""), out outs); if ((outs != 0) || (returnUrl.IndexOf("products") != -1)) { return(Redirect(returnUrl)); } } return(RedirectToAction("index", "home")); //if (memberClass == 0)//批发客户跳转到基药频道 //{ // return RedirectToAction("Index", "jy"); //} //else if (memberClass == 1)//OTC客户跳转到OTC频道 //{ // //return RedirectToAction("Index", "Otc"); //} //else//其它用户 //{ // if (returnUrl.ToLower().IndexOf("logon") != -1 || returnUrl.ToLower().IndexOf("register") != -1) // { // return RedirectToAction("LoginOK", "Account"); // } // else if (!string.IsNullOrEmpty(returnUrl)) // { // return Redirect(returnUrl); // } // else // { // return RedirectToAction("LoginOK", "Account"); // } //} } } } else { ModelState.AddModelError("", "您输入的用户名或密码不正确。"); } } } // 如果我们进行到这一步时某个地方出错,则重新显示表单 return(View(model)); }