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(ShippersDataContext.WPFMessageAndLabelForList.MessageBoxDeleteConfirm, ShippersDataContext.WPFMessageAndLabelForList.MessageBoxDeleteConfirmCaption, button, icon); string error = null; switch (result) { case MessageBoxResult.Yes: ModelNotifiedForShippers itemSelected = (ModelNotifiedForShippers)DataGridShippers.SelectedItem; dataConnection.DeleteData(itemSelected, out error); if (string.IsNullOrEmpty(error)) { ShippersDataContext.modelNotifiedForShippersMain.Remove(itemSelected); } break; case MessageBoxResult.No: return; } if (error != null) { MessageBox.Show(error); } else { //MessageBox.Show(MessageBoxDeleteOK); MessageBox.Show(ShippersDataContext.WPFMessageAndLabelForList.MessageBoxDeleteOK); btnReload_Click(null, null); } }
//private void CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) //{ //Notify("IncludeFolders"); //} public List <ModelNotifiedForShippers> GetAllShippers(out string error) { error = null; try { ShippersBsn bsn = new ShippersBsn(wpfConfig); List <ShippersInfo> dbItems = bsn.GetAll(); List <ModelNotifiedForShippers> notifiedItems = new List <ModelNotifiedForShippers>(); foreach (ShippersInfo dbItem in dbItems) { ModelNotifiedForShippers itemToAdd = new ModelNotifiedForShippers(); Cloner.CopyAllTo(typeof(ShippersInfo), dbItem, typeof(ModelNotifiedForShippers), itemToAdd); itemToAdd.ItemChanged = false; itemToAdd.NewItem = false; notifiedItems.Add(itemToAdd); } return(notifiedItems); } catch (Exception ex) { error = ex.Message; } return(null); }
public void DeleteData(ModelNotifiedForShippers modelNotifiedForShippers, out string error) { ShippersGenericREST ShippersGenericREST = new ShippersGenericREST(wpfConfig); DeleteShippersView deleteShippersView = new DeleteShippersView(); Cloner.CopyAllTo(typeof(ModelNotifiedForShippers), modelNotifiedForShippers, typeof(DeleteShippersView), deleteShippersView); ShippersGenericREST.Delete(deleteShippersView, out error); }
public void AddData(ModelNotifiedForShippers modelNotifiedForShippers, out string error) { ShippersGenericREST ShippersGenericREST = new ShippersGenericREST(wpfConfig); CreateShippersView createShippersView = new CreateShippersView(); Cloner.CopyAllTo(typeof(ModelNotifiedForShippers), modelNotifiedForShippers, typeof(CreateShippersView), createShippersView); ShippersGenericREST.Insert(createShippersView, out error); }
public void SaveData(ModelNotifiedForShippers modelNotifiedForShippers, out string error) { ShippersGenericREST ShippersGenericREST = new ShippersGenericREST(wpfConfig); UpdateShippersView updateShippersView = new UpdateShippersView(); Cloner.CopyAllTo(typeof(ModelNotifiedForShippers), modelNotifiedForShippers, typeof(UpdateShippersView), updateShippersView); ShippersGenericREST.Update(updateShippersView, out error); }
public void DeleteData(ModelNotifiedForShippers modelNotifiedForShippers, out string error) { ShippersBsn bsn = new ShippersBsn(wpfConfig); ShippersInfo dbItem = new ShippersInfo(); Cloner.CopyAllTo(typeof(ModelNotifiedForShippers), modelNotifiedForShippers, typeof(ShippersInfo), dbItem); bsn.DeleteByID(dbItem, out error); }
public void AddData(ModelNotifiedForShippers modelNotifiedForShippers, out string error) { ShippersBsn bsn = new ShippersBsn(wpfConfig); ShippersInfo dbItem = new ShippersInfo(); Cloner.CopyAllTo(typeof(ModelNotifiedForShippers), modelNotifiedForShippers, typeof(ShippersInfo), dbItem); bsn.InsertOne(dbItem, out error); modelNotifiedForShippers.NewItem = false; Cloner.CopyAllTo(typeof(ShippersInfo), dbItem, typeof(ModelNotifiedForShippers), modelNotifiedForShippers); }
/// <summary> /// Triggered by change in grid's row. /// </summary> private void OnSelectionChanged(object sender, SelectionChangedEventArgs e) { if ((DataGridShippers.SelectedItem == null) || DataGridShippers.SelectedItem.GetType() != typeof(ModelNotifiedForShippers)) { //New row on grid's bottom. By default do nothing when new row is included return; } ModelNotifiedForShippers selectedItem = (ModelNotifiedForShippers)DataGridShippers.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(ModelNotifiedForShippers selectedItem) { if (selectedItem == null) { return; } if (DetailListOrders != null) { DetailListOrders.LoadGrid(x => x.ShipVia == selectedItem.ShipperID); } /* Note: the detail form can load only ONE row from 'Orders'. It's necessary to inform DetailForm primary key here or create a custom Form.Load(). * if (DetailForm{0} != null) * { * //DetailFormOrders.LoadForm(selectedItem.ShipperID); * } */ }
private void OpenFormClick(object sender, RoutedEventArgs e) { ModelNotifiedForShippers itemSelected = (ModelNotifiedForShippers)DataGridShippers.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.Shippers.FormWPFShippers page = new MyApp.WPFForms.Shippers.FormWPFShippers(config); page.LoadForm(itemSelected.ShipperID); page.Setup_SetLanguage(CurrentLanguage); ContainerWindowSimple win = new ContainerWindowSimple(page, "Form Shippers"); win.Show(); }
private void SaveClick(object sender, RoutedEventArgs e) { ModelNotifiedForShippers itemSelected = (ModelNotifiedForShippers)DataGridShippers.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(ShippersDataContext.WPFMessageAndLabelForList.MessageBoxSaveOK); } else { //MessageBox.Show(MessageBoxSaveError + error); MessageBox.Show(ShippersDataContext.WPFMessageAndLabelForList.MessageBoxSaveError + error); } }