Пример #1
0
 public Поселение(HotelRooms R, List <HotelRooms> h) : this()
 {
     HR       = h;
     Building = R.Building;
     Floor    = R.Floor;
     Room     = R.Room;
     InitializeComponent();
     label2.Text             = $"{R.HumanReadableRoom}";
     label5.Text             = DateTime.Now.ToString("dd MMM yyyy HH:mm");
     dateTimePicker2.MinDate = DateTime.Today;
     if (DateTime.Today == dateTimePicker2.Value.Date)
     {
         dateTimePicker2.Value = DateTime.Today.AddHours(DateTime.Now.Hour + 1).AddMinutes(00);
     }
     else
     {
         dateTimePicker2.Value = DateTime.Today.AddHours(12).AddMinutes(00);
     }
     if (M1Enc.InitializeUSB(1) != 0)
     {
         //MessageBox.Show("Проблемы с авторизатором");
         button1.Enabled = false;
         return;
     }
     if (Convert.ToBoolean(Program.Config["Depo"] ?? false))
     {
         textBox2.Visible = Convert.ToBoolean(Program.Config["Depo"] ?? false);
     }
 }
Пример #2
0
        private List <HotelRooms> LoadRoomState()
        {
            List <HotelRooms> HR = new List <HotelRooms>();

            using (LockDbDataContext Db = new LockDbDataContext(Convert.ToString(Program.Config["ConnectionString"])))
            {
                //HR.Clear();
                var _S = Db.Rooms.OrderBy(x => x.HumanRoomNumber).GroupBy(x => x.Floor.Value);
                if (_S.Count() > 0)
                {
                    Point StartPoint = new Point(Convert.ToInt32(Program.Config["StartX"] ?? 70), Convert.ToInt32(Program.Config["StartY"] ?? 50));
                    //Point StartPoint = new Point(70, 50);
                    HotelRooms Room = new HotelRooms();
                    foreach (var L in _S)
                    {
                        foreach (var N in L)
                        {
                            Rectangle    R  = new Rectangle(StartPoint, new Size(Convert.ToInt32(Program.Config["SizeX"] ?? 50), Convert.ToInt32(Program.Config["SizeY"] ?? 50)));
                            GraphicsPath GP = new GraphicsPath();
                            GP.AddRectangle(R);
                            P.Add(GP);
                            DateTime Checkout;
                            if (N.Cards.Count() > 0)
                            {
                                Checkout = N.Cards.Max(x => x.Co.Value);
                            }
                            //Checkout = N.Cards.First().Co.Value;
                            else
                            {
                                Checkout = DateTime.MaxValue;
                            }

                            Room = new HotelRooms
                            {
                                HumanReadableRoom = N.HumanRoomNumber,
                                Room     = N.Room.Value,
                                Building = N.Building.Value,
                                Floor    = N.Floor.Value,
                                GP       = GP,
                                State    = (RoomStates)N.State.Value,
                                Co       = Checkout//N.Cards.First().Ci.Value
                            };
                            HR.Add(Room);
                            StartPoint = NewPosition(StartPoint);
                        }
                        StartPoint = NewLine(StartPoint);
                    }
                }
            }
            return(HR);
        }
Пример #3
0
        private void Panel1_MouseClick(object sender, MouseEventArgs e)
        {
            Point    Click = new Point(e.X, e.Y);
            MenuItem P1    = new MenuItem("Записать карту");

            P1.Click += P1_Click;
            MenuItem P2 = new MenuItem("Выселить");

            P2.Click += P2_Click;
            MenuItem P3 = new MenuItem("Блокировать утерянную карту");

            P3.Click += P3_Click;
            ContextMenu CM = new ContextMenu(new MenuItem[] { P1, P2, P3 });
            // опредление шейпа в который кликнули
            List <HotelRooms> HR = LoadRoomState();

            foreach (HotelRooms GP in HR)
            {
                if (GP.GP.IsVisible(new PointF(e.X, e.Y)))
                {
                    _GP = GP;
                    if (e.Button == MouseButtons.Right)
                    {
                        CM.Show(panel1, Click);
                    }
                    else
                    {
                        //MessageBox.Show($"{GP.HumanReadableRoom} {GP.Building:00}{GP.Flour:00}{GP.Room:00}");
                        if (GP.State == RoomStates.Vacant)
                        {
                            (new Поселение(GP, HR)
                            {
                                StartPosition = FormStartPosition.CenterScreen
                            }).Show();
                        }
                        if (GP.State == RoomStates.Busy)
                        {
                            (new Выселение(HR, GP)
                            {
                                StartPosition = FormStartPosition.CenterScreen
                            }).Show();
                        }
                    }
                }
            }
        }
Пример #4
0
        private void Timer1_Tick(object sender, EventArgs e)
        {
            byte[] cardbuf = new byte[250];
            byte[] lockno  = new byte[8];
            string R;

            if (M1Enc.InitializeUSB(1) != 0)
            {
                timer1.Stop();
                //MessageBox.Show("Проблемы с авторизатором");
                button1.Enabled = false;
                return;
            }
            if (M1Enc.ReadCard(1, cardbuf) != 0)
            {
                MessageBox.Show("Ошибка чтения");
            }
            else
            {
                string Signature = Encoding.ASCII.GetString(cardbuf);
                if (Signature.Length > 6)
                {
                    if (Signature.Substring(0, 6) == "551501")
                    {
                        Card = Encoding.ASCII.GetString(cardbuf).Substring(24, 8);
                        if (Card != "FFFFFFFF")
                        {
                            timer1.Stop();
                            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));
                                label2.Text = Find(R);
                            }
                            if (current == null)
                            {
                                current = HR.Find(x => x.Building == Building && x.Floor == Floor && x.Room == Room);
                            }
                        }
                    }
                }
            }
        }
Пример #5
0
 public Выселение(List <HotelRooms> h, HotelRooms c) : this()
 {
     label6.Visible = false;
     HR             = h;
     if (c != null)
     {
         current     = c;
         label2.Text = c.HumanReadableRoom;
         label5.Text = $"{DateTime.Now:dd MMM yyyy HH:mm}";
     }
     else
     {
         MessageBox.Show("Карта не от номера");
         button1.Enabled = false;
     }
     if (M1Enc.InitializeUSB(1) != 0)
     {
         timer1.Stop();
         //MessageBox.Show("Проблемы с авторизатором");
         button1.Enabled = false;
     }
 }
Пример #6
0
        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();
        }