protected void GridView_ProductNotes_RowDeleting(object sender, GridViewDeleteEventArgs e) { int noteId = Convert.ToInt32(GridView_ProductNotes.DataKeys[e.RowIndex].Values[0]); using (ManufacturingDataDataContext dc = new ManufacturingDataDataContext()) { ProductNote note = dc.ProductNotes.Where(n => n.Id == noteId).Single(); dc.ProductNotes.DeleteOnSubmit(note); dc.SubmitChanges(); } BindGrid(); }
protected void GridView_ProductNotes_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow row = GridView_ProductNotes.Rows[e.RowIndex]; int noteId = Convert.ToInt32(GridView_ProductNotes.DataKeys[e.RowIndex].Values[0]); string note_str = (row.FindControl("Text_note") as TextBox).Text; string date_str = (row.FindControl("Text_effectiveDate") as TextBox).Text; using (ManufacturingDataDataContext dc = new ManufacturingDataDataContext()) { ProductNote note = dc.ProductNotes.Where(n => n.Id == noteId).Single(); note.Note = note_str; note.EffectiveDate = DateTime.Parse(date_str); dc.SubmitChanges(); } GridView_ProductNotes.EditIndex = -1; BindGrid(); }
protected void Insert(object sender, EventArgs e) { if (Text_note.Text == "") { return; } using (ManufacturingDataDataContext dc = new ManufacturingDataDataContext()) { ProductNote note = new ProductNote() { Note = Text_note.Text, EffectiveDate = DateTime.Parse(Text_effectiveDate.Text) }; dc.ProductNotes.InsertOnSubmit(note); dc.SubmitChanges(); } BindGrid(); }