mercredi 30 octobre 2019

String disappears after clicking on another textbox

I'm trying to generate random integer value (Barcode) when I click on a button. Then, I 'm checking two tables (stocks, units) if the new barcode already exist or not. If it's unique, the new barcode will be written in the textbox.

It's all working but when I click on another texbox of form the barcode disappears.

PS: I defined newBarcode in global area as Integer..

        {
            BarcodeGenerator();
            string _newBarcode = newBarcode.ToString();
            if (context.Stocks.Any(c => c.Barcode == _newBarcode) || context.Units.Any(c => c.Unit == _newBarcode))
            {
                BarkodOlustur();
                return;
            }
            else
            {
                txtBarcode.Text = _newBarcode;
            }
        }



 private void BarcodeGenerator()
        {
            Random rnd = new Random();
            newBarcode = rnd.Next(10000000, 99999999);
        }



Aucun commentaire:

Enregistrer un commentaire