Пример #1
0
        /// <summary>
        /// This input will
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddNewItemBtn_Click(object sender, RoutedEventArgs e)
        {
            //clear error from previous entry
            ErrorLbl.Content = "";

            string barcode  = BarcodeTB.Text;
            string quantity = QuantityTB.Text;
            var    tdrV     = new TillDataRowValidation(barcode, quantity);

            //till row is valid
            if (tdrV.isTillDataRowValid)
            {
                //if description for item doesnt exist in datagrid
                if (!DoesDescriptionExist(tdrV.item.Description))
                {
                    //adding new TillDataRow
                    var newTDR = new TillDataRow(tdrV.item, tdrV.quantity);
                    AddRow(newTDR);

                    //update datagrid on screen
                    ItemDisplayDatGrd.UpdateLayout();
                }
                else
                {
                    ErrorLbl.Content = "That item already exists. Delete it and reenter.\n";
                }
            }
            else
            {
                ErrorLbl.Content = tdrV.ErrorMessage;
            }

            //allow for reuse
            tdrV.Complete();
            ClearInputs();
        }
Пример #2
0
 /// <summary>
 /// It will add the new row
 /// To the itemSource then update
 /// The datagrid
 /// </summary>
 /// <param name="barcode"></param>
 void AddRow(TillDataRow tdrAdd)
 {
     dataContext.Rows.Add(tdrAdd);
     ItemDisplayDatGrd.UpdateLayout();
 }