You are on page 1of 6

Manual de Ayuda

using using using using using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms; System.Data.OleDb;

namespace Practica { public partial class reservas : Form { //conexion a base de datos OleDbConnection conex = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Roberth\Desktop\BasesDatos\Reservas.accdb"); OleDbCommand com = new OleDbCommand(); OleDbCommand com2; int ver = 0;//BANDERA public reservas() { InitializeComponent(); } private void reservaBindingNavigatorSaveItem_Click(object sender, EventArgs e) { //buscamos si existe el id socio this.Validate(); this.reservaBindingSource.EndEdit(); this.tableAdapterManager.UpdateAll(this.reservasDataSet); conex.Open(); String id = TextBox1.Text; com.CommandText = string.Format("SELECT ID_Soc FROM Socios WHERE ID_Soc='{0}'", id); string buscar_id = com.CommandText; com2 = new OleDbCommand(buscar_id,conex); OleDbDataReader lee = com2.ExecuteReader(); if (!lee.Read() && ver == 0) { DialogResult res = MessageBox.Show("ID del Socio no existe desea crearlo?", "Crear Socio",MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) {//habilitamos las opciones conex.Close(); nombreTextBox.Enabled = true; telefonoTextBox.Enabled = true;

profesionTextBox.Enabled = true; datos_bancTextBox.Enabled = true; nombreTextBox.Focus(); } else { MessageBox.Show("Registro No Guardado"); } } else { conex.Close(); MessageBox.Show("Registro Guardado"); } } //se cierra el guardar reservas private void reservas_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'reservasDataSet.Socios' table. You can move, or remove it, as needed. // this.sociosTableAdapter.Fill(this.reservasDataSet.Socios); // TODO: This line of code loads data into the 'reservasDataSet.Reserva' table. You can move, or remove it, as needed. this.reservaTableAdapter.Fill(this.reservasDataSet.Reserva); } private void button1_Click(object sender, EventArgs e) {//ESTE CODIGO ES EN EL GUARDAR conex.Open(); OleDbCommand com = new OleDbCommand("INSERT INTO Socios(ID_Soc,Nombre,Telefono,Profesion,Datos_banc) VALUES(" + TextBox1.Text + ",'" + nombreTextBox.Text + "','" + telefonoTextBox.Text + "','" + profesionTextBox.Text + "','" + datos_bancTextBox.Text + "')", conex); com.ExecuteNonQuery(); MessageBox.Show("Registro Guardado"); conex.Close(); nombreTextBox.Enabled = false; telefonoTextBox.Enabled = false; profesionTextBox.Enabled = false; datos_bancTextBox.Enabled = false; ver = 1; } private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e) { ver = 0; } private void nombreTextBox_KeyPress(object sender, KeyPressEventArgs e) {//VALIDACIONES if (char.IsLetter(e.KeyChar) || e.KeyChar == 8) { e.Handled = false; } else { e.Handled = true; }

} private void telefonoTextBox_KeyPress(object sender, KeyPressEventArgs e) { if (char.IsNumber(e.KeyChar) || e.KeyChar == 8) { e.Handled = false; } else { e.Handled = true; } } } } ESTE ES DEL FORMULARIO squash using using using using using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms; System.Data.OleDb;

