private void btnRandom_Click(object sender, EventArgs e) { ClearForm(); if ((Application.OpenForms["FormCreateRandom"] as FormCreateRandom) != null) { //ya tenemos un formulario abierto SetNotificationTip("Cuidado!", "ya tenemos un formulario abierto.", ToolTipIcon.Info); } else { using (var formRand = new FormCreateRandom()) { var result = formRand.ShowDialog(); if (result == DialogResult.OK) { txtNameBook.Text = formRand.RandBook.NameBook; txtPurchasePrice.Text = formRand.RandBook.PurchasePrice.ToString(); txtSalePrice.Text = formRand.RandBook.SalePrice.ToString(); dtPublishDateBook.Value = formRand.RandBook.DatePublishBook; chAvaible.Checked = formRand.RandBook.IsAvaible; nudPagesBook.Value = formRand.RandBook.NumberPages; } //formRand.Show(); } } var formRandom = new FormCreateRandom(); //formRandom.Show(); //formRandom.ShowDialog(); }
private void btnRandom_Click(object sender, EventArgs e) { ClearForm(); if ((Application.OpenForms["FormCreateRandom"] as FormCreateRandom) != null) { //Form is already open SetNotificationTip("Advertencia", $"Ya existe una pantalla de libro aleatorio", ToolTipIcon.Warning); } else { // Form is not open using (var formRand = new FormCreateRandom()) { var result = formRand.ShowDialog(); if (result == DialogResult.OK) { //ASIGNAR VALORE A FORMULARIO txtNameBook.Text = formRand.RandBook.NameBook; txtPurchasePrice.Text = formRand.RandBook.PurchasePrice.ToString(); txtSalePrice.Text = formRand.RandBook.SalePrice.ToString(); dtPublishDateBook.Value = formRand.RandBook.DatePublishBook; chAvaible.Checked = formRand.RandBook.IsAvaible; nudPagesBook.Value = formRand.RandBook.NumberPages; } } } }