private void Button1_Click(object sender, EventArgs e) { // проверяем депозит if (Convert.ToBoolean(Program.Config["Depo"] ?? false)) { IDepo c = (new Depo.Depo()).Connect(Convert.ToString(Program.Config["DepoServerAddress"])); if (c.CheckAmount(Card, out decimal Amount) == Results.Succsess) { if (Amount > 0) { MessageBox.Show("На карте есть активный депозит. Выселение не возможно"); return; } } } byte[] cardbuf = new byte[250]; using (LockDbDataContext Db = new LockDbDataContext(Convert.ToString(Program.Config["ConnectionString"]))) { DateTime Now = DateTime.Now; 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.Rooms.Room.Value == current.Room && x.Co.Value > Now); int count = _C.Count(); if (count > 0) { foreach (var c in _C) { Form f = new Form() { StartPosition = FormStartPosition.CenterScreen, AutoSize = true, AutoSizeMode = AutoSizeMode.GrowAndShrink, ShowIcon = false, ShowInTaskbar = false, ControlBox = false, Text = $"Положите карту {count--} от номера в авторизатор" }; //f.Controls.Add(new Label //{ // Font = new Font(DefaultFont.FontFamily, 12), // TextAlign = ContentAlignment.MiddleCenter, // Text = $"Положите карту {count--} от номера в авторизатор" //}); f.Controls.Add(new Button { DialogResult = DialogResult.OK, Font = new Font(DefaultFont.FontFamily, 12), AutoSize = true, Text = $"Записать карту от номера" }); Hide(); if (f.ShowDialog() == DialogResult.OK) { if (Program.IshueCard(Now) == 0) //{ } //Стереть_карту f = new Стереть_карту() { StartPosition = FormStartPosition.CenterScreen, Tag = c.Card.Trim() }; //if (f.ShowDialog() == DialogResult.OK) { c.Co = DateTime.Now; f.Close(); //Db.Cards.DeleteOnSubmit(c); } } } } var r = Db.Rooms.Where(x => x.Building == Building && x.Floor == Floor && x.Room == 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.First().State = (int)RoomStates.Vacant; } } Db.SubmitChanges(); } Close(); }
partial void UpdateRooms(Rooms instance);
partial void DeleteRooms(Rooms instance);
partial void InsertRooms(Rooms instance);