Esempio n. 1
0
        private void CalculateMetrics()
        {
            using (var context = new EventEntities())
            {
                var totalGuests = context.Guests.Count();
                var unassigned  = (from guest in context.Guests
                                   where !context.Tokens.Any(q => q.GuestID == guest.ID)
                                   select guest.ID).ToList().Count();

                var assigned = (from guest in context.Guests
                                where context.Tokens.Any(q => q.GuestID == guest.ID)
                                select guest.ID).ToList().Count();

                var crew      = context.SpecialCards.Where(q => q.Level == "Crew").Count();
                var protocol  = context.SpecialCards.Where(q => q.Level == "Protocol").Count();
                var media     = context.MediaCards.Where(q => q.Uid != null && q.Uid.Length > 0).Count();
                var vvip      = context.VipCards.Where(q => q.Uid != null && q.Uid.Length > 0 && q.Level == "VVIP").Count();
                var vip       = context.VipCards.Where(q => q.Uid != null && q.Uid.Length > 0 && q.Level == "VIP").Count();
                var temporary = context.TemporaryCards.Count();

                this.Total_Guests_Label.Text      = totalGuests.ToString();
                this.Unassigned_Guests_Label.Text = unassigned.ToString();
                this.Assigned_Guests_Label.Text   = assigned.ToString();
                this.Crew_Cards_Label.Text        = crew.ToString();
                this.Protocol_Cards_Label.Text    = protocol.ToString();
                this.Media_Cards_Label.Text       = media.ToString();
                this.VVIP_Cards_Label.Text        = vvip.ToString();
                this.VIP_Cards_Label.Text         = vip.ToString();
                this.Temporary_Cards_Label.Text   = temporary.ToString();
            }
        }
