public ActionResult ProductCategoryList() { var companyInfo = MemberService.GetCompanyInfoByUserId(PlantEngContext.Current.UserId); if (CECRequest.GetQueryString("action") == "delete") { //删除 int _id = CECRequest.GetQueryInt("Id", 0); bool flag = CompanyProductCategoryService.Delete(_id, companyInfo.CompanyId); if (!flag) { //暂时没有实现 //return JavaScript("<script type=\"text/javascript\">alert('删除失败');</script>"); } Response.Redirect("/accounts/company/productcategorylist"); Response.End(); } int id = CECRequest.GetQueryInt("Id", 0); var model = CompanyProductCategoryService.Get(id, companyInfo.CompanyId); //产品分类 ViewBag.CategoryList = CompanyProductCategoryService.GetCategoryList(companyInfo.CompanyId); return(View(model)); }
public ActionResult RegisterCompany() { var catList = CompanyProductCategoryService.GetSystemCategoryList(); ViewBag.CatList = catList; return(View()); }
public ActionResult ProductEdit() { int id = CECRequest.GetQueryInt("id", 0); var companyInfo = MemberService.GetCompanyInfoByUserId(PlantEngContext.Current.UserId); var model = CompanyProductService.Get(id, companyInfo.CompanyId); //产品分类 ViewBag.CategoryList = CompanyProductCategoryService.GetCategoryList(companyInfo.CompanyId); return(View(model)); }
public ActionResult Profile() { var companyInfo = MemberService.GetCompanyInfoByUserId(PlantEngContext.Current.UserId); var catList = CompanyProductCategoryService.GetSystemCategoryList(); ViewBag.CatList = catList; return(View(companyInfo)); }
// // GET: /Product/ #region == 首页 /product/ == /// <summary> /// 首页 /// </summary> /// <returns></returns> public ActionResult Index() { int pageIndex = CECRequest.GetQueryInt("page", 1); int catId = CECRequest.GetQueryInt("catId", 0); var list = CompanyProductService.List(new CompanyProductSearchSetting() { PageIndex = pageIndex, SystemCategoryId = catId }); ViewBag.List = list; var catList = CompanyProductCategoryService.GetSystemCategoryList(); ViewBag.CatList = catList; return(View()); }
public ActionResult ProductCategoryList(CompanyProductCategoryInfo oldModel) { var companyInfo = MemberService.GetCompanyInfoByUserId(PlantEngContext.Current.UserId); //保存 bool errors = false; if (string.IsNullOrEmpty(oldModel.Name)) { errors = true; ModelState.AddModelError("NAMEEMPTY", "名称不能为空"); } if (!errors && ModelState.IsValid) { //OK oldModel.CompanyId = companyInfo.CompanyId; CompanyProductCategoryService.Update(oldModel); ViewBag.Msg = "保存成功!"; } //产品分类 ViewBag.CategoryList = CompanyProductCategoryService.GetCategoryList(companyInfo.CompanyId); return(View(oldModel)); }
public ActionResult RegisterCompany(CompanyInfo oldModel, FormCollection fc) { var catList = CompanyProductCategoryService.GetSystemCategoryList(); ViewBag.CatList = catList; #region == 验证合法性 == bool errors = false; if (string.IsNullOrEmpty(oldModel.UserName)) { ModelState.AddModelError("USERNAME", "用户名不能为空"); errors = true; } if (string.IsNullOrEmpty(oldModel.Email)) { ModelState.AddModelError("EMAIL", "Email不能为空"); errors = true; } if (string.IsNullOrEmpty(oldModel.Password) || string.IsNullOrEmpty(fc["confirmpassword"])) { ModelState.AddModelError("PASSWORD", "密码不能为空"); errors = true; } if (oldModel.Password != fc["confirmpassword"]) { ModelState.AddModelError("PASSWORD2", "两次密码不一致,请重新输入"); errors = true; } if (string.IsNullOrEmpty(oldModel.RealName)) { ModelState.AddModelError("REALNAME", "真实姓名不能为空"); errors = true; } //判断用户名是否存在 if (!string.IsNullOrEmpty(oldModel.UserName)) { if (CheckBlockUser(oldModel.UserName) || MemberService.UserNameExists(oldModel.UserName)) { ModelState.AddModelError("USERNAMEEXISTS", "用户名已经存在,请选择其他用户名"); errors = true; } } //判断Email是否存在 if (!string.IsNullOrEmpty(oldModel.Email)) { if (MemberService.EmailExists(oldModel.Email)) { ModelState.AddModelError("EMAILEXISTS", "Email已经存在,请选择其他Email"); errors = true; } } //判断公司产品类别是否选择 var pc = fc["cbCat"]; if (string.IsNullOrEmpty(pc)) { ModelState.AddModelError("PRODUCTCATERROR", "请选择公司产品"); errors = true; } else { oldModel.Categories = pc.Split(new char [] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(i => Convert.ToInt32(i)).ToList(); } #endregion if (!errors && ModelState.IsValid) { //行业 oldModel.Industry = fc["Industry"]; oldModel.Province = fc["Province"]; oldModel.City = fc["City"]; oldModel.Position = fc["Position"]; //设置为企业用户类型 oldModel.Type = MemberType.Enterprise; oldModel.UserId = oldModel.Id = MemberService.Insert(oldModel); if (oldModel.UserId > 0) { //上传LOGO HttpFileCollectionBase files = Request.Files; HttpPostedFileBase postedFile = files["picfile"]; int errorCode = 0; oldModel.CompanyLogo = FileUpload.UploadCompanyLogo(postedFile, out errorCode); //插入企业用户信息 oldModel.CompanyId = MemberService.InsertCompany(oldModel); //登录 _Login(oldModel); Response.Redirect("/accounts/"); } else { ModelState.AddModelError("FINALERROR", "注册失败,请重试。"); } } return(View()); }
public ActionResult ProductEdit(CompanyProductInfo oldModel, FormCollection fc) { bool errors = false; bool isAdd = oldModel.Id == 0; var companyInfo = MemberService.GetCompanyInfoByUserId(PlantEngContext.Current.UserId); if (string.IsNullOrEmpty(oldModel.Title)) { errors = true; ModelState.AddModelError("TitleEmpty", "标题不能为空"); } if (string.IsNullOrEmpty(oldModel.Content)) { errors = true; ModelState.AddModelError("ContentEmpty", "内容不能为空"); } oldModel.SystemCategoryId = Utils.StrToInt(fc["syscat"], 0); if (oldModel.SystemCategoryId == 0) { errors = true; ModelState.AddModelError("SysCatEmpty", "请选择产品系统分类"); } //为了在更新的时候,判断新分类是否还是以前的分类,然后为更新新分类产品数做判断 int oldCatId = oldModel.CategoryId; oldModel.CategoryId = Utils.StrToInt(fc["cat"], 0); if (oldModel.CategoryId == 0) { errors = true; ModelState.AddModelError("CatEmpty", "请选择自定义分类"); } if (!errors && ModelState.IsValid) { oldModel.CompanyId = companyInfo.CompanyId; oldModel = CompanyProductService.Update(oldModel); if (isAdd) { //如果是添加,则更新产品分类表中的产品数 + 1 CompanyProductCategoryService.UpdateProductCount(oldModel.CategoryId, companyInfo.CompanyId, true); } else { //如果没有更改分类,则什么都不变 //否则则原来的分类的产品数-1,新分类产品数+ 1 if (oldCatId == oldModel.CategoryId) { //说明还是在原来的分类上更新 } else { //分类改变了 //原来的分类产品数 - 1 ,新分类数 + 1 CompanyProductCategoryService.UpdateProductCount(oldCatId, companyInfo.CompanyId, false); //新分类 + 1 CompanyProductCategoryService.UpdateProductCount(oldModel.CategoryId, companyInfo.CompanyId, true); } } ViewBag.Msg = "保存成功!"; } //产品分类 ViewBag.CategoryList = CompanyProductCategoryService.GetCategoryList(companyInfo.CompanyId); return(View(oldModel)); }
public ActionResult Profile(CompanyInfo oldModel, FormCollection fc) { bool errors = false; //var companyInfo = MemberService.GetCompanyInfoByUserId(PlantEngContext.Current.UserId); //oldModel = companyInfo; //POST过来oldModel中CompanyId = 0 //在这在设置一下 var catList = CompanyProductCategoryService.GetSystemCategoryList(); ViewBag.CatList = catList; var pc = fc["cbCat"]; if (string.IsNullOrEmpty(pc)) { errors = true; ModelState.AddModelError("PRODUCTCATERROR", "请选择公司产品"); } else { oldModel.Categories = pc.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(ii => Convert.ToInt32(ii)).ToList(); } #region == 上传 LOGO BANNER == //上传LOGO HttpFileCollectionBase files = Request.Files; HttpPostedFileBase logoFile = files["logofile"]; int logoErrorCode = 0; string logo = FileUpload.UploadCompanyLogo(logoFile, out logoErrorCode); if (!string.IsNullOrEmpty(logo)) { oldModel.CompanyLogo = logo; } if (logoErrorCode == 2) { errors = true; ModelState.AddModelError("FILEERROR", "LOGO格式错误,请重试"); } if (logoErrorCode == 3) { errors = true; ModelState.AddModelError("FILESIZEERROR", "LOGO大小请在3M以内"); } //上传Banner HttpPostedFileBase bannerFile = files["bannerfile"]; int bannerErrorCode = 0; string banner = FileUpload.UploadCompanyBanner(bannerFile, out bannerErrorCode); if (!string.IsNullOrEmpty(banner)) { oldModel.CompanyBanner = banner; } if (bannerErrorCode == 2) { errors = true; ModelState.AddModelError("BANNERFILEERROR", "BANNER格式错误,请重试"); } if (bannerErrorCode == 3) { errors = true; ModelState.AddModelError("BANNERFILESIZEERROR", "BANNER大小请在3M以内"); } #endregion if (!errors && ModelState.IsValid) { int i = MemberService.UpdateCompanyInfo(oldModel); if (i > 0) { ViewBag.Msg = "更新成功"; } else { ModelState.AddModelError("ERROR", "更新失败,请重试"); } } return(View(oldModel)); }