initial commit
This commit is contained in:
110
stuff/Item/AlterarLivro.cs
Normal file
110
stuff/Item/AlterarLivro.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Windows.Forms;
|
||||
using CSharpLibrary.SqlTypes;
|
||||
using CSharpLibrary.stuff;
|
||||
|
||||
|
||||
namespace TelasProjeto
|
||||
{
|
||||
public partial class formAlterarLivro : Form
|
||||
{
|
||||
public int? id1, id2, id3, id4;
|
||||
public int idI = -9999;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
private void btnAlterarLivro_Click(object sender, EventArgs e)
|
||||
{
|
||||
Item i = new Item(idI,"1", 1, 1, 1, 1, "1","1");
|
||||
SqlException sql = null;
|
||||
try {
|
||||
i.Edit(idI, new List<string>
|
||||
{ txtNomeLivro.Text, //0
|
||||
txtAutor.Text, // 1
|
||||
txtGenero.Text, // 2
|
||||
txtEditora.Text, // 3
|
||||
txtTipoMidia.Text, // 4
|
||||
txtISBN.Text, // 5
|
||||
statusLivro.SelectedItem.ToString()} // 6
|
||||
|
||||
// (string Autor, string Genero, string Editora, string Tipo)
|
||||
// Return para pegar PK!!
|
||||
// Vlr[0], [5], [6] -> nomeItem, isbnItem, statusItem;
|
||||
// Vlr[1], [2], [3], [4] -> idAutor,generoItem,editoraItem,tipoItem;
|
||||
);
|
||||
}
|
||||
catch(SqlException g)
|
||||
{
|
||||
sql = g;
|
||||
MessageBox.Show("Falha na alteração de dados!");
|
||||
}
|
||||
if(sql == null)
|
||||
{
|
||||
MessageBox.Show("Dados atualizados!");
|
||||
this.Close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public string n1, n2, n3, n4;
|
||||
|
||||
public formAlterarLivro(List<Tuple<int,string>> a)
|
||||
{
|
||||
idI = a[0].Item1;
|
||||
List<string> tmp = new List<string>();
|
||||
foreach (Tuple<int, string> b in a)
|
||||
tmp.Add(b.Item2);
|
||||
InitializeComponent();
|
||||
txtNomeLivro.Text = tmp[0];
|
||||
txtAutor.Text = tmp[1];
|
||||
txtGenero.Text = tmp[2];
|
||||
txtEditora.Text = tmp[3];
|
||||
txtTipoMidia.Text = tmp[4];
|
||||
txtISBN.Text = tmp[5];
|
||||
statusLivro.SelectedItem = tmp[6];
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user