namespace Practica { public partial class squash : Form { OleDbConnection conex = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Roberth\Desktop\BasesDatos\Reservas.accdb"); public squash() { InitializeComponent(); } private void squashBindingNavigatorSaveItem_Click(object sender, EventArgs e) { this.Validate(); this.squashBindingSource.EndEdit(); this.tableAdapterManager.UpdateAll(this.reservasDataSet); String id = iD_PistaTextBox.Text; if (int.Parse(iD_PistaTextBox.Text) >= 0 && int.Parse(iD_PistaTextBox.Text) <= 50) { conex.Open(); OleDbCommand com2 = new OleDbCommand(); com2.Connection = conex; for (int i = 0; i < tabla.Rows.Count - 1; i++) { com2.CommandText = "INSERT INTO Reserva(Fecha,ID_Soc,ID_Pista) VALUES(" + tabla[0, i].Value.ToString() + ",'" + tabla[1, i].Value.ToString() + "','" + id + "')"; com2.ExecuteNonQuery();

} conex.Close(); MessageBox.Show("Registro Guardado y Relacionado"); } else { MessageBox.Show("Campo Metros2 Solo permite valores entre 10 y 50 metros, Cambie Dicho Valor"); } } private void squash_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'reservasDataSet.Reserva' table. You can move, or remove it, as needed. this.reservaTableAdapter.Fill(this.reservasDataSet.Reserva); // TODO: This line of code loads data into the 'reservasDataSet.Squash' table. You can move, or remove it, as needed. this.squashTableAdapter.Fill(this.reservasDataSet.Squash); } private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e) {//NUEVO AGREGAR AUTOMATICO conex.Open(); OleDbCommand com = new OleDbCommand("SELECT ID_Pista FROM Squash ORDER BY ID_Pista DESC", conex); OleDbDataReader lee = com.ExecuteReader(); if (lee.Read()) { iD_PistaTextBox.Text = (int.Parse(lee[0].ToString()) + 1) + ""; // tabla.Enabled = true; } else { iD_PistaTextBox.Text = "1"; // tabla.Enabled = true; } conex.Close(); } } } Otras opciones

//ventana es (data source) //ventana (server explore) //barra de herramientas toolbox // ventana de formularios solution explore primeramente revisar libreras 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 System.Data.OleDb;


// para en lasar con la base de datos escribimos lo siguiente const string cnn = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\Base de datos1.accdb";

OleDbConnection conexion = new OleDbConnection(cnn); OleDbCommand comando1 = new OleDbCommand(); OleDbCommand comando2; OleDbDataAdapter adaptador; DataTable dt; //luego para validar las letras que solo sean mayuscula //nos colocamos en el cuadro de texto y en la ventana de propiedades (evento) // key press (nombre_socTextBox_KeyPres) dos clic y colocamos el codigo para validar el tex private void nombre_socTextBox_KeyPress(object sender, KeyPressEventArgs e) { if (Char.IsUpper(e.KeyChar) || e.KeyChar == 8) { e.Handled = false; } else { e.Handled = true; } }
//para validar solo numeros

private void telefono_socTextBox_KeyPress(object sender, KeyPressEventArgs e) { if (Char.IsNumber(e.KeyChar) || e.KeyChar == 8) { e.Handled = false; } else { e.Handled = true; } }
//validar letras minusculas

private void profesion_socTextBox_KeyPress(object sender, KeyPressEventArgs e) { if (Char.IsLower(e.KeyChar) || e.KeyChar == 8) { e.Handled = false; } else {

e.Handled = true; }
// para buscar si existe un codiogo

private void btbuscar_Click(object sender, EventArgs e) { conexion.Open(); string nombre= nombre_socTextBox.Text; comando1.CommandText = string.Format("SELECT nombre_soc from Socios where nombre_soc='{0}'",nombre); string buscarnombre = comando1.CommandText; comando2 = new OleDbCommand(buscarnombre, conexion); OleDbDataReader resultado = comando2.ExecuteReader(); if (resultado.Read()) { button1.Enabled = false; } else { MessageBox.Show("El nombre de socio no existe, desea crearlo?", "Alerta", MessageBoxButtons.YesNo); button1.Enabled = true; } conexion.Close(); } ///en el guardar si deseamos buscar //para agregar automaticamente //clic en nuevo escribimos el codigo necesitamos un combo box //escribimos el codigo siguiente private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e) { conexion.Open(); OleDbCommand comando1 = new OleDbCommand("SELECT count(*) from Squash", conexion); OleDbDataReader lee1 = comando1.ExecuteReader(); if (lee1.Read()) { id_pista_squaTextBox.Text = (int.Parse(lee1[0].ToString()) + 1) + ""; } conexion.Close(); } //para hacer reporte //primero agregamos un nuevo items en reportin cristalreposti1 //standar //OLE DB(ADO) (crear nueva coneccion) //para validar la cedula necesita maracar el casillero //Maxlength //maximo de nmeros groupBox1(ES PARA AGRUPAR COMANDOS EN UNA SOLA)

You might also like