예제 #1
0
        public void Attend_Click(Button ab)
        {
            Program.TimerReset();
            var c = list[(int)ab.Tag];

            if (c.lastpress.HasValue && DateTime.Now.Subtract(c.lastpress.Value).TotalSeconds < 1)
            {
                return;
            }

            if (c.access == "restricted")
            {
                Program.attendant.AddHistoryString("-- " + DateTime.Now.ToString("MM-dd-yy hh:mm tt") + " Check-in rejected for " + c.name + " because they are not permitted to use the facility.");
                MessageBox.Show("An access error has occurred. Please check with the attendant.", "Access Error");
                return;
            }

            if (c.access == "true")
            {
                c.accesstype = 1;
            }
            else
            {
                if (c.visitcount < Program.BuildingInfo.maxvisits && Program.addguests == null)
                {
                    MessageBox.Show("Welcome " + c.name + "! This is visit number " + (c.visitcount + 1) + " of " + Program.BuildingInfo.maxvisits + ".", "Guest Information");
                    c.accesstype = 2;
                }
                else
                {
                    if (Program.addguests == null)
                    {
                        Program.attendant.AddHistoryString("-- " + DateTime.Now.ToString("MM-dd-yy hh:mm tt") + " Check-in rejected for " + c.name + " because they are not a member.");
                        MessageBox.Show("Only members may check-in. You will need to be a guest of a member to check-in.", "Members Only Error");
                        return;
                    }

                    if (Program.BuildingInfo.maxguests > -1)
                    {
                        var p = Program.GuestOf();

                        if (p != null && Util.GetGuestCount(p.pid) >= Program.BuildingInfo.maxguests)
                        {
                            Program.attendant.AddHistoryString("-- " + DateTime.Now.ToString("MM-dd-yy hh:mm tt") + " Check-in rejected for " + c.name + " because " + p.name + " reached the guest limit.");
                            MessageBox.Show("No additional guests are permitted for today.", "Guest Limit Error");
                            return;
                        }

                        c.accesstype = 3;
                    }
                }
            }

            var pb = Program.attendant.pictureBox1;

            pb.SetPropertyThreadSafe(() => pb.Image, Util.GetImage(c.pid));
            var na = Program.attendant.NameDisplay;

            na.SetPropertyThreadSafe(() => na.Text, c.name);
            var notes = Program.attendant.notes;

            notes.SetPropertyThreadSafe(() => notes.Text, c.notes);

            activities               = new ChooseActivities();
            activities.ControlBox    = false;
            activities.Tag           = ab.Tag;
            activities.StartPosition = FormStartPosition.Manual;
            activities.Location      = new Point(Program.baseform.Location.X + 100, Program.baseform.Location.Y + 100);
            activities.Text          = "Choose Activities for " + c.name;

            activities.list.Items.Clear();
            foreach (var i in Program.BuildingInfo.Activities)
            {
                activities.list.Items.Add(i);
            }
            activities.ok.Tag        = ab;
            activities.cancel.Tag    = ab;
            activities.AcceptButton  = activities.ok;
            activities.CancelButton  = activities.cancel;
            activities.ok.Click     += ok_Click;
            activities.cancel.Click += cancel_Click;

            mask           = new Label();
            mask.BackColor = BackColor;
            mask.Size      = Size;
            //mask.Location = this.Location;
            mask.Parent = this;
            mask.BringToFront();
            var nam = this.Controls[this.Controls.IndexOfKey("name" + ab.Tag.ToString())] as Button;
            var org = this.Controls[this.Controls.IndexOfKey("org" + ab.Tag.ToString())] as Label;

            nam.BringToFront();
            org.BringToFront();

            mask.Show();
            nam.Enabled = false;
            activities.ShowDialog();
            activities.BringToFront();
        }
예제 #2
0
        public void Attend_Click(Button ab)
        {
            Program.TimerReset();
            var c = list[(int)ab.Tag];
            if (c.lastpress.HasValue && DateTime.Now.Subtract(c.lastpress.Value).TotalSeconds < 1)
                return;

            if (c.access == "restricted")
            {
                Program.attendant.AddHistoryString("-- " + DateTime.Now.ToString("MM-dd-yy hh:mm tt") + " Check-in rejected for " + c.name + " because they are not permitted to use the facility.");
                MessageBox.Show("An access error has occurred. Please check with the attendant.", "Access Error");
                return;
            }

            if (c.access == "true")
            {
                c.accesstype = 1;
            }
            else
            {
                if (c.visitcount < Program.BuildingInfo.maxvisits && Program.addguests == null)
                {
                    MessageBox.Show("Welcome " + c.name + "! This is visit number " + (c.visitcount + 1) + " of " + Program.BuildingInfo.maxvisits + ".", "Guest Information");
                    c.accesstype = 2;
                }
                else
                {
                    if (Program.addguests == null)
                    {
                        Program.attendant.AddHistoryString("-- " + DateTime.Now.ToString("MM-dd-yy hh:mm tt") + " Check-in rejected for " + c.name + " because they are not a member.");
                        MessageBox.Show("Only members may check-in. You will need to be a guest of a member to check-in.", "Members Only Error");
                        return;
                    }

                    if (Program.BuildingInfo.maxguests > -1)
                    {
                        var p = Program.GuestOf();

                        if (p != null && Util.GetGuestCount(p.pid) >= Program.BuildingInfo.maxguests)
                        {
                            Program.attendant.AddHistoryString("-- " + DateTime.Now.ToString("MM-dd-yy hh:mm tt") + " Check-in rejected for " + c.name + " because " + p.name + " reached the guest limit.");
                            MessageBox.Show("No additional guests are permitted for today.", "Guest Limit Error");
                            return;
                        }

                        c.accesstype = 3;
                    }
                }
            }

            var pb = Program.attendant.pictureBox1;
            pb.SetPropertyThreadSafe(() => pb.Image, Util.GetImage(c.pid));
            var na = Program.attendant.NameDisplay;
            na.SetPropertyThreadSafe(() => na.Text, c.name);
            var notes = Program.attendant.notes;
            notes.SetPropertyThreadSafe(() => notes.Text, c.notes);

            activities = new ChooseActivities();
            activities.ControlBox = false;
            activities.Tag = ab.Tag;
            activities.StartPosition = FormStartPosition.Manual;
            activities.Location = new Point(Program.baseform.Location.X + 100, Program.baseform.Location.Y + 100);
            activities.Text = "Choose Activities for " + c.name;

            activities.list.Items.Clear();
            foreach (var i in Program.BuildingInfo.Activities)
                activities.list.Items.Add(i);
            activities.ok.Tag = ab;
            activities.cancel.Tag = ab;
            activities.AcceptButton = activities.ok;
            activities.CancelButton = activities.cancel;
            activities.ok.Click += ok_Click;
            activities.cancel.Click += cancel_Click;

            mask = new Label();
            mask.BackColor = BackColor;
            mask.Size = Size;
            //mask.Location = this.Location;
            mask.Parent = this;
            mask.BringToFront();
            var nam = this.Controls[this.Controls.IndexOfKey("name" + ab.Tag.ToString())] as Button;
            var org = this.Controls[this.Controls.IndexOfKey("org" + ab.Tag.ToString())] as Label;
            nam.BringToFront();
            org.BringToFront();

            mask.Show();
            nam.Enabled = false;
            activities.ShowDialog();
            activities.BringToFront();
        }