/// <summary> /// 添加会员信息 /// </summary> /// <param name="dr"></param> private void addMemberinfo(DataRow dr) { if (dr != null) { SOSOshop.Model.MemberInfo mi = new SOSOshop.Model.MemberInfo(); SOSOshop.BLL.MemberInfo mibll = new SOSOshop.BLL.MemberInfo(); SOSOshop.BLL.MemberPermission mpbll = new SOSOshop.BLL.MemberPermission(); SOSOshop.Model.MemberPermission mp = new SOSOshop.Model.MemberPermission(); object UID = mibll.ExecuteScalar("select UID from MemberAccount where MobilePhone='" + dr["联系手机"].ToString() + "'"); if (!mibll.Exists((int)UID)) { mi.Address = dr["地址"].ToString(); mi.Code = dr["会员编号"].ToString(); mi.discount = 1; mi.Member_Type = 1; object r = mibll.ExecuteScalar("select ID from DrugsBase_Enterprise where name='" + dr["公司名称"].ToString() + "'"); mi.ParentId = (int)r; mi.TrueName = dr["联系人名"].ToString(); mi.UID = (int)UID; mi.PriceCategory = dr["价格类型"] as string; mibll.Add(mi); mp.UID = mi.UID; mp.IsMoneyAndShipping = true; mi.Province = GetRegionId(dr["省"].ToString()); mi.City = GetRegionId(dr["市"].ToString()); mi.Borough = GetRegionId(dr["区"].ToString()); mpbll.Add(mp); } else { modifyMemberinfo(dr); } } }
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)); }