Example #1
0
        public ActionResult TempArticleDetails(int id)
        {
            HttpCookie cookie          = Request.Cookies["Employer"];
            string     EmployerAccount = cookie.Values["EmployerAccount"];

            ViewBag.tb_Article = TempArticle.GetTempArticleByTempArticleID(id, EmployerAccount);
            ViewBag.tb_Demand  = TempDemandInfo.GetTempDemandInfoByTempArticleID(id);
            return(View());
        }
Example #2
0
        public ActionResult TempArticleEdit(int id) //此处id表示TempArticleID
        {
            ViewBag.flag = true;                    //文章是否存在的标志

            HttpCookie cookie = Request.Cookies["Employer"];

            if (cookie != null)
            {
                string    EmployerAccount = cookie.Values["EmployerAccount"];
                DataTable temparticle     = TempArticle.GetTempArticleByTempArticleID(id, EmployerAccount);//得到临时表文章
                if (temparticle != null && temparticle.Rows.Count > 0)
                {
                    ViewBag.Article = temparticle;

                    //显示大型招聘会选项
                    int typeid = Convert.ToInt32(temparticle.Rows[0]["TypeID"]);
                    ViewBag.typename = ArticleType.GetTypeNameByTypeID(typeid);

                    if (typeid == 1)//专场招聘
                    {
                        ViewBag.PlaceListFirst = Article.GetPlaceListFirst();
                    }
                    else if (typeid == 2)//双选会
                    {
                        DataTable bigarticleTable2 = Article.SelectArticleFromArticle(2, DateTime.Now);
                        ViewBag.bigarticleTable2 = bigarticleTable2;
                    }
                    else if (typeid == 3)//组团招聘
                    {
                        DataTable bigarticleTable3 = Article.SelectArticleFromArticle(3, DateTime.Now);
                        ViewBag.bigarticleTable3 = bigarticleTable3;
                    }
                    //其他类型的文章不用管

                    //需求部分
                    ViewBag.DemandInfos = TempDemandInfo.GetTempDemandInfoByTempArticleID(id);
                }
                else
                {
                    ViewBag.flag = false;
                }                             //文章不存在
            }
            else
            {
                ViewBag.flag = false;
            }                            //cookie不存在

            return(View());
        }
Example #3
0
 public ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         // TODO: Add delete logic here
         bool flag = TempDemandInfo.Delete(id) && TempArticle.Delete(id);
         return(Json(flag));//true表示删除成功
         //return RedirectToAction("Index");
     }
     catch
     {
         return(Json(false));
         //return View();
     }
 }
