private DBAccessor() { //var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); //SafeCreateDirectory(documents + @"\HardwareLedger\Database\"); //Directory = documents + @"\HardwareLedger\Database\{0}.json"; Directory = @"Database\{0}.json"; //SafeCreateDirectory(documents + @"\HardwareLedger\Database\"); SafeCreateDirectory(@"Database\"); data = new Dictionary <Type, List <IPgmRow> >(); Reserves = ReadJson <Reserve, DBObject.Reserve>(); ShopTypes = ReadJson <ShopType, DBObject.ShopType>(); ItemTypes = ReadJson <ItemType, DBObject.ItemType>(); ItemStates = ReadJson <ItemState, DBObject.ItemState>(); Malfunctions = ReadJson <Malfunction, DBObject.Malfunction>(); Relations = ReadJson <Relation, DBObject.Relation>(); CollectSchedules = ReadJson <CollectSchedule, DBObject.CollectSchedule>(); ReserveShippings = ReadJson <ReserveShipping, DBObject.ReserveShipping>(); data.Add(typeof(Reserve), Reserves.Cast <IPgmRow>().ToList()); data.Add(typeof(ShopType), ShopTypes.Cast <IPgmRow>().ToList()); data.Add(typeof(ItemType), ItemTypes.Cast <IPgmRow>().ToList()); data.Add(typeof(ItemState), ItemStates.Cast <IPgmRow>().ToList()); data.Add(typeof(Malfunction), Malfunctions.Cast <IPgmRow>().ToList()); data.Add(typeof(Relation), Relations.Cast <IPgmRow>().ToList()); data.Add(typeof(CollectSchedule), CollectSchedules.Cast <IPgmRow>().ToList()); data.Add(typeof(ReserveShipping), ReserveShippings.Cast <IPgmRow>().ToList()); }
public SoccerLineupDetailsViewModel(Team team, IChangeManager changeManager, CollectionFactory collections) { _changeManager = changeManager; _teamModel = team; Collections = collections; Team = new TeamViewModel(team, _changeManager, Collections); SoccerPlayerViewModel.IsSelectedPropertyChanged += SoccerPlayerViewModel_IsSelectedPropertyChanged; Substitutions = Team.Squad.Where(p => (RotationTeam)p.RotationTeam.Value == RotationTeam.Substitute).ToSquadList(); if (Substitutions.Count < 7) { Substitutions.Add(new SoccerPlayerViewModel() { Name = new EditableCellViewModel(string.Empty, _changeManager), Position = new ComboBoxCellViewModel(null, null, _changeManager) }); } Substitutions.RemoveFirstNames(); Substitutions.ArrangePositionRoleAsec(); Reserves = Team.Squad.Where(p => (RotationTeam)p.RotationTeam.Value == RotationTeam.Reserves).ToSquadList(); Reserves.RemoveFirstNames(); Reserves.ArrangePositionRoleAsec(); DragDropPlayer = new RelayCommand <SoccerPlayerViewModel>(DragOrDropFieldPlayer); }
public ActionResult CreateReserve(Reserves reserve) { string message = ""; ReservationService.AddReserve(reserve, out message); ReservationService.Notify(); return(RedirectToAction("Index", new { message = message })); }
public ActionResult DeleteConfirmed(int id) { Reserves reserves = db.Reserves.Find(id); db.Reserves.Remove(reserves); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Reserve_ID,Date,Start_Time,End_Time,Room_ID,Event_ID")] Reserves reserves) { if (ModelState.IsValid) { db.Entry(reserves).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Room_ID = new SelectList(db.Rooms, "Room_ID", "Building_Name", reserves.Room_ID); ViewBag.Event_ID = new SelectList(db.Events, "Event_ID", "Event_name", reserves.Event_ID); return(View(reserves)); }
// GET: Reserves/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Reserves reserves = db.Reserves.Find(id); if (reserves == null) { return(HttpNotFound()); } return(View(reserves)); }
private void btnDelete_Click_1(object sender, EventArgs e) { DialogResult r = MessageBox.Show("Eminsiniz mi?", "Silme", MessageBoxButtons.OKCancel); if (r == DialogResult.OK && ClickId != 0) { dgvReserves.Rows.Remove(dgvReserves.Rows[ClickedRowIndex]); Reserves rsv = db.Reserves.Find(ClickId); db.Reserves.Remove(rsv); db.SaveChanges(); btnNewOrder.Visible = true; btnDelete.Visible = false; btnCancel.Visible = false; } }
// GET: Reserves/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Reserves reserves = db.Reserves.Find(id); if (reserves == null) { return(HttpNotFound()); } ViewBag.Room_ID = new SelectList(db.Rooms, "Room_ID", "Building_Name", reserves.Room_ID); ViewBag.Event_ID = new SelectList(db.Events, "Event_ID", "Event_name", reserves.Event_ID); return(View(reserves)); }
public static bool AddReserve(Reserves reserve, out string message) { try { reserve.ReserveDate = DateTime.Now; db.Reserves.Add(reserve); db.SaveChanges(); message = "Reserve was added successfully"; return(true); } catch (Exception ex) { message = ex.Message; return(false); } }
private void btnAddMatch_Click_1(object sender, EventArgs e) { Reserves rsv = new Reserves(); DateTime day = dtpDate.Value.Date; int staId = FindStadiumIdByName(cmbStadium.Text); DateTime dateNow = DateTime.Now.Date; List <Reserves> res = db.Reserves.Where(r => r.Date == day && r.SatdiumId == staId).ToList(); //Kechmish vaxda sifarish etmeyi engellmek ucun if (dtpDate.Value < dateNow) { MessageBox.Show("Gunu duzgun girin"); return; } foreach (Reserves item in res) { if ((item.StartTime.Value.Hours <= dtpStarttime.Value.Hour && item.EndTime.Value.Hours > dtpStarttime.Value.Hour) || (item.StartTime.Value.Hours < dtpEndtime.Value.Hour && item.EndTime.Value.Hours >= dtpEndtime.Value.Hour) || (item.StartTime.Value.Hours >= dtpStarttime.Value.Hour && item.StartTime.Value.Hours < dtpEndtime.Value.Hour) || (item.EndTime.Value.Hours > dtpStarttime.Value.Hour && item.EndTime.Value.Hours <= dtpEndtime.Value.Hour)) { MessageBox.Show("Bu saatda bos deyil"); return; } } if (cmbStadium.Text != string.Empty && cmbCustomer.Text != "") { //if (dtpStarttime.Text != dtpEndtime.Text && dtpStarttime.Value < dtpEndtime.Value) //{ int x = 0; TimeSpan starttime = new TimeSpan(dtpStarttime.Value.Hour, 0, 0); TimeSpan endtime = new TimeSpan(dtpEndtime.Value.Hour, 0, 0); int diffTime = dtpEndtime.Value.Hour - dtpStarttime.Value.Hour; for (int i = 0; i < diffTime; i++) { x += 5; } rsv.Price = x; rsv.SatdiumId = FindStadiumIdByName(cmbStadium.Text); rsv.Date = dtpDate.Value; rsv.StartTime = starttime; rsv.EndTime = endtime; rsv.CustomerId = FindCustomerIdByName(cmbCustomer.Text); db.Reserves.Add(rsv); db.SaveChanges(); cmbStadium.Text = string.Empty; cmbCustomer.Text = string.Empty; } else { lblError2.Text = "boshluq buraxmayin"; lblError2.ForeColor = Color.PaleVioletRed; return; } lblError2.Text = ""; lblErrorTimespan.Text = ""; cmbStadium.Text = ""; }
public void Changed(ChangeArgs args) { #region Substitution if (args is SubstitutionArgs) { var subArgs = (SubstitutionArgs)args; var firstSub = subArgs.FirstSub; var secondSub = subArgs.SecondSub; switch (args.Type) { case ChangeType.SubSelected: if (_firstSubstitute == null) { _firstSubstitute = Team.Squad.Find(p => p.Id == firstSub.Id); } else if (firstSub.Id == _firstSubstitute.Id && secondSub == null) { return; } if (secondSub != null) { if (_secondSubstitute == null) { _secondSubstitute = Team.Squad.Find(p => p.Id == secondSub.Id); } else if (secondSub.Id == _secondSubstitute.Id) { return; } } break; case ChangeType.SubDeselect: if (firstSub != null) { _firstSubstitute = null; } else if (secondSub != null) { _secondSubstitute = null; } break; case ChangeType.SubConfirmed: _firstSubstitute.RotationTeam.Value = firstSub.Rotation; _secondSubstitute.RotationTeam.Value = secondSub.Rotation; var firstSubIndex = Substitutions.Contains(_firstSubstitute) ? Substitutions.IndexOf(_firstSubstitute) : Reserves.IndexOf(_firstSubstitute); var secondSubIndex = Substitutions.Contains(_secondSubstitute) ? Substitutions.IndexOf(_secondSubstitute) : Reserves.IndexOf(_secondSubstitute); var firstSubX = subArgs.secondSubX; var firstSubY = subArgs.secondSubY; var secondSubX = subArgs.firstSubX; var secondSubY = subArgs.firstSubY; // sub inside 'lineup details' if ((RotationTeam)_firstSubstitute.RotationTeam.Value != RotationTeam.Lineup && (RotationTeam)_secondSubstitute.RotationTeam.Value != RotationTeam.Lineup) { // sub inside same rotation team if ((RotationTeam)_firstSubstitute.RotationTeam.Value == (RotationTeam)_secondSubstitute.RotationTeam.Value) { if (Substitutions.Contains(_firstSubstitute)) { Substitutions.RemoveAt(firstSubIndex); Substitutions.Insert(firstSubIndex, _secondSubstitute); Substitutions.RemoveAt(secondSubIndex); Substitutions.Insert(secondSubIndex, _firstSubstitute); } else if (Reserves.Contains(_firstSubstitute)) { Reserves.RemoveAt(firstSubIndex); Reserves.Insert(firstSubIndex, _secondSubstitute); Reserves.RemoveAt(secondSubIndex); Reserves.Insert(secondSubIndex, _firstSubstitute); } } // sub between differant rotaion team else if ((RotationTeam)_firstSubstitute.RotationTeam.Value != (RotationTeam)_secondSubstitute.RotationTeam.Value) { if (Substitutions.Contains(_firstSubstitute)) { Substitutions.RemoveAt(firstSubIndex); Substitutions.Insert(firstSubIndex, _secondSubstitute); Reserves.RemoveAt(secondSubIndex); Reserves.Insert(secondSubIndex, _firstSubstitute); } else if (Reserves.Contains(_firstSubstitute)) { Reserves.RemoveAt(firstSubIndex); Reserves.Insert(firstSubIndex, _secondSubstitute); Substitutions.RemoveAt(secondSubIndex); Substitutions.Insert(secondSubIndex, _firstSubstitute); } } } // sub first sub from 'field details' to second sub in 'lineup details' else if ((RotationTeam)_firstSubstitute.RotationTeam.Value == RotationTeam.Lineup && (RotationTeam)_secondSubstitute.RotationTeam.Value != RotationTeam.Lineup) { if (Substitutions.Contains(_secondSubstitute)) { Substitutions.Remove(_secondSubstitute); _firstSubstitute.RotationTeam.Value = RotationTeam.Substitute; Substitutions.Insert(secondSubIndex, _firstSubstitute); } else if (Reserves.Contains(_secondSubstitute)) { Reserves.Remove(_secondSubstitute); _firstSubstitute.RotationTeam.Value = RotationTeam.Reserves; Reserves.Insert(secondSubIndex, _firstSubstitute); } _secondSubstitute.X = firstSubX; _secondSubstitute.Y = firstSubY; _firstSubstitute.X = secondSubX; _firstSubstitute.Y = secondSubY; } // sub first sub from 'lineup details' to second sub in 'field details' else if ((RotationTeam)_firstSubstitute.RotationTeam.Value != RotationTeam.Lineup && (RotationTeam)_secondSubstitute.RotationTeam.Value == RotationTeam.Lineup) { if (Substitutions.Contains(_firstSubstitute)) { Substitutions.Remove(_firstSubstitute); _secondSubstitute.RotationTeam.Value = RotationTeam.Substitute; Substitutions.Insert(firstSubIndex, _secondSubstitute); } else if (Reserves.Contains(_firstSubstitute)) { Reserves.Remove(_firstSubstitute); _secondSubstitute.RotationTeam.Value = RotationTeam.Reserves; Reserves.Insert(firstSubIndex, _secondSubstitute); } _firstSubstitute.X = secondSubX; _firstSubstitute.Y = secondSubY; _secondSubstitute.X = firstSubX; _secondSubstitute.Y = firstSubY; } Substitutions.RemoveFirstNames(); Substitutions.ArrangePositionRoleAsec(); Substitutions = new SquadList <SoccerPlayerViewModel>(Substitutions); Reserves.RemoveFirstNames(); Reserves.ArrangePositionRoleAsec(); Reserves = new SquadList <SoccerPlayerViewModel>(Reserves); // reset subs VM _firstSubstitute.SetIsSelectedBinding(false); _secondSubstitute.SetIsSelectedBinding(false); _firstSubstitute = null; _secondSubstitute = null; // Also: // recreate TeamDetails & PlayerDetails break; } } #endregion #region EditFormation if (args is EditFormationArgs) { var editArgs = (EditFormationArgs)args; Substitutions.ForEach(p => p.IsEnabled = !editArgs.IsEditMode); Reserves.ForEach(p => p.IsEnabled = !editArgs.IsEditMode); switch (editArgs.Type) { //case ChangeType.EditFormationModeEnabled: // break; case ChangeType.EditFormationModeDisabled: break; } } #endregion }