public JsonResult IsExist(string BNumber = null,int BID=0, string BFullName = null, string NumberEmp = null, int EmpID = 0, RegisterModel reg = null) { if (BNumber != null) { if (BID > 0) { return Json(db.BDepartments.Where(m => m.BID!=BID&&m.BNumber.Equals(BNumber)).Count() <= 0, JsonRequestBehavior.AllowGet); } return Json(db.BDepartments.Where(m => m.BNumber.Equals(BNumber)).Count() <= 0, JsonRequestBehavior.AllowGet); } else if (BFullName != null) {//BFullName BID用来判断是否Edit if (db.BDepartments.Where(m => m.BID == BID).Count() > 0) { //判断是否有重复 if (db.BDepartments.Where(m => m.BFullName.Equals(BFullName)).Count() > 0) { //判断是否自身 return Json(db.BDepartments.Where(m => m.BFullName.Equals(BFullName) && m.BID == BID).Count() > 0, JsonRequestBehavior.AllowGet); } //没重复返回true return Json(true, JsonRequestBehavior.AllowGet); } //CREATE验证 return Json(db.BDepartments.Where(m => m.BFullName.Equals(BFullName)).Count() <= 0, JsonRequestBehavior.AllowGet); } //**************BEmplyee*********** else { //if (db.BEmplyees.Where(m => m.EmpID == EmpID).Count()>0) //{ // return Json(true, JsonRequestBehavior.AllowGet); //} if (reg != null&®.bemplyee!=null) { NumberEmp = reg.bemplyee.NumberEmp; } if (EmpID > 0) { return Json(db.BEmplyees.Where(m => m.EmpID != EmpID && m.NumberEmp.Equals(NumberEmp)).Count() <= 0, JsonRequestBehavior.AllowGet); } return Json(db.BEmplyees.Where(m=>m.NumberEmp.Equals(NumberEmp)).Count()<=0,JsonRequestBehavior.AllowGet); } }
public ActionResult Register(RegisterModel register) { if (ModelState.IsValid) { HttpPostedFileBase fCodeAtt = Request.Files["fCodeAtt"]; HttpPostedFileBase fTaxAtt = Request.Files["fTaxAtt"]; HttpPostedFileBase fCertAtt = Request.Files["fCertAtt"]; HttpPostedFileBase fLicenceAtt = Request.Files["fLicenceAtt"]; HttpPostedFileBase fDelegateBook = Request.Files["fDelegateBook"]; //**************** 委托书 ************** HttpPostedFileBase fPromiseAtt = Request.Files["fPromiseAtt"]; HttpPostedFileBase fSecretAtt = Request.Files["fSecretAtt"]; HttpPostedFileBase fPeopleAtt = Request.Files["fPeopleAtt"]; HttpPostedFileBase fOpenAccountAtt = Request.Files["fOpenAccountAtt"]; HttpPostedFileBase fprojectAtt = Request.Files["fprojectAtt"]; //**************** 委托书 ************** if (fCodeAtt == null || fTaxAtt == null || fCertAtt == null || fLicenceAtt == null || fDelegateBook == null || fPromiseAtt==null) { return Content("error file is null"); } if (Path.GetExtension(fCodeAtt.FileName).ToLower().EndsWith("exe")|| Path.GetExtension(fTaxAtt.FileName).ToLower().EndsWith("exe") || Path.GetExtension(fCertAtt.FileName).ToLower().EndsWith("exe") || Path.GetExtension(fCertAtt.FileName).ToLower().EndsWith("exe") || //**************** 委托书 ************** Path.GetExtension(fPromiseAtt.FileName).ToLower().EndsWith("exe") || Path.GetExtension(fDelegateBook.FileName).ToLower().EndsWith("exe")) { return Content("请上传办公文件或压缩文件"); } //using( TransactionScope scope=new TransactionScope()) //{ WebSecurity.CreateUserAndAccount(register.bemplyee.NumberEmp, register.Password); BEmplyee emp = db.BEmplyees.Single(m => m.NumberEmp.Equals(register.bemplyee.NumberEmp)); emp.CopyFrom(register.bemplyee); //**************** 保密协议 ************** emp.SecretAtt = DateTime.Now.ToString("yyyyMMdd") + Guid.NewGuid().ToString("N"); if (fSecretAtt != null) { Directory.CreateDirectory(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.SecretAtt.Substring(0, 4) + @"\" + emp.SecretAtt.Substring(4, 4) + @"\"))); fSecretAtt.SaveAs(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.SecretAtt.Substring(0, 4) + @"\" + emp.SecretAtt.Substring(4, 4) + @"\" + emp.SecretAtt.Substring(8)))); GenericDataAccess.UpdateBySql("Insert into YZAppAttachment(FileID,Name,Ext,Size,OwnerAccount) values(@FileID,@Name,@Ext,@Size,@OwnerAccount)", new string[,] { { "@FileID",emp.SecretAtt,"DbType.String",null }, { "@Name",Path.GetFileName(fSecretAtt.FileName),"DbType.String",null }, { "@Ext",Path.GetExtension(fSecretAtt.FileName),"DbType.String",null }, { "@Size",fSecretAtt.ContentLength.ToString(),"DbType.Int32",null }, { "@OwnerAccount","0","DbType.String",null } }); } //*******************资格证明*********** //**************** 开户许可证 ************** emp.OpenAccountAtt = DateTime.Now.ToString("yyyyMMdd") + Guid.NewGuid().ToString("N"); if (fOpenAccountAtt != null) { Directory.CreateDirectory(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.OpenAccountAtt.Substring(0, 4) + @"\" + emp.OpenAccountAtt.Substring(4, 4) + @"\"))); fOpenAccountAtt.SaveAs(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.OpenAccountAtt.Substring(0, 4) + @"\" + emp.OpenAccountAtt.Substring(4, 4) + @"\" + emp.OpenAccountAtt.Substring(8)))); GenericDataAccess.UpdateBySql("Insert into YZAppAttachment(FileID,Name,Ext,Size,OwnerAccount) values(@FileID,@Name,@Ext,@Size,@OwnerAccount)", new string[,] { { "@FileID",emp.OpenAccountAtt,"DbType.String",null }, { "@Name",Path.GetFileName(fOpenAccountAtt.FileName),"DbType.String",null }, { "@Ext",Path.GetExtension(fOpenAccountAtt.FileName),"DbType.String",null }, { "@Size",fOpenAccountAtt.ContentLength.ToString(),"DbType.Int32",null }, { "@OwnerAccount","0","DbType.String",null } }); } //**************** 类似项目的经营业绩 ************** emp.projectAtt = DateTime.Now.ToString("yyyyMMdd") + Guid.NewGuid().ToString("N"); if (fprojectAtt != null) { Directory.CreateDirectory(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.projectAtt.Substring(0, 4) + @"\" + emp.projectAtt.Substring(4, 4) + @"\"))); fprojectAtt.SaveAs(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.projectAtt.Substring(0, 4) + @"\" + emp.projectAtt.Substring(4, 4) + @"\" + emp.projectAtt.Substring(8)))); GenericDataAccess.UpdateBySql("Insert into YZAppAttachment(FileID,Name,Ext,Size,OwnerAccount) values(@FileID,@Name,@Ext,@Size,@OwnerAccount)", new string[,] { { "@FileID",emp.projectAtt,"DbType.String",null }, { "@Name",Path.GetFileName(fprojectAtt.FileName),"DbType.String",null }, { "@Ext",Path.GetExtension(fprojectAtt.FileName),"DbType.String",null }, { "@Size",fprojectAtt.ContentLength.ToString(),"DbType.Int32",null }, { "@OwnerAccount","0","DbType.String",null } }); } //**************** 保密协议 ************** emp.PeopleAtt = DateTime.Now.ToString("yyyyMMdd") + Guid.NewGuid().ToString("N"); if (fPeopleAtt != null) { Directory.CreateDirectory(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.PeopleAtt.Substring(0, 4) + @"\" + emp.PeopleAtt.Substring(4, 4) + @"\"))); fPeopleAtt.SaveAs(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.PeopleAtt.Substring(0, 4) + @"\" + emp.PeopleAtt.Substring(4, 4) + @"\" + emp.PeopleAtt.Substring(8)))); GenericDataAccess.UpdateBySql("Insert into YZAppAttachment(FileID,Name,Ext,Size,OwnerAccount) values(@FileID,@Name,@Ext,@Size,@OwnerAccount)", new string[,] { { "@FileID",emp.PeopleAtt,"DbType.String",null }, { "@Name",Path.GetFileName(fPeopleAtt.FileName),"DbType.String",null }, { "@Ext",Path.GetExtension(fPeopleAtt.FileName),"DbType.String",null }, { "@Size",fPeopleAtt.ContentLength.ToString(),"DbType.Int32",null }, { "@OwnerAccount","0","DbType.String",null } }); } //**************** 委托书 ************** emp.PromiseAtt = DateTime.Now.ToString("yyyyMMdd") + Guid.NewGuid().ToString("N"); if (fPromiseAtt != null) { Directory.CreateDirectory(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.PromiseAtt.Substring(0, 4) + @"\" + emp.PromiseAtt.Substring(4, 4) + @"\"))); fPromiseAtt.SaveAs(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.PromiseAtt.Substring(0, 4) + @"\" + emp.PromiseAtt.Substring(4, 4) + @"\" + emp.PromiseAtt.Substring(8)))); GenericDataAccess.UpdateBySql("Insert into YZAppAttachment(FileID,Name,Ext,Size,OwnerAccount) values(@FileID,@Name,@Ext,@Size,@OwnerAccount)", new string[,] { { "@FileID",emp.PromiseAtt,"DbType.String",null }, { "@Name",Path.GetFileName(fPromiseAtt.FileName),"DbType.String",null }, { "@Ext",Path.GetExtension(fPromiseAtt.FileName),"DbType.String",null }, { "@Size",fPromiseAtt.ContentLength.ToString(),"DbType.Int32",null }, { "@OwnerAccount","0","DbType.String",null } }); } emp.CodeAtt = DateTime.Now.ToString("yyyyMMdd") + Guid.NewGuid().ToString("N"); if (fCodeAtt != null) { Directory.CreateDirectory(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.CodeAtt.Substring(0, 4) + @"\" + emp.CodeAtt.Substring(4, 4) + @"\"))); fCodeAtt.SaveAs(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.CodeAtt.Substring(0, 4) + @"\" + emp.CodeAtt.Substring(4, 4) + @"\" + emp.CodeAtt.Substring(8)))); GenericDataAccess.UpdateBySql("Insert into YZAppAttachment(FileID,Name,Ext,Size,OwnerAccount) values(@FileID,@Name,@Ext,@Size,@OwnerAccount)", new string[,] { { "@FileID",emp.CodeAtt,"DbType.String",null }, { "@Name",Path.GetFileName(fCodeAtt.FileName),"DbType.String",null }, { "@Ext",Path.GetExtension(fCodeAtt.FileName),"DbType.String",null }, { "@Size",fCodeAtt.ContentLength.ToString(),"DbType.Int32",null }, { "@OwnerAccount","0","DbType.String",null } }); } emp.TaxAtt = DateTime.Now.ToString("yyyyMMdd") + Guid.NewGuid().ToString("N"); if (fTaxAtt != null) { Directory.CreateDirectory(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.TaxAtt.Substring(0, 4) + @"\" + emp.TaxAtt.Substring(4, 4) + @"\"))); fTaxAtt.SaveAs(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.TaxAtt.Substring(0, 4) + @"\" + emp.TaxAtt.Substring(4, 4) + @"\" + emp.TaxAtt.Substring(8)))); GenericDataAccess.UpdateBySql("Insert into YZAppAttachment(FileID,Name,Ext,Size,OwnerAccount) values(@FileID,@Name,@Ext,@Size,@OwnerAccount)", new string[,] { { "@FileID",emp.TaxAtt,"DbType.String",null }, { "@Name",Path.GetFileName(fTaxAtt.FileName),"DbType.String",null }, { "@Ext",Path.GetExtension(fTaxAtt.FileName),"DbType.String",null }, { "@Size",fTaxAtt.ContentLength.ToString(),"DbType.Int32",null }, { "@OwnerAccount","0","DbType.String",null } }); } emp.CertAtt = DateTime.Now.ToString("yyyyMMdd") + Guid.NewGuid().ToString("N"); if (fCertAtt != null) { Directory.CreateDirectory(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.CertAtt.Substring(0, 4) + @"\" + emp.CertAtt.Substring(4, 4) + @"\"))); fCertAtt.SaveAs(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.CertAtt.Substring(0, 4) + @"\" + emp.CertAtt.Substring(4, 4) + @"\" + emp.CertAtt.Substring(8)))); GenericDataAccess.UpdateBySql("Insert into YZAppAttachment(FileID,Name,Ext,Size,OwnerAccount) values(@FileID,@Name,@Ext,@Size,@OwnerAccount)", new string[,] { { "@FileID",emp.CertAtt,"DbType.String",null }, { "@Name",Path.GetFileName(fCertAtt.FileName),"DbType.String",null }, { "@Ext",Path.GetExtension(fCertAtt.FileName),"DbType.String",null }, { "@Size",fCertAtt.ContentLength.ToString(),"DbType.Int32",null }, { "@OwnerAccount","0","DbType.String",null } }); } emp.LicenceAtt = DateTime.Now.ToString("yyyyMMdd") + Guid.NewGuid().ToString("N"); if (fLicenceAtt != null) { Directory.CreateDirectory(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.LicenceAtt.Substring(0, 4) + @"\" + emp.LicenceAtt.Substring(4, 4) + @"\"))); fLicenceAtt.SaveAs(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.LicenceAtt.Substring(0, 4) + @"\" + emp.LicenceAtt.Substring(4, 4) + @"\" + emp.LicenceAtt.Substring(8)))); GenericDataAccess.UpdateBySql("Insert into YZAppAttachment(FileID,Name,Ext,Size,OwnerAccount) values(@FileID,@Name,@Ext,@Size,@OwnerAccount)", new string[,] { { "@FileID",emp.LicenceAtt,"DbType.String",null }, { "@Name",Path.GetFileName(fLicenceAtt.FileName),"DbType.String",null }, { "@Ext",Path.GetExtension(fLicenceAtt.FileName),"DbType.String",null }, { "@Size",fLicenceAtt.ContentLength.ToString(),"DbType.Int32",null }, { "@OwnerAccount","0","DbType.String",null } }); } emp.DelegateBook = DateTime.Now.ToString("yyyyMMdd") + Guid.NewGuid().ToString("N"); if (fDelegateBook != null) { Directory.CreateDirectory(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.DelegateBook.Substring(0, 4) + @"\" + emp.DelegateBook.Substring(4, 4) + @"\"))); fDelegateBook.SaveAs(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.DelegateBook.Substring(0, 4) + @"\" + emp.DelegateBook.Substring(4, 4) + @"\" + emp.DelegateBook.Substring(8)))); GenericDataAccess.UpdateBySql("Insert into YZAppAttachment(FileID,Name,Ext,Size,OwnerAccount) values(@FileID,@Name,@Ext,@Size,@OwnerAccount)", new string[,] { { "@FileID",emp.DelegateBook,"DbType.String",null }, { "@Name",Path.GetFileName(fDelegateBook.FileName),"DbType.String",null }, { "@Ext",Path.GetExtension(fDelegateBook.FileName),"DbType.String",null }, { "@Size",fDelegateBook.ContentLength.ToString(),"DbType.Int32",null }, { "@OwnerAccount","0","DbType.String",null } }); } emp.RegisterDate = System.DateTime.Now; db.SaveChanges(); //WebSecurity.Login(emp.NumberEmp, register.Password); //System.Web.Routing.RouteValueDictionary routv= new System.Web.Routing.RouteValueDictionary(); //routv.Add("EmpID","6"); //return RedirectToAction("Create", "Tender_CompanyInfo", routv); // scope.Complete(); //} return Content("注册成功!请登录"); //return RedirectToLocal("/"); } return View(); }