using System; using System.Windows.Forms; using CSharpLibrary.stuff; using CSharpLibrary.SqlTypes; using System.Data.SqlClient; namespace ProjetoLPVIII { public partial class Cadastro_de_Livros : Form { public int? id1, id2, id3, id4; public string n1, n2, n3, n4; public int idI = -9999; public Cadastro_de_Livros() { InitializeComponent(); Clean(); } private void Clean() { txtAutor.Clear(); txtEditora.Clear(); txtGenero.Clear(); txtISBN.Clear(); txtNomeLivro.Clear(); txtTipoMidia.Clear(); statusLivro.Text = ""; } private void btnSalvar_Click(object sender, EventArgs e) { SqlException sql = null; try { Item i = new Item(null, txtNomeLivro.Text, (int)id1,(int)id2,(int)id3,(int)id4,txtISBN.Text.ToString(),statusLivro.SelectedItem.ToString()); i.Add(); } catch (SqlException g) { sql = g; MessageBox.Show("Falha no cadastro!"); } if (sql == null) { MessageBox.Show("Item Cadastrado!"); Clean(); } } private void button2_Click(object sender, EventArgs e) { Clean(); } private void psqAutor_Click(object sender, EventArgs e) { search srch = new search(this, 1); srch.Show(); } private void psqGenero_Click(object sender, EventArgs e) { search srch = new search(this, 2); srch.Show(); } private void psqEditora_Click(object sender, EventArgs e) { search srch = new search(this, 3); srch.Show(); } private void psqTipo_Click(object sender, EventArgs e) { search srch = new search(this, 4); srch.Show(); } public void UpdateTxt() { if (n1 != null) { txtAutor.Text = n1; } if (n2 != null) { txtGenero.Text = n2; } if (n3 != null) { txtEditora.Text = n3; } if (n4 != null) { txtTipoMidia.Text = n4; } } } }