Esempio n. 2
0
        private void AssignCardToGuest(string uid, int guestId)
        {
            using (var context = new EventEntities())
            {
                var exists = context.Tokens.FirstOrDefault(q => q.Uid == uid);

                if (exists == null)
                {
                    var guest = context.Guests.FirstOrDefault(q => q.ID == guestId);

                    if (guest != null && MessageBox.Show(string.Format("Do you want to assign card uid [{0}] to guest [{1}]", uid, guest.FullName), "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        var token = new Token()
                        {
                            Uid     = uid,
                            GuestID = guestId
                        };

                        context.Tokens.Add(token);
                        context.SaveChanges();
                        ClearInput();
                    }
                }
            }

            CalculateMetrics();
        }
Esempio n. 3
0
        private void PopulateTemporaryList()
        {
            this.Temporary_List.BeginUpdate();
            this.Temporary_List.Items.Clear();

            using (var context = new EventEntities())
            {
                var cards = context.TemporaryCards.ToList();

                cards.All(delegate(TemporaryCard card)
                {
                    var item  = new ListViewItem();
                    item.Tag  = card.ID;
                    item.Text = card.Uid;
                    item.SubItems.Add(card.Serial);

                    this.Temporary_List.Items.Add(item);


                    return(true);
                });
            }

            this.Temporary_List.EndUpdate();
        }
Esempio n. 4
0
        private void Connect_Button_Click(object sender, EventArgs e)
        {
            var server   = this.Server_Box.Text;
            var catalog  = this.Catalog_Box.Text;
            var user     = this.Username_Box.Text;
            var password = this.Password_Box.Text;

            Settings.Default.Server   = server;
            Settings.Default.Catalog  = catalog;
            Settings.Default.Username = user;
            Settings.Default.Password = password;

            Settings.Default.Save();

            try
            {
                using (var db = new EventEntities())
                {
                    var guests = db.Guests.ToList();
                    MessageBox.Show("Connection was successfull.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    CalculateMetrics();
                    PopulateStatusList();
                    PopulateSpecialList();
                    PopulateTemporaryList();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 5
0
        private void Delete_Button_Click(object sender, EventArgs e)
        {
            if (this.Status_List.SelectedItems != null)
            {
                var item = this.Status_List.SelectedItems[0];

                var uid = item.Text;

                if (uid.Length > 0)
                {
                    string question = string.Format("{0} uid related to a quest will be deleted, are you sure?", uid);

                    if (MessageBox.Show(question, "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        using (var context = new EventEntities())
                        {
                            var existingRecord = context.Tokens.FirstOrDefault(q => q.Uid == uid);

                            if (existingRecord != null)
                            {
                                context.Tokens.Remove(existingRecord);
                                context.SaveChanges();

                                PopulateStatusList();
                            }
                        }
                    }
                }
            }
        }
Esempio n. 6
0
        internal static void ConfigureConnectionString(EventEntities context)
        {
            Settings.Default.Reload();

            var server   = Settings.Default.Server;
            var catalog  = Settings.Default.Catalog;
            var user     = Settings.Default.Username;
            var password = Settings.Default.Password;


            context.Database.Connection.ConnectionString = context.Database.Connection.ConnectionString.Replace("{Server}", server).
                                                           Replace("{Catalog}", catalog).
                                                           Replace("{User}", user).
                                                           Replace("{Password}", password);
        }
Esempio n. 7
0
        private void Search_Vip_Box_TextChanged(object sender, EventArgs e)
        {
            if (this.Search_Vip_Box.Text.Length > 0)
            {
                var key = this.Search_Vip_Box.Text.ToUpper();

                using (var context = new EventEntities())
                {
                    var result = (from m in context.VipCards
                                  where (m.Name.ToUpper() + " " + m.MiddleName.ToUpper() + " " + m.Surname.ToUpper()).Contains(key) &&
                                  m.Uid == null
                                  select m).ToList();

                    if (result.Count > 0)
                    {
                        this.Vip_List.BeginUpdate();
                        this.Vip_List.Items.Clear();

                        result.All(delegate(VipCard card)
                        {
                            var item = new ListViewItem()
                            {
                                Text = card.Level,
                            };

                            item.SubItems.Add(card.Title);
                            item.SubItems.Add(card.Name);

                            item.SubItems.Add(card.Surname);
                            item.SubItems.Add(card.Position);
                            item.SubItems.Add(card.Company);
                            item.Tag = card.ID;

                            this.Vip_List.Items.Add(item);

                            return(true);
                        });

                        this.Vip_List.EndUpdate();
                    }
                    else
                    {
                        this.Vip_List.Items.Clear();
                    }
                }
            }
        }
Esempio n. 8
0
        private void Search_Box_TextChanged(object sender, EventArgs e)
        {
            if (this.Search_Box.Text.Length > 0)
            {
                var key = this.Search_Box.Text.ToUpper();

                using (var context = new EventEntities())
                {
                    var result = (from guest in context.Guests
                                  where (guest.Name.ToUpper() + " " + guest.Surname.ToUpper()).Contains(key) &&
                                  !context.Tokens.Any(q => q.GuestID == guest.ID)
                                  select guest).ToList();

                    if (result.Count > 0)
                    {
                        this.Results_View.BeginUpdate();

                        this.Results_View.Items.Clear();

                        result.All(delegate(Guest guest)
                        {
                            var item = new ListViewItem()
                            {
                                Text = guest.Title,
                            };

                            item.SubItems.Add(guest.Name);
                            item.SubItems.Add(guest.Surname);
                            item.SubItems.Add(guest.Position);
                            item.SubItems.Add(guest.Organization);
                            item.Tag = guest.ID;

                            Results_View.Items.Add(item);

                            return(true);
                        });

                        this.Results_View.EndUpdate();
                    }
                    else
                    {
                        this.Results_View.Items.Clear();
                    }
                }
            }
        }
Esempio n. 9
0
        private void AssignVipCard(string uid, int cardId)
        {
            if (uid.Length > 0)
            {
                using (var context = new EventEntities())
                {
                    var card = context.VipCards.FirstOrDefault(q => q.ID == cardId);

                    if (card != null)
                    {
                        card.Uid = uid;
                        context.SaveChanges();

                        ClearInput();
                        CalculateMetrics();
                    }
                }
            }
        }
Esempio n. 10
0
        private void Search_Media_Box_TextChanged(object sender, EventArgs e)
        {
            if (this.Search_Media_Box.Text.Length > 0)
            {
                var key = this.Search_Media_Box.Text.ToUpper();

                using (var context = new EventEntities())
                {
                    var result = (from m in context.MediaCards
                                  where m.Name.ToUpper().Contains(key) &&
                                  m.Uid == null
                                  select m).ToList();

                    if (result.Count > 0)
                    {
                        this.Media_List.BeginUpdate();
                        this.Media_List.Items.Clear();

                        result.All(delegate(MediaCard card)
                        {
                            var item = new ListViewItem()
                            {
                                Text = card.Name,
                            };

                            item.SubItems.Add(card.Outlet);
                            item.Tag = card.ID;

                            this.Media_List.Items.Add(item);

                            return(true);
                        });

                        this.Media_List.EndUpdate();
                    }
                    else
                    {
                        this.Media_List.Items.Clear();
                    }
                }
            }
        }
Esempio n. 11
0
        private void Add_Special_Button_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(this.Special_Uid_Box.Text) && this.Special_Uid_Box.Text.Length > 0)
            {
                using (var context = new EventEntities())
                {
                    var card = new SpecialCard()
                    {
                        Level = this.Special_Level_Combo.SelectedItem.ToString(),
                        Uid   = this.Special_Uid_Box.Text
                    };

                    context.SpecialCards.Add(card);
                    context.SaveChanges();

                    ClearInput();
                    PopulateSpecialList();
                    CalculateMetrics();
                }
            }
        }
Esempio n. 12
0
        private void Add_Button_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(this.Temp_Uid_Box.Text) &&
                !string.IsNullOrEmpty(this.Serial_Box.Text))
            {
                using (var context = new EventEntities())
                {
                    var card = new TemporaryCard()
                    {
                        Uid    = this.Temp_Uid_Box.Text,
                        Serial = this.Serial_Box.Text
                    };

                    context.TemporaryCards.Add(card);
                    context.SaveChanges();

                    ClearInput();
                    PopulateTemporaryList();
                }
            }
        }
Esempio n. 13
0
        private void Delete_Special_Button_Click(object sender, EventArgs e)
        {
            if (this.Special_List.SelectedItems != null && this.Special_List.SelectedItems.Count > 0)
            {
                var item = this.Special_List.SelectedItems[0];

                var id = Convert.ToInt32(item.Tag);

                using (var context = new EventEntities())
                {
                    var exists = context.SpecialCards.FirstOrDefault(q => q.ID == id);

                    if (exists != null)
                    {
                        context.SpecialCards.Remove(exists);
                        context.SaveChanges();

                        PopulateSpecialList();
                    }
                }
            }
        }
Esempio n. 14
0
        private void Delete_Temporary_Button_Click(object sender, EventArgs e)
        {
            if (this.Temporary_List.SelectedItems != null &&
                this.Temporary_List.SelectedItems.Count > 0)
            {
                var item = this.Temporary_List.SelectedItems[0];
                var id   = Convert.ToInt32(item.Tag);

                using (var context = new EventEntities())
                {
                    var existing = context.TemporaryCards.FirstOrDefault(q => q.ID == id);

                    if (existing != null)
                    {
                        context.TemporaryCards.Remove(existing);
                        context.SaveChanges();

                        ClearInput();
                    }
                }

                PopulateTemporaryList();
            }
        }
Esempio n. 15
0
        void PopulateSpecialList()
        {
            this.Special_List.BeginUpdate();
            this.Special_List.Items.Clear();

            using (var context = new EventEntities())
            {
                var specialCards = context.SpecialCards.OrderByDescending(q => q.ID).ToList();

                specialCards.All(delegate(SpecialCard card)
                {
                    var item  = new ListViewItem();
                    item.Tag  = card.ID;
                    item.Text = card.Uid;
                    item.SubItems.Add(card.Level);

                    this.Special_List.Items.Add(item);

                    return(true);
                });
            }

            this.Special_List.EndUpdate();
        }
Esempio n. 16
0
        private void PcscReader_CardScanned(string uid)
        {
            ClearInput();

            using (var context = new EventEntities())
            {
                var exists  = context.Tokens.FirstOrDefault(q => q.Uid == uid);
                var exists2 = context.TemporaryCards.FirstOrDefault(q => q.Uid == uid);
                var exists3 = context.SpecialCards.FirstOrDefault(q => q.Uid == uid);
                var exists4 = context.MediaCards.FirstOrDefault(q => q.Uid == uid);
                var exists5 = context.VipCards.FirstOrDefault(q => q.Uid == uid);

                if (exists != null)
                {
                    var guest = context.Guests.FirstOrDefault(q => q.ID == exists.GuestID);

                    if (guest != null)
                    {
                        MessageBox.Show(string.Format("This card already belongs to {0}.", guest.FullName), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else if (exists2 != null)
                {
                    string message = string.Format("This card [{0}] is already registered as a temporary card with a serial code of: {1}", exists2.Uid, exists2.Serial);

                    MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (exists3 != null)
                {
                    string message = string.Format("This card [{0}] is already registered as a special card with {1} access level.", exists3.Uid, exists3.Level);

                    MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (exists4 != null)
                {
                    string message = string.Format("This card [{0}] is already registered as a media/reporter card to {1} - {2}", exists4.Uid, exists4.Name, exists4.Outlet);

                    MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (exists5 != null)
                {
                    string message = string.Format("This card [{0}] is already registered as a vip/vvip card to {1} {2}", exists5.Uid, exists5.Name, exists5.Surname);
                    MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    this.Uid_Box.Text         = uid;
                    this.Temp_Uid_Box.Text    = uid;
                    this.Special_Uid_Box.Text = uid;
                    this.Media_Uid_Box.Text   = uid;
                    this.Vip_Uid_Box.Text     = uid;

                    if (tabControl1.SelectedTab == tabPage6)
                    {
                        Search_Vip_Box.Focus();
                    }
                    else
                    {
                        this.Search_Box.Focus();
                    }

                    this.Search_Box.Enabled    = true;
                    this.Cancel_Button.Enabled = true;


                    this.Results_View.Enabled = true;
                }
            }
        }
Esempio n. 17
0
        private void PopulateStatusList()
        {
            using (var context = new EventEntities())
            {
                List <GuestAudit> result = new List <GuestAudit>();

                switch (ListViewState)
                {
                case ListViewState.All:
                {
                    result = (from guest in context.Guests
                              join token in context.Tokens on guest.ID equals token.GuestID into joined
                              from t in joined.DefaultIfEmpty()
                              select new GuestAudit()
                        {
                            ID = guest.ID,
                            Uid = t.Uid,
                            Title = guest.Title,
                            Name = guest.Name,
                            Surname = guest.Surname,
                            Position = guest.Position,
                            Organization = guest.Organization,
                        }).OrderBy(q => q.Name).ToList();


                    break;
                }

                case ListViewState.Unassigned:
                {
                    result = (from guest in context.Guests
                              where !context.Tokens.Any(q => q.GuestID == guest.ID)
                              select new GuestAudit()
                        {
                            ID = guest.ID,
                            Uid = "",
                            Title = guest.Title,
                            Name = guest.Name,
                            Surname = guest.Surname,
                            Position = guest.Position,
                            Organization = guest.Organization,
                        }).OrderBy(q => q.Name).ToList();

                    break;
                }

                case ListViewState.Assigned:
                {
                    result = (from guest in context.Guests
                              join token in context.Tokens on guest.ID equals token.GuestID
                              where context.Tokens.Any(q => q.GuestID == guest.ID)
                              select new GuestAudit()
                        {
                            ID = guest.ID,
                            Uid = token.Uid,
                            Title = guest.Title,
                            Name = guest.Name,
                            Surname = guest.Surname,
                            Position = guest.Position,
                            Organization = guest.Organization,
                        }).OrderBy(q => q.Name).ToList();

                    break;
                }
                }

                if (result.Count > 0)
                {
                    this.Status_List.BeginUpdate();
                    this.Status_List.Items.Clear();

                    result.All(delegate(GuestAudit audit)
                    {
                        var item  = new ListViewItem();
                        item.Tag  = audit.ID;
                        item.Text = audit.Uid;
                        item.SubItems.Add(audit.Title);
                        item.SubItems.Add(audit.Name);
                        item.SubItems.Add(audit.Surname);
                        item.SubItems.Add(audit.Position);
                        item.SubItems.Add(audit.Organization);

                        this.Status_List.Items.Add(item);

                        return(true);
                    });

                    this.Status_List.EndUpdate();
                }
                else
                {
                    this.Status_List.BeginUpdate();
                    this.Status_List.Items.Clear();
                    this.Status_List.EndUpdate();
                }
            }
        }