示例#1
0
文件: ColorVM.cs 项目: rsalit/CSBC
 public static void Insert(Color entity)
 {
     using (var db = new CSBCDbContext())
     {
         var rep = new ColorRepository(db);
         rep.Insert(entity);
         db.SaveChanges();
     }
 }
示例#2
0
文件: TestInit.cs 项目: rsalit/CSBC
 public void InitColors(CSBCDbContext context)
 {
     var rep = new ColorRepository(context);
     for (int i = 0; i < ColorNames.Count; i++)
     {
         rep.Insert(new Color { ColorName = ColorNames[i], CompanyID = 1 });
     }
     rep.Insert(new Color { ColorName = "Chartreuse", CompanyID = 1, Discontinued = true });
     context.SaveChanges();
 }
示例#3
0
        private void UpdateRegularSeasonGame(int scheduleNo, int gameNo)
        {
            var vm = new ScheduleGamesVM();
            var game = vm.GetByScheduleAndGameNo(scheduleNo, gameNo);

            try
            {
                game.GameDate = (DateTime)ConcatDateTime(mskDate.Text, txtTime.Text);
                game.GameTime = txtTime.Text;
                game.LocationNumber = Convert.ToInt32(cmbVenues.SelectedItem.Value);
                game.HomeTeamNumber = (int)ScheduleGamesVM.GetScheduleTeamNumberFromTeamNumber(scheduleNo, Convert.ToInt32(txtHome.Text));
                game.VisitingTeamNumber = (int)ScheduleGamesVM.GetScheduleTeamNumberFromTeamNumber(scheduleNo, Convert.ToInt32(txtVisitor.Text));
                if (game.VisitingTeamScore == null)
                    game.VisitingTeamScore = -1;
                else
                    game.VisitingTeamScore = game.VisitingTeamScore;
                if (game.HomeTeamScore == null)
                    game.HomeTeamScore = -1;
                else
                    game.HomeTeamScore = game.HomeTeamScore;
                game.DivisionId = Int32.Parse(ddlDivisions.SelectedValue);
                game.SeasonId = Master.SeasonId;

                using (var db = new CSBCDbContext())
                {
                    new ScheduleGameRepository(db).Update(game);
                    db.SaveChanges();
                }
            }
            catch (Exception e)
            {
                lblError.Text = "Update Regular Season Game:" + e.Message;
            }
        }
示例#4
0
        private void UpdatePlayoffGame(int scheduleNo, int gameNo)
        {
            try
            {
                if (gameNo > 0)
                {
                    var vm = new ScheduleGamesVM();
                    var game = vm.GetPlayoffByScheduleAndGameNo(scheduleNo, gameNo);
                    if (game != null)
                    {
                        game.GameDate = ConcatDateTime(mskDate.Text, txtTime.Text);
                        game.GameTime = txtTime.Text;
                        game.LocationNumber = Convert.ToInt32(cmbVenues.SelectedItem.Value);
                        game.HomeTeam = txtHome.Text;
                        game.VisitingTeam = txtVisitor.Text;
                        game.Descr = txtDescr.Text;
                        game.DivisionId = Convert.ToInt32(ddlDivisions.SelectedValue);

                        using (var db = new CSBCDbContext())
                        {
                            var rep = new SchedulePlayoffRepository(db);
                            rep.Update(game);
                            db.SaveChanges();
                        }
                    }
                }
                else
                {
                    var date = ConcatDateTime(mskDate.Text, txtTime.Text);

                    ScheduleGamesVM.AddPlayoffGame(scheduleNo, date, txtTime.Text,
                        Convert.ToInt32(cmbVenues.SelectedItem.Value), txtHome.Text, txtVisitor.Text, txtDescr.Text,Convert.ToInt32(cmbDivisions.SelectedValue));
                }

            }
            catch (Exception e)
            {
                lblError.Text = "Update Regular Season Game:" + e.Message;
            }
        }
示例#5
0
 private void AddRegularSeasonGame(int scheduleNo)
 {
     using (var db = new CSBCDbContext())
     {
         var rep = new ScheduleGameRepository(db);
         var game = new ScheduleGame();
         try
         {
             game.ScheduleNumber = scheduleNo;
             game.GameDate = (DateTime)ConcatDateTime(mskDate.Text, txtTime.Text);
             game.GameTime = txtTime.Text;
             game.HomeTeamNumber = ScheduleGamesVM.GetScheduleTeamNumberFromTeamNumber(ScheduleNo, Convert.ToInt32(txtHome.Text));
             game.VisitingTeamNumber = ScheduleGamesVM.GetScheduleTeamNumberFromTeamNumber(ScheduleNo, Convert.ToInt32(txtVisitor.Text));
             game.LocationNumber = Convert.ToInt32(cmbVenues.SelectedItem.Value);
             if (game.VisitingTeamScore == null)
                 game.VisitingTeamScore = -1;
             else
                 game.VisitingTeamScore = game.VisitingTeamScore;
             if (game.HomeTeamScore == null)
                 game.HomeTeamScore = -1;
             else
                 game.HomeTeamScore = game.HomeTeamScore;
             game.DivisionId = Int32.Parse(ddlDivisions.SelectedValue);
             game.SeasonId = Master.SeasonId;
             //_with1.Descr = txtDescr.Text;
             var newGame = rep.Insert(game);
             db.SaveChanges(); //this should be in UOM!
             GameNo = newGame.GameNumber;
         }
         catch (Exception ex)
         {
             Session["ErrorMSG"] = "ADDRow::" + ex.Message;
         }
     }
 }
示例#6
0
 private void AddPlayoffGame(int scheduleNo)
 {
     using (var db = new CSBCDbContext())
     {
         var rep = new SchedulePlayoffRepository(db);
         var game = new SchedulePlayoff();
         try
         {
             game.ScheduleNumber = scheduleNo;
             game.GameDate = (DateTime)ConcatDateTime(mskDate.Text, txtTime.Text);
             game.GameTime = txtTime.Text;
             game.HomeTeam = txtHome.Text;
             game.VisitingTeam = txtVisitor.Text;
             game.LocationNumber = Convert.ToInt32(cmbVenues.SelectedItem.Value);
             game.Descr = txtDescr.Text;
             game.DivisionId = Convert.ToInt32(ddlDivisions.SelectedValue);
             var newGame = rep.Insert(game);
             db.SaveChanges(); //this should be in UOM!
             GameNo = newGame.GameNumber;
         }
         catch (Exception ex)
         {
             Session["ErrorMSG"] = "ADDRow::" + ex.Message;
         }
     }
 }
示例#7
0
 internal static void AddPlayoffGame(int scheduleNo, DateTime? date, string gameTime, int locationNumber,
     string homeTeam, string visitorTeam, string description, int divisionId)
 {
     using (var db = new CSBCDbContext())
     {
         var rep = new SchedulePlayoffRepository(db);
         var game = new SchedulePlayoff
         {
             ScheduleNumber = scheduleNo,
             GameDate = date,
             GameTime = gameTime,
             LocationNumber = locationNumber,
             HomeTeam = homeTeam,
             VisitingTeam = visitorTeam,
             Descr = description,
             DivisionId = divisionId
         };
         rep.Insert(game);
         db.SaveChanges();
     }
 }