//保存 protected void Button1_Click(object sender, EventArgs e) { if (Request.QueryString["type"] != null) { if (!FileUpload2.HasFile && string.IsNullOrEmpty(Label1.Text)) { Message("请上传详细材料", false); return; } //更新 int id = Convert.ToInt32(Request.QueryString["id"].ToString()); var Item = DB.Achievements.FirstOrDefault(a => a.Id == id);//获取对象 Item.AchTitle = AchTitle.Text; Item.AchType = AchType.Text; Item.AchContent = AchContent.Text; Item.AchTel = AchTel.Text; Item.Honor = Honor.Text; if (FileUpload2.HasFile) { string fileName = string.Empty; Item.AchFile = FileUp.SaveFile(FileUpload2, Server.MapPath("~/UpFile/"), ref fileName); Item.FileName = fileName; } Item.State = "待审"; //更新数据 DB.Entry(Item).State = EntityState.Modified; DB.SaveChanges(); } else { //添加数据 int personId = Convert.ToInt32(Session["PersonId"]); Achievements Item = new Achievements(); Item.PersonId = personId; Item.AchTitle = AchTitle.Text; Item.AchType = AchType.Text; Item.AchContent = AchContent.Text; Item.AchTel = AchTel.Text; Item.Honor = Honor.Text; Item.State = "待审"; Item.OperTime = DateTime.Now; string fileName = string.Empty; Item.AchFile = FileUp.SaveFile(FileUpload1, Server.MapPath("~/UpFile/"), ref fileName); Item.FileName = fileName; DB.Achievements.Add(Item); DB.SaveChanges(); } Message("/AchievementsPage/Manage.aspx", "保存成功"); }
//保存 protected void Button1_Click(object sender, EventArgs e) { int id = Convert.ToInt32(Request.QueryString["id"].ToString()); int personId = Convert.ToInt32(Session["PersonId"]); ExpRecord Item = new ExpRecord(); Item.PersonId = personId; Item.ItemId = id; Item.ExpContent = ExpContent.Text; if (FileUpload3.HasFile) { string fileName = string.Empty; Item.UpFile = FileUp.SaveFile(FileUpload3, Server.MapPath("~/UpFile/"), ref fileName); Item.FileName = fileName; } Item.State = "正常"; Item.ExpTime = DateTime.Now; DB.ExpRecord.Add(Item); DB.SaveChanges(); Response.Redirect("/ExpRecordPage/Manage.aspx?id=" + id); }
//项目申报 protected void Button1_Click(object sender, EventArgs e) { if (Request.QueryString["type"] != null) { //添加 if (!FileUpload2.HasFile && string.IsNullOrEmpty(Label1.Text)) { Message("请上传详细材料", false); return; } //更新 int id = Convert.ToInt32(Request.QueryString["id"].ToString()); var Item = DB.ResearchItem.FirstOrDefault(a => a.Id == id);//获取对象 Item.ItemName = ItemName.Text; Item.ItemType = ItemType.Text; Item.ItemCompany = ItemCompany.Text; Item.MajorPerson = MajorPerson.Text; Item.Tel = Tel.Text; Item.Funds = Convert.ToDecimal(Funds.Text); Item.ExeYear = Convert.ToInt32(ExeYear.Text); if (FileUpload2.HasFile) { string fileName = string.Empty; Item.UpFile = FileUp.SaveFile(FileUpload2, Server.MapPath("~/UpFile/"), ref fileName); Item.FileName = fileName; } Item.State = "暂存"; //更新数据 DB.Entry(Item).State = EntityState.Modified; DB.SaveChanges(); } else { //添加 if (!FileUpload1.HasFile) { Message("请上传详细材料"); return; } ResearchItem Item = new ResearchItem(); Item.PersonId = Convert.ToInt32(Session["PersonId"]); Item.ItemName = ItemName.Text; Item.ItemType = ItemType.Text; Item.ItemCompany = ItemCompany.Text; Item.MajorPerson = MajorPerson.Text; Item.Tel = Tel.Text; Item.Funds = Convert.ToDecimal(Funds.Text); Item.ExeYear = Convert.ToInt32(ExeYear.Text); string fileName = string.Empty; Item.UpFile = FileUp.SaveFile(FileUpload1, Server.MapPath("~/UpFile/"), ref fileName); Item.FileName = fileName; Item.OperTime = DateTime.Now; Item.State = "暂存"; //插入数据 DB.ResearchItem.Add(Item); DB.SaveChanges(); //将自己作为参与人员 ItemPersonnel itemPerson = new ItemPersonnel(); itemPerson.ItemId = Item.Id; itemPerson.PersonId = Convert.ToInt32(Session["PersonId"]); itemPerson.OperTime = DateTime.Now; DB.ItemPersonnel.Add(itemPerson); DB.SaveChanges(); } Message("/ResearchItemPage/Manage.aspx", "保存成功"); }