Example #4
0
        public ActionResult TempArticleEdit(int id, FormCollection collection) //id为TempArticleID
        {
            //判断字段是否符合标准
            //第一部分:文章
            TempArticle temparticle = new TempArticle();

            //判断文章类型
            temparticle.TempArticleID = id;
            temparticle.TypeID        = TempArticle.GetTypeIDByTempArticleID(id);
            temparticle.Title         = Request["Title"].Trim();
            temparticle.Introduction  = Request["Introduction"].Trim();
            //temparticle.EditTime = DateTime.Now;//提交时间不再改变

            HttpCookie cookie = Request.Cookies["Employer"];

            if (cookie != null)
            {
                string EmployerAccount = cookie.Values["EmployerAccount"];
                temparticle.EditorAccount = EmployerAccount;//获取单位的Account
            }

            //temparticle.TypeID = Convert.ToInt32(Request["TypeID"].Trim());//得到类型
            temparticle.ContactInfo        = Request["ContactInfo"].Trim();
            temparticle.FileAddr           = ""; //下面上传文件时会赋值
            temparticle.IsAudit            = 1;  //待定
            temparticle.ArticleDescription = Request["ArticleDescription"].Trim();

            int bigarticle = -1;//初始值

            //判断文章类型
            if (temparticle.TypeID == 1)
            {
                temparticle.PlaceFirstID = Convert.ToInt32(Request["PlaceFirstID"]);
                temparticle.RecruitTime  = Convert.ToDateTime(Request["RecruitTime"]);
            }
            else if (temparticle.TypeID == 2)
            {
                if (Request["bigarticle2"] == null || Request["bigarticle2"] == "")
                {
                    return(Json(new { message = "必须选择一个要加入的双选会" }));//退出
                }
                bigarticle = Convert.ToInt32(Request["bigarticle2"]);
            }
            else if (temparticle.TypeID == 3)
            {
                if (Request["bigarticle3"] == null || Request["bigarticle3"] == "")
                {
                    return(Json(new { message = "必须选择一个要加入的组团招聘" }));//退出
                }
                bigarticle = Convert.ToInt32(Request["bigarticle3"]);
            }
            temparticle.BigArticleID = bigarticle;//默认-1是未选择大型招聘会文章的

            //第二部分:需求

            string[] PositionName     = Request.Form.GetValues("PositionName");
            string[] EducationalLevel = Request.Form.GetValues("EducationalLevel");
            string[] Major            = Request.Form.GetValues("Major");
            string[] DemandNum        = Request.Form.GetValues("DemandNum");
            string[] PositionDec      = Request.Form.GetValues("PositionDec");
            //判断需求是否符合标准

            List <TempDemandInfo> tempdemandInfo = new List <TempDemandInfo>();

            //判断有几个需求
            for (int i = 0; i < PositionName.Count(); ++i)
            {
                TempDemandInfo temp = new TempDemandInfo();
                //temp.TempArticleID = 1;//得到刚上传的文章ID,在下面的插入后会有赋值
                temp.PositionName     = PositionName[i].ToString().Trim();
                temp.EducationalLevel = EducationalLevel[i].ToString().Trim();
                temp.Major            = Major[i].ToString().Trim();
                temp.DemandNum        = Convert.ToInt32(DemandNum[i].ToString().Trim());
                temp.PositionDec      = PositionDec[i].ToString().Trim();

                tempdemandInfo.Add(temp);
            }

            if (Request["IsDeleteFile"].ToString().Trim() == "yes")
            {
                //处理文件上传
                if (Request.Files.Count > 0)
                {
                    //支持的类型
                    List <string> FileType = new List <string>();
                    FileType.Add("jpg");
                    FileType.Add("gif");
                    FileType.Add("png");
                    FileType.Add("bmp");
                    FileType.Add("jpeg");

                    FileType.Add("pdf");
                    FileType.Add("txt");
                    FileType.Add("xls");
                    FileType.Add("xlsx");
                    FileType.Add("doc");
                    FileType.Add("docx");

                    FileType.Add("rar");
                    FileType.Add("zip");

                    //获取文件
                    HttpPostedFileBase uploadFile = Request.Files[0];
                    //判断是否为空文件
                    if (uploadFile == null)//|| uploadFile.ContentLength == 0)
                    {
                        return(Json(new { message = "fileerror" }));
                    }

                    //截取文件后缀名,判断文件类型是否被支持
                    if (FileType.Contains(uploadFile.FileName.Substring(uploadFile.FileName.LastIndexOf(".") + 1)))
                    {
                        //用jobsky作为分段符号
                        var fileTime   = DateTime.Now.ToFileTime().ToString() + Path.GetFileName(uploadFile.FileName); //新命名的文件名(包含时间的整数形式)
                        var tofileName = Path.Combine(Request.MapPath("~/UploadFiles"), fileTime);                     //把两个名字连接起来
                        try
                        {
                            if (Directory.Exists(Server.MapPath("~/UploadFiles")) == false)//如果不存在就创建file文件夹
                            {
                                Directory.CreateDirectory(Server.MapPath("~/UploadFiles"));
                            }
                            uploadFile.SaveAs(tofileName);
                            temparticle.FileAddr = fileTime;//获得上传后的文件名
                        }
                        catch
                        {
                            return(Json(new { message = "fileerror" }));
                        }
                    }
                    else
                    {
                        return(Json(new { message = "fileerror" }));//不支持此格式文件上传
                    }
                }
            }
            else
            {
                temparticle.FileAddr = Request["IsDeleteFile"].ToString().Trim();//没有删除,则获得到的就是原来的文件名
            }

            //更新文章到数据库
            if (TempArticle.Update(temparticle))
            {
                //删除需求
                TempDemandInfo.Delete(temparticle.TempArticleID);
                //插入需求到数据库
                foreach (var t in tempdemandInfo)
                {
                    t.TempArticleID = temparticle.TempArticleID;
                    if (TempDemandInfo.Insert(t))
                    {
                        //插入成功
                    }
                    else
                    {
                        return(Json(new { message = "inserterror1" }));
                    }
                }
            }

            return(Json(new { message = "success" }));
        }