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(); } } } } } }
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(); }
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(); } } } }
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(); } } }
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(); } } }
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(); } } } }
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(); } }