using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Npgsql;
namespace Agencia_de_Viajes
{
public partial class Form5 : Form
{
public Form5()
{
InitializeComponent();
}
private void irMenu_Click(object sender, EventArgs e)
{
this.Visible = false;
Form1 menu
= new Form1
(); menu.Visible = true;
}
private void cmdAgregar_Click(object sender, EventArgs e)
{
if (txtNumero.Text == "" || txtDescripcion.Text == "" || txtFecha.Text == "" || txtIdCliente.Text == "")
{
MessageBox.Show("DEBES INTRODUCIR VALORES...");
}
else
{
try
{
int NUMERO = Convert.ToInt16(txtNumero.Text);
string DESCRIPCION = txtDescripcion.Text;
DateTime today = DateTime.Today;
string FECHA = today.ToString("yyyy/MM/dd");
int ID = Convert.ToInt16(txtIdCliente.Text);
IDbConnection dbcon
= new NpgsqlConnection
("Server = localhost;" + "Database = Facturas;" + "User ID = marcela;"); dbcon.Open();
IDbCommand dbcmd = dbcon.CreateCommand();
dbcmd.CommandText = "insert into Cuentas_extras values(" + NUMERO + ",'" + DESCRIPCION + "','" + FECHA + "'," + ID + ")";
IDataReader reader = dbcmd.ExecuteReader();
dbcon.Close();
txtNumero.Text = "";
txtDescripcion.Text = "";
txtFecha.Text = "";
txtIdCliente.Text = "";
MessageBox.Show("Registro Guardado correctamente");
}
catch (Exception msg)
{
MessageBox.Show("error.....\n\n" + msg.ToString());
}
}
}
private void cmdMostrar_Click(object sender, EventArgs e)
{
try
{
NpgsqlConnection conexion
= new NpgsqlConnection
("Server = localhost; " + "Database = Facturas;" + "User ID = marcela;");
NpgsqlDataAdapter adaptador
= new NpgsqlDataAdapter
("select * from Cuentas_extras", conexion
); DataTable tablamemoria
= new DataTable
(); adaptador.Fill(tablamemoria);
dtaCuentasExtras.DataSource = tablamemoria.DefaultView;
}
catch (Exception msg)
{
MessageBox.Show("Error......\n\n" + msg.ToString());
}
}
}
}