private void DeleteClick(object sender, RoutedEventArgs e) { MessageBoxButton button = MessageBoxButton.YesNo; MessageBoxImage icon = MessageBoxImage.Warning; //MessageBoxResult result = MessageBox.Show(MessageBoxDeleteConfirm, MessageBoxDeleteConfirmCaption, button, icon); MessageBoxResult result = MessageBox.Show(TagDataContext.WPFMessageAndLabelForList.MessageBoxDeleteConfirm, TagDataContext.WPFMessageAndLabelForList.MessageBoxDeleteConfirmCaption, button, icon); string error = null; switch (result) { case MessageBoxResult.Yes: ModelNotifiedForTag itemSelected = (ModelNotifiedForTag)DataGridTag.SelectedItem; dataConnection.DeleteData(itemSelected, out error); if (string.IsNullOrEmpty(error)) { TagDataContext.modelNotifiedForTagMain.Remove(itemSelected); } break; case MessageBoxResult.No: return; } if (error != null) { MessageBox.Show(error); } else { //MessageBox.Show(MessageBoxDeleteOK); MessageBox.Show(TagDataContext.WPFMessageAndLabelForList.MessageBoxDeleteOK); btnReload_Click(null, null); } }
//private void CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) //{ //Notify("IncludeFolders"); //} public List <ModelNotifiedForTag> GetAllTag(out string error) { error = null; try { TagBsn bsn = new TagBsn(wpfConfig); List <TagInfo> dbItems = bsn.GetAll(); List <ModelNotifiedForTag> notifiedItems = new List <ModelNotifiedForTag>(); foreach (TagInfo dbItem in dbItems) { ModelNotifiedForTag itemToAdd = new ModelNotifiedForTag(); Cloner.CopyAllTo(typeof(TagInfo), dbItem, typeof(ModelNotifiedForTag), itemToAdd); itemToAdd.ItemChanged = false; itemToAdd.NewItem = false; notifiedItems.Add(itemToAdd); } return(notifiedItems); } catch (Exception ex) { error = ex.Message; } return(null); }
public void DeleteData(ModelNotifiedForTag modelNotifiedForTag, out string error) { TagGenericREST TagGenericREST = new TagGenericREST(wpfConfig); DeleteTagView deleteTagView = new DeleteTagView(); Cloner.CopyAllTo(typeof(ModelNotifiedForTag), modelNotifiedForTag, typeof(DeleteTagView), deleteTagView); TagGenericREST.Delete(deleteTagView, out error); }
public void AddData(ModelNotifiedForTag modelNotifiedForTag, out string error) { TagGenericREST TagGenericREST = new TagGenericREST(wpfConfig); CreateTagView createTagView = new CreateTagView(); Cloner.CopyAllTo(typeof(ModelNotifiedForTag), modelNotifiedForTag, typeof(CreateTagView), createTagView); TagGenericREST.Insert(createTagView, out error); }
public void SaveData(ModelNotifiedForTag modelNotifiedForTag, out string error) { TagGenericREST TagGenericREST = new TagGenericREST(wpfConfig); UpdateTagView updateTagView = new UpdateTagView(); Cloner.CopyAllTo(typeof(ModelNotifiedForTag), modelNotifiedForTag, typeof(UpdateTagView), updateTagView); TagGenericREST.Update(updateTagView, out error); }
public void DeleteData(ModelNotifiedForTag modelNotifiedForTag, out string error) { TagBsn bsn = new TagBsn(wpfConfig); TagInfo dbItem = new TagInfo(); Cloner.CopyAllTo(typeof(ModelNotifiedForTag), modelNotifiedForTag, typeof(TagInfo), dbItem); bsn.DeleteByID(dbItem, out error); }
public void AddData(ModelNotifiedForTag modelNotifiedForTag, out string error) { TagBsn bsn = new TagBsn(wpfConfig); TagInfo dbItem = new TagInfo(); Cloner.CopyAllTo(typeof(ModelNotifiedForTag), modelNotifiedForTag, typeof(TagInfo), dbItem); bsn.InsertOne(dbItem, out error); modelNotifiedForTag.NewItem = false; Cloner.CopyAllTo(typeof(TagInfo), dbItem, typeof(ModelNotifiedForTag), modelNotifiedForTag); }
/// <summary> /// Triggered by change in grid's row. /// </summary> private void OnSelectionChanged(object sender, SelectionChangedEventArgs e) { if ((DataGridTag.SelectedItem == null) || DataGridTag.SelectedItem.GetType() != typeof(ModelNotifiedForTag)) { //New row on grid's bottom. By default do nothing when new row is included return; } ModelNotifiedForTag selectedItem = (ModelNotifiedForTag)DataGridTag.SelectedItem; LoadDetail(selectedItem); }
/// <summary> /// Load Detail form/list in master detail. Triggered by user's change in Grid's Row. /// When row change, load "DetailForm" or "Detail List" (need to be configured) /// </summary> /// <param name="selectedItem"></param> private void LoadDetail(ModelNotifiedForTag selectedItem) { if (selectedItem == null) { return; } if (DetailListTagEmployee != null) { DetailListTagEmployee.LoadGrid(x => x.TagFK == selectedItem.TagID); } /* Note: the detail form can load only ONE row from 'TagEmployee'. It's necessary to inform DetailForm primary key here or create a custom Form.Load(). * if (DetailForm{0} != null) * { * //DetailFormTagEmployee.LoadForm(selectedItem.TagID); * } */ }
private void OpenFormClick(object sender, RoutedEventArgs e) { ModelNotifiedForTag itemSelected = (ModelNotifiedForTag)DataGridTag.SelectedItem; if (itemSelected == null) { return; } //Uncomment this line to allow navigation //this.FrameMainWindow.Navigate(this.DetailListGeoCities); /* COMPILE ERROR WARNING!!! If this line crash: * a) Generate the FORM version of this list. * b) Re-generate the LIST without the "OpenForm" feature.# * c) Remove this chunk of code*/ MyApp.WPFForms.Tag.FormWPFTag page = new MyApp.WPFForms.Tag.FormWPFTag(config); page.LoadForm(itemSelected.TagID); page.Setup_SetLanguage(CurrentLanguage); ContainerWindowSimple win = new ContainerWindowSimple(page, "Form Tag"); win.Show(); }
private void SaveClick(object sender, RoutedEventArgs e) { ModelNotifiedForTag itemSelected = (ModelNotifiedForTag)DataGridTag.SelectedItem; if (itemSelected == null) { return; } string error = null; if (itemSelected.NewItem) { dataConnection.AddData(itemSelected, out error); if (error == null) { btnReload_Click(null, null); } } else { dataConnection.SaveData(itemSelected, out error); } if (error == null) { //MessageBox.Show(MessageBoxSaveOK); MessageBox.Show(TagDataContext.WPFMessageAndLabelForList.MessageBoxSaveOK); } else { //MessageBox.Show(MessageBoxSaveError + error); MessageBox.Show(TagDataContext.WPFMessageAndLabelForList.MessageBoxSaveError + error); } }