/// <summary>
        /// this is the delete
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void DeleteButtonClicked(object sender, NewEventArgs e)
        {
            try
            {
                int li = e.LineItemID;
                RegisterLineItemControl RemoveCandidate = new RegisterLineItemControl();
                foreach (RegisterLineItemControl item in flowPanel.Controls)
                {
                    if (item.UserControlLineItemID == li)
                    {
                        RemoveCandidate = item;
                    }
                }

                flowPanel.Controls.Remove(RemoveCandidate);

                // reindex the flow panel
                foreach (RegisterLineItemControl item in flowPanel.Controls)
                {
                    if (item.UserControlLineItemID > li)
                    {
                        item.UserControlLineItemID--;
                    }
                }
                TheSale.DeleteRow(e.LineItemID);
                this.LineItem--;
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Exception at DeleteButtonClicked: {0}", ex));
            }

            CalculateRegister();
            FocusMe();
        }
 private void cmdDelete_Click(object sender, EventArgs e)
 {
     try
     {
         var d = new NewEventArgs();
         d.LineItemID = UserControlLineItemID;
         d.PriceChange = txtPrice.Text;
         d.QuantityChange = txtQuantity.Text;
         if (this.DeleteClick != null)
             this.DeleteClick(this, d);
     }
     catch (Exception ex)
     {
         MessageBox.Show(string.Format("Exception at cmdDelete_Click {0}", ex));
     }
 }
        /// <summary>
        /// this is the delete
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void DeleteButtonClicked(object sender, NewEventArgs e)
        {
            int li = e.LineItemID;
            UserControl1 RemoveCandidate = new UserControl1();

            foreach (UserControl1 item in flowPanel.Controls)
            {
                if (item.UserControlLineItemID == li)
                {
                    RemoveCandidate = item;
                }

            }

            flowPanel.Controls.Remove(RemoveCandidate);
            TheSale.DeleteRow(li);
            CalculateRegister();
            FocusMe();
        }
        /// <summary>
        /// this is for a quantity change
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void TextBoxChanged(object sender, NewEventArgs e)
        {
            int li = 0;
            double di = 0;
            string TestPrice;
            string TestQuantity;
            int OriginalQuantity = TheSale.Sale[e.LineItemID].Quantity;
            double OriginalPrice = TheSale.Sale[e.LineItemID].Price;

            TestQuantity = e.QuantityChange.Replace("$", "");
            TestQuantity = TestQuantity.Replace(",", "");
            TestQuantity = TestQuantity.Replace("#", "");
            TestQuantity = TestQuantity.Replace("-", "");

            if (int.TryParse(TestQuantity, out li) == true)
            {
                li = int.Parse(TestQuantity);
            }
            else
            {
                li = OriginalQuantity;
            }

            TestPrice = e.PriceChange.Replace("$","");
            TestPrice = TestPrice.Replace(",", "");
            TestPrice = TestPrice.Replace("#", "");
            TestPrice = TestPrice.Replace("-", "");
            if (double.TryParse(TestPrice, out di) == true)
            {
                di = double.Parse(TestPrice);
            }
            else
            {
                di = OriginalPrice;
            }

            TheSale.Update(e.LineItemID,di,li);
            //Update the flowpanel controls with revised values
            foreach (UserControl1 item in flowPanel.Controls)
            {
                if (item.UserControlLineItemID == e.LineItemID)
                {
                    item.SetNewLineItem(li, di, li * di);
                }

            }

            CalculateRegister();
            FocusMe();
        }
        /// <summary>
        /// this is for a quantity change
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void TextBoxChanged(object sender, NewEventArgs e)
        {
            int lineItemQuantity = 0;
            double lineItemPrice = 0;
            string TestPrice;
            string TestQuantity;

            try
            {
                int OriginalQuantity = TheSale.Sale[e.LineItemID].Quantity;
                double OriginalPrice = TheSale.Sale[e.LineItemID].Price;
                TestQuantity = e.QuantityChange.Replace("$", "");
                TestQuantity = TestQuantity.Replace(",", "");
                TestQuantity = TestQuantity.Replace("#", "");
                TestQuantity = TestQuantity.Replace("-", "");

                if (!int.TryParse(TestQuantity, out lineItemQuantity))
                {
                    lineItemQuantity = OriginalQuantity;
                }

                TestPrice = e.PriceChange.Replace("$", "");
                TestPrice = TestPrice.Replace(",", "");
                TestPrice = TestPrice.Replace("#", "");
                TestPrice = TestPrice.Replace("-", "");
                if (!double.TryParse(TestPrice, out lineItemPrice))
                {
                    lineItemPrice = OriginalPrice;
                }

                TheSale.Update(e.LineItemID, lineItemPrice, lineItemQuantity);
                //Update the flowpanel controls with revised values
                foreach (RegisterLineItemControl item in flowPanel.Controls)
                {
                    if (item.UserControlLineItemID == e.LineItemID)
                    {
                        item.SetNewLineItem(lineItemQuantity, lineItemPrice, lineItemQuantity * lineItemPrice);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Exception at TextBoxChanged: {0}", ex));
            }

            CalculateRegister();
            FocusMe();
        }
        private void txtPrice_LostFocus(object sender, EventArgs e)
        {
            try
            {
                var d = new NewEventArgs();
                d.LineItemID = UserControlLineItemID;
                d.PriceChange = txtPrice.Text;
                d.QuantityChange = txtQuantity.Text;

                if (this.priceChange != null)
                {
                    this.priceChange(sender, d);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Exception at txtPrice_LostFocus {0}", ex));
            }
        }