initial commit
This commit is contained in:
106
stuff/Item/AlterarEmprestimo.cs
Normal file
106
stuff/Item/AlterarEmprestimo.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Windows.Forms;
|
||||
using CSharpLibrary.SqlTypes;
|
||||
|
||||
namespace CSharpLibrary.stuff.Item
|
||||
{
|
||||
public partial class AlterarEmprestimo : Form
|
||||
{
|
||||
public Emprestimo ed = null;
|
||||
public CSharpLibrary.SqlTypes.Item i = null;
|
||||
public Funcionario f = null;
|
||||
public Cliente c = null;
|
||||
string str;
|
||||
Consulta ce = null;
|
||||
public AlterarEmprestimo(int id, Consulta ce)
|
||||
{
|
||||
|
||||
this.ce = ce;
|
||||
InitializeComponent();
|
||||
ed = ReturnTypes.AReturnEmprestimo(id);
|
||||
i = ReturnTypes.AReturnItem(ed.idItem);
|
||||
f = ReturnTypes.AReturnFuncionario(ed.idFunc);
|
||||
c = ReturnTypes.AReturnCliente(ed.idCliente);
|
||||
|
||||
txtNomeCliente.Text = c.nome;
|
||||
txtNomeItem.Text = i.nomeItem;
|
||||
txtNomeFuncionario.Text = f.nome;
|
||||
dateTimePicker1.Value = ed.dtEmprestimo;
|
||||
dateTimePicker2.Value = ed.dtDevolucao;
|
||||
checkBox1.Checked = (ed.statusEmprestimo.ToUpper() == "EMPRESTADO") ? false : true;
|
||||
|
||||
}
|
||||
|
||||
private void btnLimpar_Click(object sender, EventArgs e)
|
||||
{
|
||||
txtNomeCliente.Clear();
|
||||
txtNomeItem.Clear();
|
||||
dateTimePicker1.ResetText();
|
||||
dateTimePicker2.ResetText();
|
||||
checkBox1.Checked = false;
|
||||
}
|
||||
|
||||
private void btnAlterar_Click(object sender, EventArgs e)
|
||||
{
|
||||
if(ed != null && f != null && i != null && c != null)
|
||||
{
|
||||
btnSalvar.Enabled = true;
|
||||
psqCli.Enabled = true;
|
||||
psqItem.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void psqCli_Click(object sender, EventArgs e)
|
||||
{
|
||||
search srch = new search(this, 7);
|
||||
srch.Show();
|
||||
}
|
||||
|
||||
private void psqItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
search srch = new search(this, 5);
|
||||
srch.Show();
|
||||
}
|
||||
public void UpdateTxt()
|
||||
{
|
||||
txtNomeCliente.Text = c.nome;
|
||||
txtNomeItem.Text = i.nomeItem;
|
||||
txtNomeFuncionario.Text = f.nome;
|
||||
dateTimePicker1.Value = ed.dtEmprestimo;
|
||||
dateTimePicker2.Value = ed.dtDevolucao;
|
||||
checkBox1.Checked = (ed.statusEmprestimo.ToUpper() == "EMPRESTADO") ? false : true;
|
||||
}
|
||||
private void btnSalvar_Click(object sender, EventArgs e)
|
||||
{
|
||||
SqlException sql = null;
|
||||
try {
|
||||
str = (checkBox1.Checked == true) ? "ENTREGUE" : "EMPRESTADO";
|
||||
ed.Edit(ed.idEmprestimo, new List<string> {
|
||||
f.nome,
|
||||
c.nome,
|
||||
i.nomeItem,
|
||||
dateTimePicker1.Value.ToString(),
|
||||
dateTimePicker2.Value.ToString(),
|
||||
str
|
||||
});
|
||||
}
|
||||
catch (SqlException g)
|
||||
{
|
||||
sql = g;
|
||||
MessageBox.Show("Falha na alteração de dados!");
|
||||
}
|
||||
if (sql == null)
|
||||
{
|
||||
MessageBox.Show("Dados atualizados!");
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void AlterarEmprestimo_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
ce.Restart();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user