private void AddToBillOnEnter() { if (fiskalizovan()) { return; } if (currentBill == null) { return; } if (quantity_textBox1.Text == string.Empty) { if (sifraProizvoda_textBox.Text == string.Empty) { // fokus na gotovinu i popuni iznos float iznos = currentBill.TotalPrice(); float toAdd = iznos - currentBill.uplaceno; currentBill.gotovina += toAdd; textBox_gotovina.Text = currentBill.gotovina.ToString("0.00"); textBox_gotovina.Focus(); textBox_gotovina.SelectionStart = 0; textBox_gotovina.SelectionLength = textBox_gotovina.Text.Length; return; } else { quantity_textBox1.Text = "1"; } } string selectedProductSifra = sifraProizvoda_textBox.Text; if (selectedProductSifra == string.Empty) { sifraProizvoda_textBox.Focus(); return; } Products selectedProduct = products.FirstOrDefault(products => products.sifra == selectedProductSifra); if (selectedProduct != null) { float quantityToAdd = 1; //default if (float.TryParse(quantity_textBox1.Text, out quantityToAdd)) { currentBill.AddItem(new BillItem() { billId = currentBill.Id, Quantity = quantityToAdd, productIdent = selectedProduct.ident, productCena = selectedProduct.cena, productSifra = selectedProduct.sifra, productNaziv = selectedProduct.naziv, productJM = selectedProduct.jm, productPdv = selectedProduct.pdv, productBarkod = selectedProduct.barkod }); PopulateBillItemsTable(); quantity_textBox1.Clear(); sifraProizvoda_textBox.Clear(); sifraProizvoda_textBox.Focus(); } } else { showMessageBox(ERROR_WRONG_SIFRA_PROIZVODA, WARNING); sifraProizvoda_textBox.Clear(); sifraProizvoda_textBox.Focus(); return; } }