/// <summary> ///审批协议,这方法后面需要修改成事务。 /// </summary> /// <param name="model"></param> /// <returns></returns> public int ApporvalsProject(T_AgreeModel model) { int i = 0; int k = 0; //先获取 var node = this.GetById(model.Id); if (model.Status == 1) { //先获得协议号,先看有没有获得过协议号 // number = number + 55; // 字母A-Z编码在65-90 int AgreementNo = 0; //合同号 int index = 0; //项目中的第几个合同 T_CompanyBLL companybll = new T_CompanyBLL(); T_ProjectBLL projectbll = new T_ProjectBLL(); var projectnode = projectbll.GetById(model.ProjectId); T_Agree maxagree = dal.Filter(o => o.ProjectId == model.ProjectId && o.Status == 1).OrderByDescending(b => b.AgreeIndex).FirstOrDefault(); if (maxagree != null) { AgreementNo = maxagree.AgreeIndex > 0 ? int.Parse(maxagree.AgreeNo.Substring(0, maxagree.AgreeNo.Length - 1)) : int.Parse(maxagree.AgreeNo); index = int.Parse(maxagree.AgreeIndex.ToString()) + 1; } else { T_Company company = companybll.GetById((int)projectnode.CompanyId); AgreementNo = (int)company.AgreementNo; company.AgreementNo = AgreementNo + 1; k = companybll.Edit(company); } if (projectnode != null) { projectnode.Status = 1; k = projectbll.Edit(projectnode); } if (node != null) { node.Status = model.Status; node.AgreeDate = DateTime.Now; node.AgreeIndex = index; node.AgreeNo = index == 0 ? AgreementNo.ToString() : AgreementNo.ToString() + Helper.Method.Chr(64 + index); i = this.Edit(node); } } else { if (node != null) { node.Status = model.Status; node.AgreeDate = DateTime.Now; i = this.Edit(node); } } return(i); }
public static T_CompanyModel DTO(this T_Company node) { if (node == null) { return(null); } var model = new T_CompanyModel() { Id = node.Id, Company = node.Company, Alias = node.Alias, Phone = node.Phone, Address = node.Address, AgreementNo = node.AgreementNo, Email = node.Email, Fax = node.Fax, GST = node.GST, GSTReg = node.GSTReg, License = node.License, Logo = node.Logo, ReceiptNo = node.ReceiptNo, Registration = node.Registration, Departments = node.Departments.Count() > 0 ? node.Departments.ToList().Select(s => s.DTO()).ToList() : null, }; return(model); }
/// <summary> /// 获取公司信息页面 /// </summary> /// <param name="id">公司标识</param> public ActionResult CompanyInfo(string id) { if (string.IsNullOrEmpty(id)) { T_Company model = new T_Company(); return(View("CompanyInfo", model)); } else { ViewData["C_GUID"] = id; Session["CurrentCompany"] = id; //ViewData["MasterCompanyGuid"] = ""; List <T_Company> Info = new List <T_Company>(); Info = new CompanySvc().GetCompanyInfo(id, ""); if (Info.Count.Equals(0)) { T_Company model = new T_Company(); return(View("CompanyInfo", model)); } else { return(View("CompanyInfo", Info.FirstOrDefault())); } } }
public ActionResult EditCompany(int id) { IPropertyCompanyBLL propertyCompanyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL"); //获取要编辑的物业公司 T_Company company = propertyCompanyBll.GetEntity(m => m.Id == id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (company != null) { //初始化返回页面的模型 SetPropertyCompanyModel model = new SetPropertyCompanyModel() { Id = company.Id, Name = company.Name, Address = company.Address, Content = company.Content, Tel = company.Tel, Img = company.Img }; return(View(model)); } else { return(RedirectToAction("CompanyList")); } }
/// <summary> /// 更新商业伙伴信息 /// </summary> /// <param name="Company">商业伙伴对象</param> /// <returns></returns> public string UpdCompanyInformation(T_Company information, List <T_BankAccount> bankItems) { information.C_GUID = Session["CurrentCompanyGuid"].ToString(); bool result = new CompanySvc().UpdCompanyInformation(information); string msg = string.Empty; if (result) { Session["Taxpayer"] = information.Taxpayer; BankAccountSvc bankAccount = new BankAccountSvc(); if (bankItems != null) { foreach (T_BankAccount account in bankItems) { if (string.IsNullOrEmpty(account.BA_GUID)) { account.BA_GUID = Guid.NewGuid().ToString(); } account.C_GUID = Session["CurrentCompanyGuid"].ToString(); //account.AccountType = string.Empty; bankAccount.UpdBankAccount(account); } } msg = General.Resource.Common.Success; } else { msg = General.Resource.Common.Failed; } return(string.Format("{{\"Result\":{0},\"Msg\":\"{1}\"}}" , result.ToString().ToLower(), msg)); }
public ActionResult EditCompany() { int CompanyId = GetSessionModel().CompanyId.Value; IPropertyCompanyBLL propertyCompanyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL"); //获取要编辑的物业公司 T_Company company = propertyCompanyBll.GetEntity(m => m.Id == CompanyId && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (company != null) { //初始化返回页面的模型 PropertyCompanyModel model = new PropertyCompanyModel() { Id = company.Id, Name = company.Name, Address = company.Address, Content = company.Content, Tel = company.Tel }; return(View(model)); } else { return(RedirectToAction("CompanyDetail")); } }
public JsonResult DeleteCompany(int id) { JsonModel jm = new JsonModel(); //获取要删除的物业公司 IPropertyCompanyBLL propertyCompanBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL"); T_Company company = propertyCompanBll.GetEntity(m => m.Id == id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); //如果该物业公司存在 if (company == null) { jm.Msg = "该物业公司不存在"; } else if (company.PropertyPlaces.Count(p => p.DelFlag == ConstantParam.DEL_FLAG_DEFAULT) > 0) { jm.Msg = "该公司下有小区存在,不能删除"; } else { //修改指定物业公司中的已删除标识 company.DelFlag = ConstantParam.DEL_FLAG_DELETE; propertyCompanBll.Update(company); //操作日志 jm.Content = "删除物业公司 " + company.Name; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
public ActionResult Detail() { //获取登录物业公司 int CompanyId = GetSessionModel().CompanyId.Value; IPropertyCompanyBLL propertyCompanyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL"); T_Company company = propertyCompanyBll.GetEntity(m => m.Id == CompanyId && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (company != null) { //初始化返回页面的模型 PropertyCompanyModel model = new PropertyCompanyModel() { Name = company.Name, Address = company.Address, Content = company.Content, Img = company.Img, Tel = company.Tel }; return(View(model)); } else { return(View()); } }
public bool UpdCompanyInformation(T_Company form) { DBHelper dh = new DBHelper(); dh.strCmd = "SP_UpdCompanyInformation"; dh.AddPare("@C_GUID", SqlDbType.NVarChar, 50, form.C_GUID); dh.AddPare("@Name", SqlDbType.NVarChar, 50, form.Name); dh.AddPare("@Taxpayer", SqlDbType.NVarChar, 50, form.Taxpayer); dh.AddPare("@ChineseFullName", SqlDbType.NVarChar, 50, form.ChineseFullName); dh.AddPare("@EnglishFullName", SqlDbType.NVarChar, 50, form.EnglishFullName); dh.AddPare("@Website", SqlDbType.NVarChar, 50, form.Website); dh.AddPare("@ContactWay", SqlDbType.NVarChar, 50, form.ContactWay); dh.AddPare("@OrganizationCode", SqlDbType.NVarChar, 50, form.OrganizationCode); dh.AddPare("@IndustryInvolved", SqlDbType.NVarChar, 50, form.IndustryInvolved); dh.AddPare("@RegisteredAddress", SqlDbType.NVarChar, 50, form.RegisteredAddress); dh.AddPare("@LOGO", SqlDbType.NVarChar, 400, form.LOGO); dh.AddPare("@TaxNumber", SqlDbType.NVarChar, 400, form.TaxNumber); dh.AddPare("@Remark", SqlDbType.NVarChar, 50, form.Remark); dh.AddPare("@BusinessLicense", SqlDbType.NVarChar, 400, form.BusinessLicense); try { dh.NonQuery(); return(true); } catch (Exception ex) { return(false); } }
/// <summary> /// 公司信息 /// </summary> /// <param name="form">公司对象</param> /// <returns></returns> public bool UpdCompany(T_Company form, string uc_guid, string u_guid) { DBHelper dh = new DBHelper(); dh.strCmd = "SP_UpdCompany"; dh.AddPare("@U_GUID", SqlDbType.NVarChar, 50, u_guid); dh.AddPare("@UC_GUID", SqlDbType.NVarChar, 50, uc_guid); dh.AddPare("@C_GUID", SqlDbType.NVarChar, 50, form.C_GUID); dh.AddPare("@CompanyID", SqlDbType.NVarChar, 50, form.CompanyID); dh.AddPare("@Name", SqlDbType.NVarChar, 50, form.Name); dh.AddPare("@TaxPayer", SqlDbType.NVarChar, 50, form.Taxpayer); dh.AddPare("@Address", SqlDbType.NVarChar, 50, form.Address); dh.AddPare("@Country", SqlDbType.NVarChar, 50, form.Country); dh.AddPare("@Province", SqlDbType.NVarChar, 50, form.Province); dh.AddPare("@City", SqlDbType.NVarChar, 50, form.City); dh.AddPare("@Contacter", SqlDbType.NVarChar, 50, form.Contacter); dh.AddPare("@ContactWay", SqlDbType.NVarChar, 50, form.ContactWay); dh.AddPare("@Type", SqlDbType.NVarChar, 50, form.Type); dh.AddPare("@AuditDate", SqlDbType.DateTime, 0, form.AuditDate); try { dh.NonQuery(); return(true); } catch (Exception ex) { return(false); } }
/// <summary> /// 保存公司信息 /// </summary> /// <param name="form">公司对象</param> public string UpdCompany(T_Company form) { string msg = string.Empty; bool result = false; form.AuditDate = DateTime.Now.ToString(); if (string.IsNullOrEmpty(form.C_GUID) == true) { form.C_GUID = Guid.NewGuid().ToString(); form.MasterCompanyGuid = Session["MasterCompanyGuid"].ToString(); } else { form.MasterCompanyGuid = ""; } if (string.IsNullOrEmpty(form.MasterCompanyGuid) == true) { form.MasterCompanyGuid = Session["MasterCompanyGuid"].ToString(); } List <T_Company> info = new List <T_Company>(); info = new CompanySvc().GetCompanyInfo("", form.Name); if (info.Count.Equals(0)) { result = new CompanySvc().UpdCompany(form); if (result) { msg = General.Resource.Common.Success; } else { msg = General.Resource.Common.Failed; } return(string.Format("{{\"Result\":{0},\"Msg\":\"{1}\"}}" , result.ToString().ToLower(), msg)); } else { if (info.FirstOrDefault().C_GUID == form.C_GUID) { result = new CompanySvc().UpdCompany(form); if (result) { msg = General.Resource.Common.Success; } else { msg = General.Resource.Common.Failed; } return(string.Format("{{\"Result\":{0},\"Msg\":\"{1}\"}}" , result.ToString().ToLower(), msg)); } result = false; msg = General.Resource.Common.CompanyName + General.Resource.Common.Exist; return(string.Format("{{\"Result\":{0},\"Msg\":\"{1}\"}}", result.ToString().ToLower(), msg)); } }
public ActionResult CreateCompany(T_Company model) { var file = Request.Files["file_icon"]; dbContent.Entry(model).State = EntityState.Added; model.CreateDate = DateTime.Now; model.Icon = SaveFile(file); dbContent.SaveChanges(); return(Ok()); }
public JsonResult SetCompanyInfo(SetPropertyCompanyModel model) { JsonModel jm = new JsonModel(); if (ModelState.IsValid) { //存入文件的路径 string directory = Server.MapPath(ConstantParam.PROPERTY_COMPANY_DIR); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } HttpPostedFileBase file = model.UploadImg; string filename = Path.GetFileName(file.FileName); //获取上传文件名 string fileEx = Path.GetExtension(filename); //获取上传文件的扩展名 //存入的文件名 string FileName = DateTime.Now.ToFileTime().ToString() + fileEx; //保存数据文件 string savrPath = Path.Combine(directory, FileName); file.SaveAs(savrPath); IPropertyCompanyBLL propertyCompanyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL"); T_Company company = propertyCompanyBll.GetEntity(m => m.Id == model.Id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (company != null) { string oldFile = company.Img; company.Img = ConstantParam.PROPERTY_COMPANY_DIR + FileName; propertyCompanyBll.Update(company); //删除旧图标 if (!string.IsNullOrEmpty(oldFile)) { oldFile = Server.MapPath(oldFile); FileInfo f = new FileInfo(oldFile); if (f.Exists) { f.Delete(); } } } //日志记录 //jm.Content = PropertyUtils.ModelToJsonString(company); } else { jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
public ActionResult ViewUnitEdit(int ID) { T_Company model = db.T_Company.Find(ID); if (model != null) { return(View(model)); } else { return(HttpNotFound()); } }
public JsonResult UnitAddSave(T_Company model) { model.Isdelete = "0"; db.T_Company.Add(model); try { db.SaveChanges(); return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet)); } catch (DbEntityValidationException ex) { return(Json(new { State = "Faile", Message = ex.EntityValidationErrors.First().ValidationErrors.First().ErrorMessage }, JsonRequestBehavior.AllowGet)); } }
public ActionResult ModifyCompany(T_Company model) { var file = Request.Files["file_icon"]; if (file != null && file.ContentLength > 0) { model.Icon = SaveFile(file); } dbContent.Entry(model).State = EntityState.Modified; dbContent.Entry(model).Property(x => x.CreateDate).IsModified = false; dbContent.SaveChanges(); return(Ok()); }
public JsonResult UnitDelete(int ID) { T_Company editModel = db.T_Company.Find(ID); editModel.Isdelete = "1"; db.Entry <T_Company>(editModel).State = System.Data.Entity.EntityState.Modified; try { db.SaveChanges(); return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet)); } catch (DbEntityValidationException ex) { return(Json(new { State = "Faile", Message = ex.EntityValidationErrors.First().ValidationErrors.First().ErrorMessage }, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// 更新商业伙伴信息 /// </summary> /// <param name="Company">商业伙伴对象</param> /// <returns></returns> public string UpdCompanyInformation(T_Company information) { bool result = new CompanySvc().UpdCompanyInformation(information); string msg = string.Empty; if (result) { msg = General.Resource.Common.Success; } else { msg = General.Resource.Common.Failed; } return(string.Format("{{\"Result\":{0},\"Msg\":\"{1}\"}}" , result.ToString().ToLower(), msg)); }
public ActionResult CompanyDetail(int id) { IPropertyCompanyBLL propertyCompanyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL"); //获取要查看的物业公司介绍 T_Company company = propertyCompanyBll.GetEntity(m => m.Id == id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (company != null) { return(View(company)); } else { return(RedirectToAction("CompanyList")); } }
public String GetAllCompany() { string count = null; List <T_Company> coms = new List <T_Company>(); coms = new CompanySvc().GetAllCompany(); count = coms.Count().ToString(); T_Company com = new T_Company(); com.Count = count; com.C_GUID = Guid.NewGuid().ToString(); List <T_Company> company = new List <T_Company>(); company.Add(com); string json = new JavaScriptSerializer().Serialize(company); return(json); }
public ActionResult SetPlatCompanyInfo(int id) { IPropertyCompanyBLL propertyCompanyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL"); T_Company company = propertyCompanyBll.GetEntity(m => m.Id == id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (company != null) { SetPropertyCompanyModel model = new SetPropertyCompanyModel() { Id = id, Img = company.Img }; return(View(model)); } else { return(RedirectToAction("CompanyList")); } }
public ActionResult SetCompanyAdministrator(int id) { //获取要设置的物业总公司 IPropertyCompanyBLL propertyCompanyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL"); T_Company company = propertyCompanyBll.GetEntity(m => m.Id == id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (company != null) { //返回初始化模型页面 CompanyUserModel model = new CompanyUserModel(); model.CompanyId = company.Id; model.CompanyName = company.Name; ViewBag.Admins = company.CompanyUsers.Where(u => u.IsMgr == ConstantParam.USER_ROLE_MGR).Select(u => u.UserName).ToList(); return(View(model)); } else { return(RedirectToAction("CompanyList")); } }
public JsonResult EditCompany(PropertyCompanyModel model) { JsonModel jm = new JsonModel(); //如果表单模型验证成功 if (ModelState.IsValid) { IPropertyCompanyBLL propertyCompanyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL"); T_Company company = propertyCompanyBll.GetEntity(m => m.Id == model.Id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (company != null) { company.Name = model.Name; company.Address = model.Address; company.Content = model.Content; company.Tel = model.Tel; //保存到数据库 if (propertyCompanyBll.Update(company)) { //日志记录 jm.Content = PropertyUtils.ModelToJsonString(model); } else { jm.Msg = "编辑失败"; } } else { jm.Msg = "该物业公司不存在"; } } else { jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 公司信息 /// </summary> /// <param name="form">公司对象</param> /// <returns></returns> public bool UpdCompany(T_Company form) { DBHelper dh = new DBHelper(); dh.strCmd = "SP_UpdCompany"; dh.AddPare("@C_GUID", SqlDbType.NVarChar, 50, form.C_GUID); dh.AddPare("@Name", SqlDbType.NVarChar, 50, form.Name); dh.AddPare("@Address", SqlDbType.NVarChar, 50, form.Address); dh.AddPare("@Contacter", SqlDbType.NVarChar, 50, form.Contacter); dh.AddPare("@ContactWay", SqlDbType.NVarChar, 50, form.ContactWay); dh.AddPare("@Type", SqlDbType.NVarChar, 50, form.Type); dh.AddPare("@AuditDate", SqlDbType.DateTime, 0, form.AuditDate); dh.AddPare("@MasterCompanyGuid", SqlDbType.NVarChar, 50, form.MasterCompanyGuid); try { dh.NonQuery(); return(true); } catch (Exception ex) { return(false); } }
public bool AddNewCompany(FormCollection form) { bool result = false; List <T_Company> Info = new List <T_Company>(); Info = new CompanySvc().GetCompanyInfo("", form["CompanyID"]); if (Info.Count.Equals(0)) { //创建 //UpdCompany T_Company company = new T_Company(); company.C_GUID = Guid.NewGuid().ToString(); Session["C_GUID"] = company.C_GUID; company.Name = form["Name"]; company.Taxpayer = form["TaxO"]; company.CompanyID = form["CompanyID"]; string address = form["country"] + "-" + form["province"] + "-" + form["city"]; company.Address = address; company.Country = form["country"]; company.Province = form["province"]; company.City = form["city"]; company.Contacter = ""; company.ContactWay = ""; company.Type = ""; company.AuditDate = DateTime.Today.ToString(); if (new CompanySvc().UpdCompany(company, "", Session["CurrentUserGuid"].ToString())) { AddCompanyCurrency(company.C_GUID, form["Currency"]); AddCompanySetting(company.C_GUID, form["Currency"]); if (Session["CurrentCompanyGuid"].ToString() == "") { Session["CurrentCompanyGuid"] = company.C_GUID; } Session["Currency"] = form["Currency"]; int count = 0; List <T_ExpenseType> List = new List <T_ExpenseType>(); string cid = "66666666-6666-6666-6666-666666666666"; List = new DetailSvc().GetExpenseTypeList(cid, out count); string id = company.C_GUID.ToString(); for (var i = 0; i < List.Count; i++) { string newID = Guid.NewGuid().ToString(); T_ExpenseType form1 = new T_ExpenseType(); form1.ET_GUID = newID; form1.ExpenseType = List[i].ExpenseType; form1.ExpenseFlag = List[i].ExpenseFlag; form1.SaleFlag = List[i].SaleFlag; form1.ManageFlag = List[i].ManageFlag; form1.FinanceFlag = List[i].FinanceFlag; form1.OtherFlag = List[i].OtherFlag; form1.TaxFlag = List[i].TaxFlag; result = new DetailSvc().UpdExpenseTypeRecord(form1, id); } List <T_Tax> ListTax = new List <T_Tax>(); ListTax = new TaxSvc().GetTax(cid); for (var i = 0; i < ListTax.Count; i++) { string newID = Guid.NewGuid().ToString(); T_Tax form2 = new T_Tax(); form2.T_GUID = newID; form2.Name = ListTax[i].Name; form2.Rate = ListTax[i].Rate; form2.Type = ListTax[i].Type; form2.C_GUID = id; new TaxSvc().UpdTax(form2); } //List<T_RateHistory> RateList = new List<T_RateHistory>(); //RateList = new CurrencySvc().GetRateModel(cid,form["Currency"]); //for (var i = 0; i < RateList.Count; i++) //{ // string newID = Guid.NewGuid().ToString(); // T_RateHistory form3 = new T_RateHistory(); // form3.GUID = newID; // form3.FAmount = RateList[i].FAmount; // form3.FCurrency = RateList[i].FCurrency; // form3.TAmount = RateList[i].TAmount; // form3.TCurrency = RateList[i].TCurrency; // form3.CurrentRecord = RateList[i].CurrentRecord; // form3.Currency = RateList[i].Currency; // form3.Rate = RateList[i].Rate; // form3.TRate = RateList[i].TRate; // form3.C_GUID = id; // new CurrencySvc().UpdRateHistory(form3); //} /*添加快速关注模板(新建model以及表)**/ new AccountSvc().UpdIntAccount(cid, id); string Nowtime = GetMinutesDate().ToString(); List <T_QuickAttention> QuickAttenList = new List <T_QuickAttention>(); QuickAttenList = new ReportSvc().GetQuickAttentionModel(cid); for (var i = 0; i < QuickAttenList.Count; i++) { string newID = Guid.NewGuid().ToString(); T_QuickAttention form4 = new T_QuickAttention(); form4.id = newID; form4.c_guid = id; form4.attention_type = QuickAttenList[i].attention_type; form4.attention_type_amount = QuickAttenList[i].attention_type_amount; form4.statistical_time = Convert.ToDateTime(Nowtime); form4.statistical_currency = QuickAttenList[i].statistical_currency; form4.attention_state = QuickAttenList[i].attention_state; form4.push_account = QuickAttenList[i].push_account; form4.push_frequency = QuickAttenList[i].push_frequency; form4.company_name = QuickAttenList[i].company_name; new ReportSvc().UpdQuickAttention(form4); } result = true; } } else { result = false; } return(result); }
public JsonResult AddCompany(PropertyCompanyModel model) { JsonModel jm = new JsonModel(); //如果表单模型验证成功 if (ModelState.IsValid) { IPropertyCompanyBLL propertyCompanyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL"); //如果图片不为空 if (model.UploadImg != null) { //存入文件的路径 string directory = Server.MapPath(ConstantParam.PROPERTY_COMPANY_DIR); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } HttpPostedFileBase file = model.UploadImg; string filename = Path.GetFileName(file.FileName); //获取上传文件名 string fileEx = System.IO.Path.GetExtension(filename); //获取上传文件扩展名 //存入的文件名 string FileName = DateTime.Now.ToFileTime().ToString() + fileEx; //保存的数据文件 string savrPath = Path.Combine(directory, FileName); file.SaveAs(savrPath); //初始化平台物业公司数据实体 T_Company company = new T_Company() { Name = model.Name, Address = model.Address, Content = model.Content, Tel = model.Tel, Img = ConstantParam.PROPERTY_COMPANY_DIR + FileName }; //保存 propertyCompanyBll.AddCompany(company); //日志记录 jm.Content = PropertyUtils.ModelToJsonString(company); } else { //初始化平台物业公司数据实体 T_Company Company = new T_Company() { Name = model.Name, Address = model.Address, Content = model.Content, Tel = model.Tel }; //保存 propertyCompanyBll.AddCompany(Company); //日志记录 jm.Content = PropertyUtils.ModelToJsonString(Company); } } else { jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR; } return(Json(jm, JsonRequestBehavior.AllowGet)); }