Example #1
0
        protected void btn_Save_Click(object sender, EventArgs e)
        {
            DataEntities ent = new DataEntities();

            int id = WS.RequestInt("id");
            JobPost p = new JobPost();
            if (id > 0)
            {
                p = (from l in ent.JobPost where l.ID == id select l).FirstOrDefault();
            }

            p.CompanyID = ddl_Company.SelectedValue.ToInt32();
            p.Title = txt_Title.Text;
            p.Province = ddl_Province.SelectedValue.ToInt32();
            p.City = ddl_City.SelectedValue.ToInt32();
            p.Salary = ddl_Salary.SelectedValue.ToInt32();
            p.Expressions = ddl_Expressions.SelectedValue.ToInt32();
            p.Edu = ddl_Edu.SelectedValue.ToInt32();
            p.EmployNumber = txt_EmployNumber.Text.ToInt32();
            p.Intro = txt_Intro.Text;
            p.PostTime = DateTime.Now;
            p.IsSetTop = chk_Settop.Checked;
            p.SetTopTime = DateTime.Now;
            p.ExpireTime = txt_ExpireTime.Text.ToDateTime();

            //绑定教育
            List<JobPostEduAndEmployeeCount> edus = new List<JobPostEduAndEmployeeCount>();
            foreach (var ed in JobAction.Edu)
            {
                edus.Add(new JobPostEduAndEmployeeCount() { Checked = false, key = ed.Key, Number = 0, Text = ed.Value });
            }
            string[] chk = WS.RequestString("chk").Split(',');
            string[] nums = WS.RequestString("number").Split(',');
            for (int i = 0; i < chk.Length; i++)
            {
                edus[i].Checked = chk[i].ToBoolean();
                edus[i].Number = nums[i].ToInt32();
            }

            p.Ext1 = Voodoo.IO.XML.Serialize(edus);

            if (p.ID <= 0)
            {
                //处理城市热度
                try
                {
                    var ct = (from l in ent.City where l.id == p.City select l).FirstOrDefault();
                    ct.Hot += 1;
                }
                catch { }

                ent.AddToJobPost(p);
            }
            ent.SaveChanges();
            ent.Dispose();

            Js.AlertAndChangUrl("保存成功!", refer);
        }