private async void LoadData()
        {
            List <ActivityDTONotify> DataList = new List <ActivityDTONotify>();

            try
            {
                IEnumerable <GeneralActivityDTO> activities = await SAGSignalR.GetActivitesByAtomName(VMMainViewModel.Instance.SimulationHubProxy, AtomCommonProperty.AtomName);

                if (activities != null)
                {
                    foreach (GeneralActivityDTO activity in activities)
                    {
                        ActivityDTONotify Rdata = new ActivityDTONotify();
                        Rdata.ActivityDTO = activity;
                        DataList.Add(Rdata);
                    }
                }


                dtGridActivities.ItemsSource = null;
                dtGridActivities.ItemsSource = DataList;

                if (dtGridActivities.ItemsSource == null)
                {
                    dtGridActivities.ItemsSource = new List <ActivityDTONotify>();
                }
            }
            catch (Exception ex)
            {
            }
        }
        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            int i = dtGridActivities.SelectedIndex;

            if (i < 0)
            {
                return;
            }
            ActivityDTONotify currActivityData = (ActivityDTONotify)dtGridActivities.Items[i];
            frmActivityEdit   frm = new frmActivityEdit(AtomCommonProperty, currActivityData.ActivityDTO);

            frm.ActivityDTOEditEvent += frm_ActivityDTOEditEvent;

            frm.Owner = Application.Current.MainWindow;
            frm.Show();
        }
        async void  frm_ActivityDTOEditEvent(object sender, ActivityDTOEditEventArgs args)
        {
            if (args.isNew)
            {
                int n = ((List <ActivityDTONotify>)(dtGridActivities.ItemsSource)).Count + 1;
                args.ActivityDTO.Activity_SeqNumber = n;

                GeneralActivityDTO activity = await SAGSignalR.SaveActivity(VMMainViewModel.Instance.SimulationHubProxy, args.ActivityDTO);

                ActivityDTONotify Rdata = new ActivityDTONotify();
                Rdata.ActivityDTO = activity;

                ((List <ActivityDTONotify>)(dtGridActivities.ItemsSource)).Add(Rdata);

                dtGridActivities.Items.Refresh();
                dtGridActivities.SelectedItem = Rdata;
                dtGridActivities.CurrentItem  = Rdata;
                DataGridWPFUtility.DataGridGotoLast(dtGridActivities);
            }
            else
            {
                GeneralActivityDTO activity = await SAGSignalR.SaveActivity(VMMainViewModel.Instance.SimulationHubProxy, args.ActivityDTO);

                if (dtGridActivities.ItemsSource == null)
                {
                    return;
                }

                List <ActivityDTONotify> listData = (List <ActivityDTONotify>)(dtGridActivities.ItemsSource);

                //  RouteData currRouteData = null;
                for (int j = 0; j < listData.Count; j++)
                {
                    if (listData[j].ActivityId == activity.ActivityId)
                    {
                        // currRouteData = listData[j];
                        listData[j].ActivityDTO = activity;
                        dtGridActivities.Items.Refresh();
                        break;
                    }
                }
            }
        }
        private async void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            int i = dtGridActivities.SelectedIndex;

            if (i < 0)
            {
                return;
            }
            MessageBoxResult res = MessageBox.Show(Properties.Resources.strAreyousureyouwanttodeleteit, String.Empty, MessageBoxButton.YesNo);

            if (res == MessageBoxResult.No)
            {
                return;
            }
            ActivityDTONotify currActivityData = (ActivityDTONotify)dtGridActivities.Items[i];

            await TDSClient.SAGInterface.SAGSignalR.DeleteActivityById(VMMainViewModel.Instance.SimulationHubProxy, currActivityData.ActivityId);

            ((List <ActivityDTONotify>)(dtGridActivities.ItemsSource)).Remove(currActivityData);
            dtGridActivities.Items.Refresh();
            dtGridActivities.Items.MoveCurrentToNext();
        }
Exemple #5
0
        private async void LoadData()
        {
            List<ActivityDTONotify> DataList = new List<ActivityDTONotify>();
           
            try
            {
                IEnumerable<GeneralActivityDTO> activities = await SAGSignalR.GetActivitesByAtomName(VMMainViewModel.Instance.SimulationHubProxy, AtomCommonProperty.AtomName);
                if (activities!=null)
                {
                    foreach (GeneralActivityDTO activity in activities)
                    {
                        ActivityDTONotify Rdata = new ActivityDTONotify();
                        Rdata.ActivityDTO = activity;
                        DataList.Add(Rdata);
                    }
                }
              

                dtGridActivities.ItemsSource = null;
                dtGridActivities.ItemsSource = DataList;

                if (dtGridActivities.ItemsSource == null)
                {
                    dtGridActivities.ItemsSource = new List<ActivityDTONotify>();
                }
            }
            catch (Exception ex)
            {

            }

        }
Exemple #6
0
        async  void  frm_ActivityDTOEditEvent(object sender, ActivityDTOEditEventArgs args)
        {

            

             if (args.isNew)
             {
                 int n = ((List<ActivityDTONotify>)(dtGridActivities.ItemsSource)).Count + 1;
                 args.ActivityDTO.Activity_SeqNumber = n;

                 GeneralActivityDTO activity = await SAGSignalR.SaveActivity(VMMainViewModel.Instance.SimulationHubProxy, args.ActivityDTO);

                 ActivityDTONotify Rdata = new ActivityDTONotify();
                 Rdata.ActivityDTO = activity;                
                 
                 ((List<ActivityDTONotify>)(dtGridActivities.ItemsSource)).Add(Rdata);

                 dtGridActivities.Items.Refresh();
                 dtGridActivities.SelectedItem = Rdata;
                 dtGridActivities.CurrentItem = Rdata;
                 DataGridWPFUtility.DataGridGotoLast(dtGridActivities);
             }
             else
             {
                 GeneralActivityDTO activity = await SAGSignalR.SaveActivity(VMMainViewModel.Instance.SimulationHubProxy, args.ActivityDTO);

                 if (dtGridActivities.ItemsSource == null) return;

                 List<ActivityDTONotify> listData = (List<ActivityDTONotify>)(dtGridActivities.ItemsSource);

               //  RouteData currRouteData = null;
                 for (int j = 0; j < listData.Count; j++)
                 {
                     if (listData[j].ActivityId == activity.ActivityId)
                     {
                        // currRouteData = listData[j];
                         listData[j].ActivityDTO = activity;
                         dtGridActivities.Items.Refresh();
                         break;
                     }
                 }

             }

            

        }