Ejemplo n.º 1
0
 public void RestartDGV()
 {
     DGView.DataSource = null;
     DGView.Rows.Clear();
     DGView.Columns.Clear();
     DGView.Update();
     DGView.Refresh();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Used to remove specific data on the Data Grid View
        /// </summary>
        /// <param name="barcode">Scanned Barcode</param>
        /// <returns></returns>
        private string RemoveSwiped(string barcode)
        {
            string message = "";

            try
            {
                var dataToRemove = _giftCards.FirstOrDefault(search => search.Barcode.Equals(barcode));
                _giftCards.Remove(dataToRemove);
                message = "Successful";

                BindingSource source = new BindingSource();
                source.DataSource = _giftCards.Select(data => new { data.SequenceNumber, data.CardHolderName }).ToList();

                DGView.DataSource = source;
                DGView.Refresh();
            }
            catch (Exception error)
            {
                message += error.Message;
            }
            return(message);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Used to load the data into the Data Grid View
        /// </summary>
        /// <param name="storedData">List of Data</param>
        private void LoadGridView(Dictionary <int, Dictionary <int, string> > storedData)
        {
            foreach (var data in storedData)
            {
                GiftCard card = new GiftCard();

                if (data.Value.TryGetValue(0, out string sequenceNumber))
                {
                    card.SequenceNumber = sequenceNumber;
                }

                if (data.Value.TryGetValue(1, out string barcode))
                {
                    card.Barcode = barcode;
                }

                if (data.Value.TryGetValue(2, out string cardHolderName))
                {
                    card.CardHolderName = cardHolderName;
                }

                if (data.Value.TryGetValue(3, out string cardNumber))
                {
                    card.CardNumber = cardNumber.Substring(cardNumber.IndexOf('B') + 1, 18);
                }

                _giftCards.Add(card);
            }

            BindingSource source = new BindingSource();

            source.DataSource = _giftCards.Select(data => new { data.SequenceNumber, data.CardNumber }).ToList();

            DGView.DataSource = source;
            DGView.Refresh();
        }