private void P3_Click(object sender, EventArgs e) { DateTime Co = DateTime.MinValue; int Id = 0; using (LockDbDataContext Db = new LockDbDataContext(Convert.ToString(Program.Config["ConnectionString"]))) { Id = Db.Rooms.Where(x => x.Building.Value == _GP.Building && x.Floor.Value == _GP.Floor && x.Room.Value == _GP.Room).First().Id; Выбор_карты f = new Выбор_карты() { Tag = Id }; if (f.ShowDialog() == DialogResult.OK) { var _C = Db.Cards.Where(x => x.Id == Convert.ToInt32(f.Tag)); if (_C.Count() > 0) { LostForm lf = new LostForm() { Tag = _C.First().Card.Trim() }; if (lf.ShowDialog() == DialogResult.OK) { Card = _C.First().Card; Co = _C.First().Co.Value; Db.Cards.DeleteOnSubmit(_C.First()); Db.SubmitChanges(); } } } PregareNewDepo(_GP.Building, _GP.Floor, _GP.Room, Co); } }
private void CheckOutWithOutCard_Click(object sender, EventArgs e) { using (LockDbDataContext Db = new LockDbDataContext(Convert.ToString(Program.Config["ConnectionString"]))) { //int CardNo = 0; //Выбор_карты f = new Выбор_карты() { Tag = Db.Rooms.Where(x => x.Building.Value == current.Building && x.Floor.Value == current.Floor && x.Room.Value == current.Room).First().Id }; //if (f.ShowDialog() == DialogResult.OK) //{ //CardNo = Convert.ToInt32(f.Tag); DateTime Now = DateTime.Now; // пишем lost по количеству карт в номере var _C = Db.Cards.Where(x => x.Rooms.Building.Value == current.Building && x.Rooms.Floor.Value == current.Floor && x.Rooms.Room.Value == current.Room && x.Co.Value > Now); if (_C.Count() > 0) { int count = _C.Count(); foreach (var c in _C) { Hide(); LostForm lf = new LostForm() { Tag = c.Card, StartPosition = FormStartPosition.CenterScreen, ShowIcon = false, ShowInTaskbar = false, Text = $"Положите чистую карту в авторизатор" }; if (lf.ShowDialog() == DialogResult.OK) { count--; c.Co = DateTime.Now; //Db.Cards.DeleteOnSubmit(c); } } } //var r1 = HR.Where(x => x.Building == current.Building && x.Floor == current.Floor && x.Room == current.Room); //if (r1.Count() > 0) //{ // r1.First().State = RoomStates.Vacant; //} var _r = Db.Rooms.Where(x => x.Building.Value == current.Building && x.Floor.Value == current.Floor && x.Room.Value == current.Room && x.Cards.Where(y => y.Co.Value > Now).Count() > 0); if (_r.Count() > 0) { Rooms R = _r.First(); if (R.Cards.Count(x => x.Co.Value > DateTime.Now) <= 0) { R.State = (int)RoomStates.Vacant; } } Db.SubmitChanges(); } Close(); }