Esempio n. 1
0
        private void gridShuttleDestination_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
        {
            if (e.EditAction == GridViewEditAction.Cancel)
            {
                return;
            }
            if (e.EditOperationType == GridViewEditOperationType.Insert)
            {
                try
                {
                    db.SaveChanges();
                    binddatagrid();
                }
                catch { MessageBox.Show("Invalid"); }
            }
            else if (e.EditOperationType == GridViewEditOperationType.Edit)
            {
                try
                {
                    foreach (var data in gridShuttleDestination.SelectedItems)
                    {
                        t_ShuttleDestination myData = data as t_ShuttleDestination;
                        destid = myData.DestinationID;
                        destin = myData.Destination;

                        t_ShuttleDestination dest = db.t_ShuttleDestination.First(p => p.DestinationID == destid);
                        dest.Destination = destin;
                        db.SaveChanges();
                        binddatagrid();
                    }
                }
                catch { }
            }
        }
Esempio n. 2
0
        private void gridShuttleDestination_AddingNewDataItem(object sender, GridViewAddingNewEventArgs e)
        {
            var dest = new t_ShuttleDestination();

            dest.Destination = destin;
            e.NewObject      = dest;

            db.t_ShuttleDestination.Add(dest);
        }
Esempio n. 3
0
        private void gridShuttleDestination_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.Key == Key.Delete)
                {
                    string sMessageBoxText = "Do you want to continue?";
                    string sCaption        = "Delete Destination";

                    MessageBoxButton btnMessageBox = MessageBoxButton.YesNo;
                    MessageBoxImage  icnMessageBox = MessageBoxImage.Warning;

                    MessageBoxResult rsltMessageBox = MessageBox.Show(sMessageBoxText, sCaption, btnMessageBox, icnMessageBox);

                    switch (rsltMessageBox)
                    {
                    case MessageBoxResult.Yes:
                        foreach (var data in gridShuttleDestination.SelectedItems)
                        {
                            t_ShuttleDestination myData = data as t_ShuttleDestination;
                            var deletedest = db.t_ShuttleDestination.Where(dest => dest.DestinationID == myData.DestinationID).FirstOrDefault();
                            db.t_ShuttleDestination.Remove(deletedest);
                            db.SaveChanges();
                        }
                        break;

                    case MessageBoxResult.No:
                        /* ... */
                        break;
                    }
                }

                else
                {
                    return;
                }
            }
            catch { }
        }