public ActionResult IsCompanyNameExist(string comName) { if (comName != null && comName != "") { if (RegisterBusinessLayer.CheckCompanyExist(comName)) { return(Json(new { Result = false, Message = "已存在的公司名,请使用其他的公司名" })); } return(Json(new { Result = true, Message = "success" })); } else { return(Json(new { Result = true, Message = "success" })); } }
public ActionResult IsAccountExist(string account) { if (account != null && account != "") { if (RegisterBusinessLayer.CheckAccountExist(account)) { return(Json(new { Result = false, Message = "已存在的用户名,请使用其他的用户名" })); } return(Json(new { Result = true, Message = "success" })); } else { return(Json(new { Result = true, Message = "success" })); } }
public ActionResult Register_Post() { if (ModelState.IsValid) { Register register = new Register(); UpdateModel(register); RegisterBusinessLayer registerBusinessLayer = new RegisterBusinessLayer(); registerBusinessLayer.AddRegistredUser(register); return(RedirectToAction("Login", "Login")); } return(View()); }
public ActionResult SuperAdminCreateCompany(CompanyRegisterModel companyRM) { OrganizationService orService = new OrganizationService(); companyRM.companys = orService.GetAvaiOrganizations(); companyRM.WhichToShow = "company"; string uploadLicenceUri = ""; if (companyRM.CompanyID == "" || companyRM.CompanyID == null) { companyRM.CompanyIdError = "企业组织机构代码应为15位数字"; return(View(companyRM)); } if (companyRM.ZipCode != null && companyRM.ZipCode != null) { Regex zipcodeReg = new Regex("^\\d{6}$"); if ((!zipcodeReg.IsMatch(companyRM.ZipCode))) { companyRM.ZipCodeError = "邮编应为6位数字"; return(View(companyRM)); } } else { companyRM.ZipCodeError = "邮编应为6位数字"; return(View(companyRM)); } //Regex companyPhoneReg = new Regex("^[-\\d]{7-20}$"); //if ((!companyPhoneReg.IsMatch(companyRM.CompanyPhone))) //{ // companyRM.CompanyPhoneError = "公司电话格式有误"; // return View(companyRM); //} //验证用户名是否存在 if (companyRM.Account != null && companyRM.Account != "") { if (RegisterBusinessLayer.CheckAccountExist(companyRM.Account)) { companyRM.AccountError = "已存在的用户名,请使用其他的用户名"; return(View(companyRM)); } } else { companyRM.AccountError = "账号不能为空"; return(View(companyRM)); } //验证公司名是否存在 if (companyRM.CompanyName != null && companyRM.CompanyName != "") { if (RegisterBusinessLayer.CheckCompanyExist(companyRM.CompanyName)) { companyRM.CompanyNameError = "已存在的公司名,请使用其他的公司名"; return(View(companyRM)); } } else { companyRM.CompanyNameError = "公司名称不能为空"; return(View(companyRM)); } //验证邮箱格式 if (companyRM.ApplyEmail != null && companyRM.ApplyEmail != "") { string emailStr = @"^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,5})+$"; //邮箱正则表达式对象 Regex emailReg = new Regex(emailStr); if (!emailReg.IsMatch(companyRM.ApplyEmail)) { companyRM.EmailError = "请填写正确的邮箱格式"; return(View(companyRM)); } } else { companyRM.EmailError = "请填写正确的邮箱格式"; return(View(companyRM)); } if (companyRM.ApplyPhone != null && companyRM.ApplyPhone != "") { Regex mobileReg = new Regex("^[0-9]{11,11}$"); if (!mobileReg.IsMatch(companyRM.ApplyPhone)) { companyRM.MobileError = "手机号码应为11位数字"; return(View(companyRM)); } } else { companyRM.MobileError = "手机号码应为11位数字"; return(View(companyRM)); } /* * var file = Request.Files[0]; * if (file != null && file.ContentLength > 0) * { * * * //文件名的key和value * string savePath = Server.MapPath("~/upload/BusinessLicencePicture"); * if (!System.IO.Directory.Exists(savePath)) * { * System.IO.Directory.CreateDirectory(savePath); * } * Guid addToTheEnd = new Guid(); * string filepath = savePath + "\\" + file.FileName + addToTheEnd; * file.SaveAs(filepath); * uploadLicenceUri = filepath; * * } * else * { * //上传失败返回到注册页面 * return View(companyRM); * * //InfoAllRight = false; * //backMessage = backMessage + "上传图片有误/n"; * } */ //uploadLicenceUri = "asd/asd/asd"; if (companyRM.UploadLicenceUri != null && companyRM.UploadLicenceUri != "") { uploadLicenceUri = companyRM.UploadLicenceUri; } else { companyRM.UriError = "图片不能为空!"; return(View(companyRM)); } //保存 Organization org = new Organization(); org.BusinessLicence = companyRM.BusinessLicence; //get uri by last step org.BusinessLicensePicUri = uploadLicenceUri; org.ContacterName = companyRM.ApplyName; org.ContacterPhone = companyRM.ApplyPhone; org.Name = companyRM.CompanyName; org.OrganizationAddress = companyRM.Address; org.OrganizationNumber = companyRM.CompanyID; org.OrganizationTelephone = companyRM.CompanyPhone; org.OrganizationStatus = OrganizationStatus.Available; OrganizationType companyType; string comtype = companyRM.CompanyType; switch (comtype) { case "设计公司": companyType = OrganizationType.DesignCompany; break; case "建设公司": companyType = OrganizationType.BuildingCompany; break; case "审查机构": companyType = OrganizationType.Censorship; break; default: companyType = OrganizationType.DesignCompany; break; } org.OrganizationType = companyType; org.ProposerEmail = companyRM.ApplyEmail; org.ProposerName = companyRM.ApplyName; org.ProposerPhone = companyRM.ApplyPhone; org.ZipCode = companyRM.ZipCode; //new OrganizationService(); Customer cus = new Customer(); DateTime localDate = DateTime.Now; cus.CreateTime = localDate; cus.LastVisitTime = localDate; //need to add cus.EmployeeId = "P0802"; System.Guid guid = System.Guid.NewGuid(); cus.CustomerGuid = guid; cus.CustomerStatus = CustomerStatus.Available; cus.CustomerType = CustomerType.Admin; cus.Email = companyRM.ApplyEmail; cus.Mobile = companyRM.ApplyPhone; //need to add cus.Telephone = companyRM.ApplyPhone; //need to add cus.Department = "liuliu"; cus.Name = companyRM.ApplyName; //cus.Organization = org; cus.OrganizationId = org.Id; cus.Password = companyRM.Password; cus.UserAccount = companyRM.Account; bool isSuccess = new OrganizationService().InsertOrganizationAndUser(org, cus); //new CustomerService().Insert(cus); //设置登陆状态并跳转到对应功能页 // LoginCheck.PasswordSignIn(companyRM.Account, companyRM.Password, this.SetCustomerCookie); return(RedirectToAction("SuperAdminchecklist")); }
public ActionResult SuperAdminCreateUser(CompanyRegisterModel companyRM) { OrganizationService orService = new OrganizationService(); companyRM.companys = orService.GetAvaiOrganizations(); companyRM.WhichToShow = "user"; if (companyRM.UserAccount != "" && companyRM.UserAccount != null) { //验证用户名是否存在 if (RegisterBusinessLayer.CheckAccountExist(companyRM.UserAccount)) { companyRM.AccountError = "已存在的用户名,请使用其他的用户名"; return(View("Register", companyRM)); } } else { companyRM.AccountError = "用户名不能为空"; return(View("Register", companyRM)); } if (companyRM.UserEmail != "" && companyRM.UserEmail != null) { //验证邮箱格式 string emailStr = @"^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,5})+$"; //邮箱正则表达式对象 Regex emailReg = new Regex(emailStr); if (!emailReg.IsMatch(companyRM.UserEmail)) { companyRM.EmailError = "输入的邮件格式有误"; return(View("Register", companyRM)); } } else { companyRM.EmailError = "邮箱不能为空"; return(View("Register", companyRM)); } if (companyRM.UserMobile != "" && companyRM.UserMobile != null) { Regex mobileReg = new Regex("^[0-9]{11,11}$"); if (!mobileReg.IsMatch(companyRM.UserMobile)) { companyRM.MobileError = "手机格式有误"; return(View("Register", companyRM)); } } else { companyRM.MobileError = "手机号不能为空"; return(View("Register", companyRM)); } string userCompanyId = companyRM.UserCompanyId; int orgId; if (userCompanyId != null && userCompanyId != "") { orgId = Convert.ToInt32(userCompanyId); } else { companyRM.CompanyIdAndNameError = "公司名不能为空"; return(View("Register", companyRM)); } //保存 //OrganizationType companyType; //string comtype = companyRM.CompanyType; //switch (comtype) //{ // case "设计公司": companyType = OrganizationType.DesignCompany; break; // case "建设公司": companyType = OrganizationType.BuildingCompany; break; // case "审查机构": companyType = OrganizationType.Censorship; break; // default: companyType = OrganizationType.DesignCompany; break; //} //new OrganizationService(); Customer cus = new Customer(); DateTime localDate = DateTime.Now; cus.CreateTime = localDate; cus.LastVisitTime = localDate; //need to add cus.EmployeeId = "P0802"; System.Guid guid = System.Guid.NewGuid(); cus.CustomerGuid = guid; cus.CustomerStatus = CustomerStatus.Available; cus.CustomerType = CustomerType.User; cus.Email = companyRM.UserEmail; cus.Mobile = companyRM.UserMobile; //need to add cus.Telephone = companyRM.UserMobile; //need to add cus.Department = "liuliu"; cus.Name = companyRM.UserName; cus.OrganizationId = orgId; //cus.Organization = orService.GetOrgById(orgId); cus.Password = companyRM.UserPassword; cus.UserAccount = companyRM.UserAccount; new CustomerService().Insert(cus); //设置登陆状态并跳转到对应功能页 return(RedirectToAction("SuperAdminchecklist")); }