private async Task LoadSharedKeyAndQrCodeUriAsync(MemberUserInfo user) { // Load the authenticator key & QR code URI to display on the form var unformattedKey = await _userManager.GetAuthenticatorKeyAsync(user); if (string.IsNullOrEmpty(unformattedKey)) { await _userManager.ResetAuthenticatorKeyAsync(user); unformattedKey = await _userManager.GetAuthenticatorKeyAsync(user); } SharedKey = FormatKey(unformattedKey); var email = await _userManager.GetEmailAsync(user); AuthenticatorUri = GenerateQrCodeUri(email, unformattedKey); }
public async Task <IActionResult> OnPostConfirmationAsync(string returnUrl = null) { returnUrl = returnUrl ?? Url.Content("~/"); // Get the information about the user from the external login provider var info = await _signInManager.GetExternalLoginInfoAsync(); if (info == null) { ErrorMessage = "Error loading external login information during confirmation."; return(RedirectToPage("./Login", new { ReturnUrl = returnUrl })); } if (ModelState.IsValid) { var user = new MemberUserInfo { UserName = Input.Email, Email = Input.Email }; var result = await _userManager.CreateAsync(user); if (result.Succeeded) { result = await _userManager.AddLoginAsync(user, info); if (result.Succeeded) { await _signInManager.SignInAsync(user, isPersistent : false); _logger.LogInformation("User created an account using {Name} provider.", info.LoginProvider); return(LocalRedirect(returnUrl)); } } foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } } LoginProvider = info.LoginProvider; ReturnUrl = returnUrl; return(Page()); }
public async Task <IActionResult> OnPostAsync(string returnUrl = null) { returnUrl = returnUrl ?? Url.Content("~/"); if (ModelState.IsValid) { var user = new MemberUserInfo { UserName = Input.CrsId, Email = $"{Input.CrsId}@cam.ac.uk" }; var result = await _userManager.CreateAsync(user, Input.Password); if (result.Succeeded) { _logger.LogInformation("User created a new account with password."); var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); var callbackUrl = Url.Page( "/Account/ConfirmEmail", pageHandler: null, values: new { userId = user.Id, code = code }, protocol: Request.Scheme); await _emailSender.SendEmailAsync($"{Input.CrsId}@cam.ac.uk", "Confirm your email", $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>."); await _signInManager.SignInAsync(user, isPersistent : false); return(LocalRedirect(returnUrl)); } foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } } // If we got this far, something failed, redisplay form return(Page()); }
// // GET: /AddUser/ public ActionResult Index(FormCollection collection) { Dictionary<string, string> sitemaster = GetSiteMaster(); ViewData["SiteMaster"] = sitemaster; if (Int32.Parse(sitemaster["isadmin"]) > 2) { if (collection.Count != 0) { UserModel newuser = new UserModel(); newuser.Username = collection["UserName"]; newuser.Password = collection["Password"]; newuser.Email = ""; if (!MembershipService.UserIsExists(newuser.Username)) { //创建用户 try { MembershipService.CreateNewUser(newuser); } catch (Exception e) { return View(e.Message); } int tempuserid = MembershipService.GetUserID(collection["UserName"]); //插入企业表 EnterpriseMemberInfo emi = new EnterpriseMemberInfo(); emi.EnterPriceType = 1; emi.Memberlevel = GetLevel(collection["MemberLevel"]); emi.EnterpriseName = collection["EnterpriseName"]; emi.Telphone = collection["Telphone"]; emi.Contract = collection["ContractName"]; emi.ContractName = collection["ContractName"]; emi.ContractMobile = collection["Telphone"]; emi.Fax = ""; emi.Province = collection["Address"]; emi.Address = collection["Address"]; emi.Zip = ""; emi.CreateTime = DateTime.Now; emi.CreateUserID = 4; emi.SaleUserID = 4; emi.ServiceUserID = 4; emi.MemberCode = GetCode(); try { new EnterpriseMemberInfoDao().Insert(emi); } catch (Exception e) { return View(e.Message); } Hashtable htparm = new Hashtable(); int memberid = CRMMapper.Get().QueryForObject<int>("EnterpriseMemberInfo.myFind", collection["EnterpriseName"]); //插入MemberUserInfo MemberUserInfo newMember = new MemberUserInfo(); newMember.UserID = tempuserid; newMember.MemberID = memberid; newMember.Name = collection["ContractName"]; newMember.IsMemberAdmin = 1; newMember.Mobile = collection["Telphone"]; newMember.Status = 1; try { new MemberUserInfoDao().Insert(newMember); } catch (Exception e) { return View(e.Message); } //插入订单表 OrderInfo oi = new OrderInfo(); oi.MemberID = memberid; oi.MemberUserID = tempuserid; oi.ProductID = 1; oi.VersionID = 1; oi.ServiceStartTime = DateTime.Parse(collection["TimeFrom"]).AddHours(8); oi.ServiceEndTime = DateTime.Parse(collection["TimeTo"]).AddHours(23); oi.PayMethod = 1; oi.OrigPrice = 0; oi.PayPrice = 0; oi.PayStatus = 1; oi.OrderSource = 1; oi.OrderStatus = 0; oi.CreateTime = DateTime.Now; CookieUserInfo cui = MembershipService.GetUserCookie(); oi.CretorUserID = CRMMapper.Get().QueryForObject<int>("EmployeeInfo.GetEmpID", cui.UserName); oi.LastModifyTime = DateTime.Now; oi.LastModifyUserID = 4; oi.SaleUserID = 4; oi.ServiceUserID = 4; try { new OrderInfoDao().Insert(oi); } catch (Exception e) { return View(e.Message); } ViewData["Basicinfo"] = collection; ViewData["MemberLevel"] = collection["MemberLevel"]; ViewData["IsExists"] = false; ViewData["Success"] = true; } else { ViewData["Basicinfo"] = collection; ViewData["MemberLevel"] = collection["MemberLevel"]; ViewData["IsExists"] = true; ViewData["Success"] = false; } } else { ViewData["Success"] = false; ViewData["IsExists"] = false; ViewData["MemberLevel"] = "初级会员"; } return View(); } else return new RedirectResult("/Base/MemberLevelError.mvc/" + 0); }
public ActionResult Qualification(FormCollection collection) { //all files /*foreach (string filename in Request.Files) { HttpPostedFileBase hfile = Request.Files[filename]; System.IO.FileInfo findo = new System.IO.FileInfo(hfile.FileName); hfile.SaveAs("C:\\" + findo.Name ); }*/ Dictionary<string, string> sitemaster = GetSiteMaster(); ViewData["SiteMaster"] = sitemaster; if (CurrentUserInfo != null) { int userid = Int32.Parse(CurrentUserInfo.UserID); MemberUserInfo member = new MemberUserInfo(); member = new MemberUserInfoDao().Find(userid); IDictionary result = CRMMapper.Get().QueryForObject<IDictionary>("EnterpriseTotalInfo.MyFind", member.MemberID); IList<IDictionary> GMPresult = CRMMapper.Get().QueryForList<IDictionary>("GMPCerts.MyFind", member.MemberID); IList<IDictionary> Techresult = CRMMapper.Get().QueryForList<IDictionary>("TechCerts.MyFind", member.MemberID); string HtmlGMP = string.Empty; int GMPCount = 0; foreach (IDictionary gmp in GMPresult) { GMPCount++; string temp = string.Empty; string temp1 = string.Empty; if (gmp["GMPCertStarting"] != null) temp = ((DateTime)gmp["GMPCertStarting"]).Date.ToString(); if (gmp["GMPCertTime"] != null) temp1 = ((DateTime)gmp["GMPCertTime"]).Date.ToString(); HtmlGMP += "<tr class=\"GMP" + GMPCount + "\"><td height=\"25\" align=\"right\" class=\"view\">GMP证书" + GMPCount + "号码:</td><td height=\"25\" colspan=\"3\" align=\"left\"><span style=\"HEIGHT: 31px\">" + "<input name=\"GMPCertNo"+GMPCount+ "\" type=\"text\" class=\"kuang GMPCertNo\" size=\"40\" value=\""+gmp["GMPCertNo"]+"\"/></span><span class='view STYLE3'>*</span></td></tr>" + "<tr class=\"GMP" + GMPCount + "\"><td height=\"25\" align=\"right\" class=\"view\">GMP证书" + GMPCount + "认证范围:</td><td height=\"25\" colspan=\"3\" align=\"left\"><span style=\"HEIGHT: 31px\">" + "<input name=\"GMPCertRange" + GMPCount + "\" type=\"text\" class=\"kuang\" size=\"40\" value=\""+gmp["GMPCertRange"]+"\"/></span></td></tr>" + "<tr class=\"GMP" + GMPCount + "\"><td height=\"25\" align=\"right\" class=\"view\">GMP证书" + GMPCount + "发证时间:</td><td height=\"25\" colspan=\"3\" align=\"left\"><span style=\"HEIGHT: 31px\">" + "<input name=\"GMPCertStarting" + GMPCount + "\" type=\"text\" class=\"kuang date\" size=\"40\" value=\"" + temp + "\"/></span></td></tr>" + "<tr class=\"GMP" + GMPCount + "\"><td height=\"25\" align=\"right\" class=\"view\">GMP证书" + GMPCount + "有效期:</td><td height=\"25\" colspan=\"3\" align=\"left\"><span style=\"HEIGHT: 31px\">" + "<input name=\"GMPCertTime" + GMPCount + "\" type=\"text\" class=\"kuang date\" size=\"40\" value=\"" + temp1+ "\"/></span></td></tr>"; } string HtmlTech = string.Empty; int TechCount = 0; foreach (IDictionary gmp in Techresult) { TechCount++; string temp=string.Empty; string temp1 = string.Empty; if (gmp["TechCertStarting"] != null) temp=((DateTime)gmp["TechCertStarting"]).Date.ToString(); if (gmp["TechCertTime"] != null) temp1 = ((DateTime)gmp["TechCertTime"]).Date.ToString(); HtmlTech += "<tr class=\"Tech" + TechCount + "\"><td height=\"25\" align=\"right\" class=\"view\">高新技术企业证书" + TechCount + "号码:</td><td height=\"25\" colspan=\"3\" align=\"left\"><span style=\"HEIGHT: 31px\">" + "<input name=\"TechCertNo" + TechCount + "\" type=\"text\" class=\"kuang TechCertNo\" size=\"40\" value=\"" + gmp["TechCertNo"] + "\"/></span><span class='view STYLE3'>*</span></td></tr>" + "<tr class=\"Tech" + TechCount + "\"><td height=\"25\" align=\"right\" class=\"view\">高新技术企业证书" + TechCount + "发证时间:</td><td height=\"25\" colspan=\"3\" align=\"left\"><span style=\"HEIGHT: 31px\">" + "<input name=\"TechCertStarting" + TechCount + "\" type=\"text\" class=\"kuang date\" size=\"40\" value=\"" + temp + "\"/></span></td></tr>" + "<tr class=\"Tech" + TechCount + "\"><td height=\"25\" align=\"right\" class=\"view\">高新技术企业证书" + TechCount + "有效期:</td><td height=\"25\" colspan=\"3\" align=\"left\"><span style=\"HEIGHT: 31px\">" + "<input name=\"TechCertTime" + TechCount + "\" type=\"text\" class=\"kuang date\" size=\"40\" value=\"" + temp1 + "\"/></span></td></tr>"; } if (collection.Count == 0) { ViewData["Result"] = result; ViewData["GMPResult"] = HtmlGMP; ViewData["GMPCount"] = GMPCount; ViewData["TechResult"] = HtmlTech; ViewData["TechCount"] = TechCount; } else { bool IsSuccess = true; Hashtable htparm = new Hashtable(); IDictionary form = new Dictionary<string, string>(); int TotalGMPCount = 0; int TotalTechCount = 0; foreach(string key in collection.AllKeys) { htparm[key] = collection[key]; form[key] = collection[key]; if (key.IndexOf("GMPCertNo")!=-1 && ((string)htparm[key]) != "") TotalGMPCount++; if (key.IndexOf("TechCertNo")!=-1 && ((string)htparm[key]) != "") TotalTechCount++; } htparm["MemberID"] = member.MemberID; int memberid = new MemberUserInfoDao().Find(userid).MemberID; if (result != null) { try { //update CRMMapper.Get().Update("EnterpriseTotalInfo.MyUpdate", htparm); if (GMPCount > TotalGMPCount) { Hashtable ht = new Hashtable(); ht["num"] = GMPCount - TotalGMPCount; ht["Memberid"] = memberid; CRMMapper.Get().Delete("GMPCerts.MyDelete", ht); for (int i = 1; i <= TotalGMPCount; i++) { htparm["GMPCertNo"] = collection["GMPCertNo" + i]; htparm["GMPCertRange"] = collection["GMPCertRange" + i]; htparm["GMPCertStarting"] = collection["GMPCertStarting" + i]; htparm["GMPCertTime"] = collection["GMPCertTime" + i]; htparm["Memberid"] = memberid; CRMMapper.Get().Update("GMPCerts.MyUpdate", htparm); } } else { for (int i = 1; i <= GMPCount; i++) { htparm["GMPCertNo"] = collection["GMPCertNo" + i]; htparm["GMPCertRange"] = collection["GMPCertRange" + i]; htparm["GMPCertStarting"] = collection["GMPCertStarting" + i]; htparm["GMPCertTime"] = collection["GMPCertTime" + i]; htparm["Memberid"] = memberid; CRMMapper.Get().Update("GMPCerts.MyUpdate", htparm); } for (int j = GMPCount + 1; j <= TotalGMPCount; j++) { htparm["GMPCertNo"] = collection["GMPCertNo" + j]; htparm["GMPCertRange"] = collection["GMPCertRange" + j]; htparm["GMPCertStarting"] = collection["GMPCertStarting" + j]; htparm["GMPCertTime"] = collection["GMPCertTime" + j]; htparm["Memberid"] = memberid; CRMMapper.Get().Insert("GMPCerts.MyInsert", htparm); } } if (TechCount > TotalTechCount) { Hashtable ht = new Hashtable(); ht["num"] = TechCount - TotalTechCount; ht["Memberid"] = memberid; CRMMapper.Get().Delete("TechCerts.MyDelete", ht); for (int i = 1; i <= TotalTechCount; i++) { htparm["TechCertNo"] = collection["TechCertNo" + i]; htparm["TechCertStarting"] = collection["TechCertStarting" + i]; htparm["TechCertTime"] = collection["TechCertTime" + i]; htparm["Memberid"] = memberid; CRMMapper.Get().Update("TechCerts.MyUpdate", htparm); } } else { for (int i = 1; i <= TechCount; i++) { htparm["TechCertNo"] = collection["TechCertNo" + i]; htparm["TechCertStarting"] = collection["TechCertStarting" + i]; htparm["TechCertTime"] = collection["TechCertTime" + i]; htparm["Memberid"] = memberid; CRMMapper.Get().Update("TechCerts.MyUpdate", htparm); } for (int j = TechCount + 1; j <= TotalTechCount; j++) { htparm["TechCertNo"] = collection["TechCertNo" + j]; htparm["TechCertStarting"] = collection["TechCertStarting" + j]; htparm["TechCertTime"] = collection["TechCertTime" + j]; htparm["Memberid"] = memberid; CRMMapper.Get().Insert("TechCerts.MyInsert", htparm); } } } catch (Exception ex) { string hh = ex.Message; IsSuccess = false; } //IsSuccess=true; } else { try { //Insert CRMMapper.Get().Insert("EnterpriseTotalInfo.MyInsert", htparm); for (int i = 1; i <= TotalGMPCount; i++) { htparm["GMPCertNo"] = collection["GMPCertNo" + i]; htparm["GMPCertRange"] = collection["GMPCertRange" + i]; htparm["GMPCertStarting"] = collection["GMPCertStarting" + i]; htparm["GMPCertTime"] = collection["GMPCertTime" + i]; htparm["Memberid"] = memberid; CRMMapper.Get().Insert("GMPCerts.MyInsert", htparm); } for (int j = 1; j <= TotalTechCount; j++) { htparm["TechCertNo"] = collection["TechCertNo" + j]; htparm["TechCertStarting"] = collection["TechCertStarting" + j]; htparm["TechCertTime"] = collection["TechCertTime" + j]; htparm["Memberid"] = memberid; CRMMapper.Get().Insert("TechCerts.MyInsert", htparm); } } catch (Exception ex) { string hh = ex.Message; IsSuccess = false; } //IsSuccess = true; } HtmlGMP = string.Empty; HtmlTech = string.Empty; for (int i = 1; i <= TotalGMPCount;i++) { string temp = string.Empty; string temp1 = string.Empty; if (collection["GMPCertStarting" + i] != null && collection["GMPCertStarting" + i] != "") temp = DateTime.Parse(collection["GMPCertStarting" + i]).Date.ToString(); if (collection["GMPCertTime" + i] != null && collection["GMPCertTime" + i] != "") temp1 = DateTime.Parse(collection["GMPCertTime" + i]).Date.ToString(); HtmlGMP += "<tr class=\"GMP" + i + "\"><td height=\"25\" align=\"right\" class=\"view\">GMP证书" + i + "号码:</td><td height=\"25\" colspan=\"3\" align=\"left\"><span style=\"HEIGHT: 31px\">" + "<input name=\"GMPCertNo" + i + "\" type=\"text\" class=\"kuang GMPCertNo\" size=\"40\" value=\"" + collection["GMPCertNo" + i] + "\"/></span><span class='view STYLE3'>*</span></td></tr>" + "<tr class=\"GMP" + i + "\"><td height=\"25\" align=\"right\" class=\"view\">GMP证书" + i + "认证范围:</td><td height=\"25\" colspan=\"3\" align=\"left\"><span style=\"HEIGHT: 31px\">" + "<input name=\"GMPCertRange" + i + "\" type=\"text\" class=\"kuang\" size=\"40\" value=\"" + collection["GMPCertRange" + i] + "\"/></span></td></tr>" + "<tr class=\"GMP" + i + "\"><td height=\"25\" align=\"right\" class=\"view\">GMP证书" + i + "发证时间:</td><td height=\"25\" colspan=\"3\" align=\"left\"><span style=\"HEIGHT: 31px\">" + "<input name=\"GMPCertStarting" + i + "\" type=\"text\" class=\"kuang date\" size=\"40\" value=\"" + temp + "\"/></span></td></tr>" + "<tr class=\"GMP" + i + "\"><td height=\"25\" align=\"right\" class=\"view\">GMP证书" + i + "有效期:</td><td height=\"25\" colspan=\"3\" align=\"left\"><span style=\"HEIGHT: 31px\">" + "<input name=\"GMPCertTime" + i + "\" type=\"text\" class=\"kuang date\" size=\"40\" value=\"" + temp1 + "\"/></span></td></tr>"; } for (int i = 1; i <= TotalTechCount; i++) { string temp = string.Empty; string temp1 = string.Empty; if (collection["TechCertStarting" + i] != null && collection["TechCertStarting" + i] != "") temp = DateTime.Parse(collection["TechCertStarting" + i]).Date.ToString(); if (collection["TechCertTime" + i] != null && collection["TechCertTime" + i] != "") temp1 = DateTime.Parse(collection["TechCertTime" + i]).Date.ToString(); HtmlTech += "<tr class=\"Tech" + i + "\"><td height=\"25\" align=\"right\" class=\"view\">高新技术企业证书" + i + "号码:</td><td height=\"25\" colspan=\"3\" align=\"left\"><span style=\"HEIGHT: 31px\">" + "<input name=\"TechCertNo" + i + "\" type=\"text\" class=\"kuang TechCertNo\" size=\"40\" value=\"" + collection["TechCertNo" + i] + "\"/></span><span class='view STYLE3'>*</span></td></tr>" + "<tr class=\"Tech" + i + "\"><td height=\"25\" align=\"right\" class=\"view\">高新技术企业证书" + i + "发证时间:</td><td height=\"25\" colspan=\"3\" align=\"left\"><span style=\"HEIGHT: 31px\">" + "<input name=\"TechCertStarting" + i + "\" type=\"text\" class=\"kuang date\" size=\"40\" value=\"" + temp + "\"/></span></td></tr>" + "<tr class=\"Tech" + i + "\"><td height=\"25\" align=\"right\" class=\"view\">高新技术企业证书" + i + "有效期:</td><td height=\"25\" colspan=\"3\" align=\"left\"><span style=\"HEIGHT: 31px\">" + "<input name=\"TechCertTime" + i + "\" type=\"text\" class=\"kuang date\" size=\"40\" value=\"" + temp1 + "\"/></span></td></tr>"; } ViewData["Result"] = form; ViewData["GMPResult"] = HtmlGMP; ViewData["GMPCount"] = TotalGMPCount; ViewData["TechResult"] = HtmlTech; ViewData["TechCount"] = TechCount; ViewData["Success"] = IsSuccess; } } ViewData["titlename"] = "企业资质信息"; return View(); }
public ActionResult BasicInfo(FormCollection collection) { Dictionary<string, string> sitemaster = GetSiteMaster(); ViewData["SiteMaster"] = sitemaster; int userid=Int32.Parse(CurrentUserInfo.UserID); //int companyID = new MemberUserInfoDao().GetMemberID(userid); string username=CurrentUserInfo.UserName; IDictionary dict = QueryBasicInfo(userid); if (dict != null) { string mail = MembershipService.GetUserMail(username); if (CurrentUserInfo != null) { if (collection.Count == 0) { //ViewData["CompanyID"] = dict["MemberID"]; ViewData["Name"] = username; dict["Email"] = mail; ViewData["BasicInfo"] = dict; } else { //Dictionary<string, string> dict = new Dictionary<string, string>(); //dict["OldPassword"] = collection["OldPassword"]; //dict["NewPassword"] = collection["NewPassword"]; dict["ContractName"] = collection["ContractName"]; dict["Address"] = collection["Address"]; dict["Email"] = collection["Email"]; dict["ContractMobile"] = collection["ContractMobile"]; dict["Name"] = collection["Name"]; dict["Mobile"] = collection["Mobile"]; if (!MembershipService.CheckValidateCode(collection["ValidateCode"])) { //ViewData["CompanyID"] = companyID; ViewData["Name"] = username; ViewData["BasicInfo"] = dict; ViewData["Validatecode"] = "False"; return View(); } bool isSuccess = true; EnterpriseMemberInfo upadtedEMI = new EnterpriseMemberInfo(); upadtedEMI = new EnterpriseMemberInfoDao().Find(Int32.Parse(dict["MemberID"].ToString())); upadtedEMI.Address = collection["Address"]; upadtedEMI.ContractName = collection["ContractName"]; upadtedEMI.ContractMobile = collection["ContractMobile"]; MemberUserInfo mui = new MemberUserInfo(); Hashtable ht = new Hashtable(); ht["Mobile"] = collection["Mobile"]; ht["Name"] = collection["Name"]; ht["Userid"] = userid; try { new EnterpriseMemberInfoDao().Update(upadtedEMI); MembershipService.UpdateMail(userid, collection["Email"]); CRMMapper.Get().Update("MemberUserInfo.myupdate", ht); } catch (Exception) { isSuccess = false; } //ViewData["CompanyID"] = companyID; ViewData["Name"] = username; ViewData["Basicinfo"] = dict; ViewData["Success"] = isSuccess; } } } else { UserModel um = new MembershipUserService().GetUserName(userid); IDictionary dictex = new Dictionary<string, string>(); if (collection.Count == 0) { dictex.Add("Address", um.Address); dictex.Add("ContractMobile", um.Mobile); dictex.Add("Mobile", um.Mobile); dictex.Add("Email", um.Email); ViewData["Name"] = username; ViewData["BasicInfo"] = dictex; } else { dictex.Add("Address", collection["Address"]); dictex.Add("ContractMobile", collection["ContractMobile"]); dictex.Add("Mobile", collection["Mobile"]); dictex.Add("Email", collection["Email"]); ViewData["Name"] = username; ViewData["BasicInfo"] = dictex; if (!MembershipService.CheckValidateCode(collection["ValidateCode"])) { //ViewData["CompanyID"] = companyID; ViewData["Validatecode"] = "False"; return View(); } bool isSuccess = true; Hashtable ht = new Hashtable(); ht["Mobile"] = collection["Mobile"]; ht["Name"] = collection["Name"]; ht["Address"] = collection["Address"]; ht["Email"] = collection["Email"]; ht["Userid"] = userid; try { MembershipService.UpdateBaseInfo(ht); } catch (Exception) { isSuccess = false; } //ViewData["CompanyID"] = companyID; ViewData["Success"] = isSuccess; } } ViewData["titlename"] = "基本资料修改"; return View(); }
public ActionResult ChildUser(FormCollection collection) { Dictionary<string, string> sitemaster = GetSiteMaster(); ViewData["SiteMaster"] = sitemaster; int userid = Int32.Parse(CurrentUserInfo.UserID); MemberUserInfo mui=new MemberUserInfoDao().Find(userid); int memberid = mui.MemberID; CRMService crm = new CRMService(); int memberlevel=(int)crm.GetUserMemberLevel(userid); if (CurrentUserInfo != null) { if (collection.Count == 0) { ViewData["Name"] = CurrentUserInfo.UserName; //获得初始的功能列表 Hashtable htparm = new Hashtable(); htparm["MemberLevel"] = memberlevel; //IList<ProductFunction> versionFunctionList = crm.GetFunctions(memberid, ProductID,htparm); //string functionlist = string.Empty; Dictionary<string, string> functiondict = new Dictionary<string, string>(); int functioncount = 1; string html = string.Empty; IList<ProductFunction> versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm,1); foreach (ProductFunction func in versionFunctionList) { html += GetDict(functioncount, func, "kind1"); functioncount++; } functiondict.Add("kind1", html); html = string.Empty; versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 12); foreach (ProductFunction func in versionFunctionList) { html += GetDict(functioncount, func, "kind12"); functioncount++; } functiondict.Add("kind12", html); html = string.Empty; versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 2); foreach (ProductFunction func in versionFunctionList) { html += GetDict(functioncount, func, "kind2"); functioncount++; } functiondict.Add("kind2", html); html = string.Empty; versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 3); foreach (ProductFunction func in versionFunctionList) { html += GetDict(functioncount, func, "kind3"); functioncount++; } functiondict.Add("kind3", html); html = string.Empty; versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 4); foreach (ProductFunction func in versionFunctionList) { html += GetDict(functioncount, func, "kind4"); functioncount++; } functiondict.Add("kind4", html); html = string.Empty; versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 5); foreach (ProductFunction func in versionFunctionList) { html += GetDict(functioncount, func, "kind5"); functioncount++; } functiondict.Add("kind5", html); html = string.Empty; versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 6); foreach (ProductFunction func in versionFunctionList) { html += GetDict(functioncount, func, "kind6"); functioncount++; } functiondict.Add("kind6", html); html = string.Empty; versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 7); foreach (ProductFunction func in versionFunctionList) { html += GetDict(functioncount, func, "kind7"); functioncount++; } functiondict.Add("kind7", html); html = string.Empty; versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 8); foreach (ProductFunction func in versionFunctionList) { html += GetDict(functioncount, func, "kind8"); functioncount++; } functiondict.Add("kind8", html); html = string.Empty; ViewData["Function"] = functiondict; ViewData["Max"] = ""; } else { bool IsAdmin = new MemberUserInfoDao().IsAdmin(userid); if (!IsAdmin) { ViewData["Admin"] = IsAdmin; ViewData["Function"] = ""; ViewData["Max"] = ""; return View(); } else { //检查是否超过规定的子账户数 Hashtable htp=new Hashtable(); htp["MemberID"] = memberid; int maxchildcount = 0; int childusercount = CRMMapper.Get().QueryForObject<int>("MemberUserInfo.ChildUserCount", htp); if (CRMMapper.Get().QueryForObject<int>("SpecialChild.getcount", memberid) > 0) { maxchildcount = CRMMapper.Get().QueryForObject<int>("SpecialChild.getchildcount", memberid); } else { maxchildcount=GetMaxCount(memberlevel); } if (childusercount >= maxchildcount) { ViewData["Max"] = "对不起,您的子账户数超过了您的会员等级规定的子账户数!"; } else { UserModel newuser = new UserModel(); newuser.Username = collection["UserName"]; newuser.Password = collection["Password"]; newuser.Email = ""; /*if (!MembershipService.CheckValidateCode(collection["ValidateCode"])) { ViewData["Name"] = CurrentUserInfo.UserName; ViewData["UserInfo"] = collection["UserName"]; ViewData["Validatecode"] = "False"; return View(); }*/ if (!MembershipService.UserIsExists(newuser.Username)) { MembershipService.CreateNewUser(newuser); MemberUserInfo newMember = new MemberUserInfo(); int tempuserid = MembershipService.GetUserID(collection["UserName"]); newMember.UserID = tempuserid; newMember.MemberID = memberid; newMember.Name = collection["Name"]; newMember.IsMemberAdmin = 0; newMember.Mobile = collection["Mobile"]; newMember.Status = 1; new MemberUserInfoDao().Insert(newMember); //插入子账户功能表 ChildUserFunction newchildfunc = new ChildUserFunction(); newchildfunc.UserID = tempuserid; newchildfunc.ProductID = ProductID; newchildfunc.FunctionIDList = GetFunctionstring(collection); new ChildUserFunctionDao().Insert(newchildfunc); ViewData["Function"] = GetFunctionstringForView(userid, newchildfunc.FunctionIDList, memberid, ProductID); ViewData["PostExist"] = "False"; ViewData["ChildUser"] = "******"; ViewData["Max"] = ""; } else { ViewData["PostExist"] = "True"; ViewData["Max"] = ""; } } ViewData["IsExists"] = false; ViewData["Admin"] = IsAdmin; ViewData["Name"] = CurrentUserInfo.UserName; ViewData["UserInfo"] = collection["UserName"]; ViewData["RealName"] = collection["Name"]; ViewData["Mobile"] = collection["Mobile"]; } } } ViewData["titlename"] = "子账户新增"; return View(); }