예제 #1
0
        private void ByName(object sender, RoutedEventArgs e)
        {
            try
            {
                MotoGPDB4 objCourse = db.MotoGPDB4s.Single(course => course.TeamName == TeamsName.Text);
                //Puts an entity from this table into a pending delete state and parameter is the entity which to be deleted.

                db.MotoGPDB4s.DeleteOnSubmit(objCourse);
                try
                {
                    DialogResult dr = new DialogResult();
                    dr = MessageBox.Show("Clicking 'Yes' deletes " + objCourse.TeamName + " from the database." + Environment.NewLine + "This will remove this record from your database." + Environment.NewLine + "Have you confirmed all data to be correct?", "DataSync", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    if (dr == System.Windows.Forms.DialogResult.Yes)
                    {
                        db.SubmitChanges();
                    }



                    MaxNum.Text        = MaxWonCham();
                    MaxNumYear.Text    = MaxYear();
                    BeginningNum1.Text = MinYear();
                }
                catch (Exception)
                {
                    MessageBox.Show("Something is wrong.", "Error", 0);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Only existing teams can be deleted.", "Error", 0);
            }
        }
예제 #2
0
        //private void ChampContol(object sender, TextChangedEventArgs e)
        //{
        //    try
        //    {
        //        if (int.Parse(Won_Champs.Text)<0)
        //        { throw new Exception(); }
        //    }
        //    catch (Exception)
        //    {
        //        MessageBox.Show("Won Championshps must be greater than -1", "Error", 0);
        //    }
        //}

        private void Submitting_data(object sender, RoutedEventArgs e)
        {
            try
            {
                if (int.Parse(Won_Champs.Text) < 0)
                {
                    throw new Exception();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Won Championshps must be greater than -1", "Error", 0);
            }
            MotoGPDB4 dastab = new MotoGPDB4();

            if (db.DatabaseExists())
            {
                bool b = Paid.IsChecked == true;
                try
                {
                    MotoGPDB4 custQuery =
                        (from custs in db.MotoGPDB4s
                         orderby custs.Id descending
                         select custs)
                        .First();

                    dastab.Id          = custQuery.Id + 1;
                    dastab.TeamName    = TeamNameInput.Text;
                    dastab.YearOfFound = int.Parse(InputYear.Text);
                    dastab.WonChamps   = int.Parse(Won_Champs.Text);
                    dastab.Fee         = b;
                    db.MotoGPDB4s.InsertOnSubmit(dastab);
                    db.SubmitChanges();
                    TeamNameInput.Text = "";
                    InputYear.Text     = "";
                    Won_Champs.Text    = "";
                    Paid.IsChecked     = false;
                }

                catch (Exception)
                {
                    MessageBox.Show("Teamname cannot be empty", "Error", 0);
                }
            }
        }
예제 #3
0
        private void TeamNameSet(object sender, RoutedEventArgs e)
        {
            try
            {
                MotoGPDB4 objCourse = db.MotoGPDB4s.Single(course => course.TeamName == TeamsNameMod.Text);

                string name   = objCourse.TeamName;
                int    yearof = objCourse.YearOfFound;
                int    wonch  = objCourse.WonChamps;
                bool   a      = objCourse.Fee;
                db.MotoGPDB4s.DeleteOnSubmit(objCourse);
                try
                {
                    db.SubmitChanges();
                    MaxNum.Text        = MaxWonCham();
                    MaxNumYear.Text    = MaxYear();
                    BeginningNum1.Text = MinYear();
                }

                catch (Exception)
                {
                    MessageBox.Show("Something is wrong in submitting.", "Error", 0);
                }
                MotoGPDB4 datab    = new MotoGPDB4();
                int       maxPrice = db.MotoGPDB4s.Max(s => s.Id) + 1;
                datab.Id          = maxPrice;
                datab.TeamName    = TeamNameModTo.Text;
                datab.WonChamps   = wonch;
                datab.YearOfFound = yearof;
                datab.Fee         = a;
                try
                {
                    db.MotoGPDB4s.InsertOnSubmit(datab);
                    db.SubmitChanges();
                }
                catch
                {
                    MessageBox.Show("Something is wrong in the insertion.", "Error", 0);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Only existing teams can be deleted.", "Error", 0, MessageBoxIcon.Warning);
            }
        }
예제 #4
0
 partial void DeleteMotoGPDB4(MotoGPDB4 instance);
예제 #5
0
 partial void UpdateMotoGPDB4(MotoGPDB4 instance);
예제 #6
0
 partial void InsertMotoGPDB4(MotoGPDB4 instance);