protected void GridNoteView_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) { List <Note> notes = (List <Note>)GridNoteView.DataSource; Note note = new Note(); var newValue = e.NewValues; note.Date = newValue["Date"] == null? DateTime.Now: (DateTime)newValue["Date"]; note.Text = newValue["Text"].ToString() ?? string.Empty; note.Title = newValue["Title"].ToString() ?? string.Empty; notes.Add(note); var model = Controller.GetData(ModelId); model.Notes = notes; Controller.Update(model); var Model = Controller.GetData(ModelId); e.Cancel = true; GridNoteView.CancelEdit(); GridNoteView.DataSource = Model.Notes; GridNoteView.DataBind(); }
protected void GridNoteView_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) { List <Note> notes = (List <Note>)GridNoteView.DataSource; string id = e.Keys[0].ToString(); Note note = notes.Find(m => m.Id == id); var newValue = e.NewValues; notes.Remove(note); note.Date = newValue["Date"] == null ? DateTime.Now : (DateTime)newValue["Date"]; note.Text = newValue["Text"].ToString() ?? string.Empty; note.Title = newValue["Title"].ToString() ?? string.Empty; notes.Add(note); var model = controller.GetCustomer(modelid); model.Notes = notes; controller.UpdateCustomer(model); e.Cancel = true; GridNoteView.CancelEdit(); GridNoteView.DataSource = notes; GridNoteView.DataBind(); }
protected void GridNoteView_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e) { List <Note> notes = (List <Note>)GridNoteView.DataSource; string id = e.Keys[0].ToString(); Note note = notes.Find(m => m.Id == id); notes.Remove(note); var model = Controller.GetData(ModelId); model.Notes = notes; Controller.Update(model); e.Cancel = true; GridNoteView.CancelEdit(); GridNoteView.DataSource = notes; GridNoteView.DataBind(); }
protected void GridCustomerEmailView_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e) { List <CustomerContact> contacts = (List <CustomerContact>)GridCustomerEmailView.DataSource; string id = e.Keys[0].ToString(); CustomerContact contact = contacts.Find(m => m.Id == id); contacts.Remove(contact); var model = controller.GetCustomer(modelid); model.Contacts = contacts; controller.UpdateCustomer(model); e.Cancel = true; GridNoteView.CancelEdit(); GridCustomerEmailView.DataSource = contacts; GridCustomerEmailView.DataBind(); }