public async Task <IActionResult> PutCase(int id, Case @case) { if (id != @case.CaseId) { return(BadRequest()); } _context.Entry(@case).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CaseExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void BtnOk_Click(object sender, EventArgs e)//当点击确定的时候,页面上的数据,要保存在caseInfo中,然后将caseInfo写回到数据库中 { Console.WriteLine("编辑案件:"); this.Case.Path = Program.m_mainform.g_workPath; this.Case.CaseName = textBox1.Text; this.Case.CaseSerialNum = textBox2.Text; this.Case.CaseType = comboBox1.Text; this.Case.Collecter = textBox3.Text; this.Case.CollecterNum = textBox4.Text; this.Case.CollecterDepartMent = comboBox2.Text; this.Case.InspectionPersonName = textBox5.Text; this.Case.InspectionPersonDepartMent = textBox6.Text; this.Case.OrganizationCode = textBox7.Text; this.Case.Note = textBox8.Text; //向数据库中写回更改之后的数据 AppConfig ac = AppConfig.getAppConfig(); using (CaseContext caseContext = new CaseContext()) { var caseInfo = this.Case; var entry = caseContext.Entry(caseInfo); caseContext.Set <Case>().Attach(entry.Entity); entry.State = System.Data.Entity.EntityState.Modified; caseContext.SaveChanges(); } Program.m_mainform.AddNewGjalAj(); MessageBox.Show("编辑案件成功!"); this.Close(); }
private void button1_Click(object sender, EventArgs e) { this.Proof.ProofName = textBox1.Text; this.Proof.ProofSerialNum = textBox2.Text; this.Proof.PhoneNum = textBox6.Text; this.Proof.phoneNum2 = textBox3.Text; this.Proof.Holder = textBox4.Text; this.Proof.ProofType = comboBox2.Text; this.Proof.note = textBox8.Text; //向数据库中写回更改之后的数据 AppConfig ac = AppConfig.getAppConfig(); using (CaseContext caseContext = new CaseContext()) { var proofInfo = this.Proof; var entry = caseContext.Entry(proofInfo); caseContext.Set <Proof>().Attach(entry.Entity); entry.State = System.Data.Entity.EntityState.Modified; caseContext.SaveChanges(); } Program.m_mainform.AddNewGjalAj(); MessageBox.Show("编辑证据成功!"); this.Close(); }