public Пополнение_депозита(string C) : this() { Card = C; if (Convert.ToBoolean(Program.Config["Depo"] ?? false)) { // прверяем существование счета пользователя string address = Convert.ToString(Program.Config["DepoServerAddress"]); IDepo c = (new Depo.Depo()).Connect(address); if (c.Holder(Card, out string Holder) == Results.Succsess) { textBox2.Text = Holder; textBox2.Enabled = false; } } }
private void Info_Load(object sender, EventArgs e) { label5.Visible = Convert.ToBoolean(Program.Config["Depo"] ?? false); byte[] lockno = new byte[8]; string R; byte[] Edate = new byte[10]; byte[] cardtype = new byte[16]; if (M1Enc.GetGuestLockNoByCardDataStr(Program.HotelId, cardbuf, lockno) == 0) { R = Encoding.ASCII.GetString(lockno).Substring(0, 6); Building = int.Parse(R.Substring(0, 2)); Floor = int.Parse(R.Substring(2, 2)); Room = int.Parse(R.Substring(4, 2)); _GP = Find(R); string r = (_GP == null) ? string.Empty : _GP.HumanReadableRoom; label2.Text = r; } if (M1Enc.GetCardTypeByCardDataStr(cardbuf, cardtype) == 0) { label3.Text = M1Enc.Card_type(cardtype[0]); } if (M1Enc.GetGuestETimeByCardDataStr(Program.HotelId, cardbuf, Edate) == 0) { label7.Text = GetTime(Encoding.ASCII.GetString(Edate)).ToString(); } using (LockDbDataContext Db = new LockDbDataContext(Convert.ToString(Program.Config["ConnectionString"]))) { DateTime Now = DateTime.Now; var H = Db.Rooms.Where(x => x.Building == Building && x.Floor == Floor && x.Room == Room).OrderByDescending(x => x.Id); string h = string.Empty; if (H.Count() > 0) { var H1 = Db.Cards.Where(x => x.Ci.Value <= Now && Now <= x.Co.Value && x.RoomId == H.First().Id); foreach (var h1 in H1) { dataGridView1.Rows.Add(new object[] { h1.Id, h1.Holder, h1.Card, h1.Ci.Value, h1.Co.Value }); if (h1.Card.Trim().ToUpper() == Card.Trim().ToUpper()) { if (dataGridView1.Rows.Count > 0) { dataGridView1.Rows[0].Selected = false; } if (dataGridView1.Rows.Count > 0) { dataGridView1.Rows[dataGridView1.Rows.Count - 1].Selected = true; } } } } } if (Convert.ToBoolean(Program.Config["Depo"] ?? false)) { try { label5.Visible = false; label8.Text = string.Empty; IDepo c = (new Depo.Depo()).Connect(Convert.ToString(Program.Config["DepoServerAddress"])); if (c.Holder(Card, out string Holder) == Results.Succsess) { CiCol.Visible = false; CoCol.Visible = false; dataGridView1.Rows.Add(new object[] { 0, Holder, Card }); } if (c.CheckAmount(Card, out decimal Amount) == Results.Succsess) { label5.Visible = (Amount > 0); label8.Text = $"{Amount:C2}"; } } catch (Exception err) { MessageBox.Show($"{err.Message}"); } } timer2.Start(); }