Você está na página 1de 30

BASE DE DATOS Nombre de la Base de Datos: Biblioteca. Tabla: Editorial.

Nombre de Columna IDEditorial NombreEditorial Direccion Pais Ciudad Tipo de Datos char nvarchar nvarchar nvarchar nvarchar Longitud 10 80 100 50 50

Universidad de Managua

Permitir valore Nulos Desactivar Desactivar Desactivar Desactivar Desactivar

FORMULARIO EN VISTA DISEO

Numero 1

Tipo de Control Widows Form

Button

Button

Button

Button

Propiedad (Name) BackColor FormBordeStyle Icon MaximizeBox Size StartPosition Text (Name) BackColor FlatStyle Image Size (Name) BackColor FlatStyle Image Size (Name) BackColor FlatStyle Image Size (Name) BackColor FlatStyle Image Size

Valor FrmEditorial 236,233,216 FixedSingle Buscar Icono False 600,344 CenterScreen Registro de Editoriales CmdInicio 236,233,216 Popup Buscar Imagen 80,32 CmdSiguiente 236,233,216 Popup Buscar Imagen 80,32 CmdAnterior 236,233,216 Popup Buscar Imagen 80,32 CmdUltimo 236,233,216 Popup Buscar Imagen 80,32 1

Ing. Adolfo Machado.

Universidad de Managua
6 Button (Name) BackColor FlatStyle Image Size (Name) BackColor FlatStyle Image Size (Name) BackColor FlatStyle Image Size (Name) BackColor FlatStyle Image Size (Name) BackColor FlatStyle Image Size (Name) BackColor FlatStyle Image Size (Name) BackColor FlatStyle Image Size (Name) BackColor Font ForeColor Size Text (Name) BackColor Text (Name) BackColor BorderStyle CharacterCasing Font Text (Name) BackColor Text (Name) BackColor BorderStyle CharacterCasing Font Text (Name) BackColor Text (Name) BackColor BorderStyle CharacterCasing Font Multiline ScrollBars Text (Name) CmdNuevo 236,233,216 Popup Buscar Imagen 80,32 CmdGuardar 236,233,216 Popup Buscar Imagen 80,32 CmdCancelar 236,233,216 Popup Buscar Imagen 80,32 CmdModificar 236,233,216 Popup Buscar Imagen 80,32 CmdEliminar 236,233,216 Popup Buscar Imagen 80,32 CmdBuscar 236,233,216 Popup Buscar Imagen 80,32 CmdCerrar 236,233,216 Popup Buscar Imagen 80,32 GrpInformacion 236,233,216 Microsoft Sans Serif, Tamao 10 Navy 576,176 Informacin Editorial LblIDEditorial 236,233,216 Id. Editorial: TxtIDEditorial 251,250,213 FixedSingle Upper Lucida Console, Tamao 10 Borrar el texto en esta propiedad LblNombreEditorial 236,233,216 Nombre: TxtNombreEditorial 251,250,213 FixedSingle Upper Lucida Console, Tamao 10 Borrar el texto en esta propiedad LblDireccion 236,233,216 Direccin: TxtDireccion 251,250,213 FixedSingle Upper Lucida Console, Tamao 10 True Vertical Borrar el texto en esta propiedad LblPais 2

Button

Button

Button

10

Button

11

Button

12

Button

13

GroupBox

14

Label

15

TextBox

16

Label

17

TextBox

18

Label

19

TextBox

20

Label

Ing. Adolfo Machado.

Universidad de Managua
21 TextBox BackColor Text (Name) BackColor BorderStyle CharacterCasing Font Text (Name) BackColor Text (Name) BackColor BorderStyle CharacterCasing Font Text (Name) BackColor Text 236,233,216 Pas: TxtPais 251,250,213 FixedSingle Upper Lucida Console, Tamao 10 Borrar el texto en esta propiedad LblCiudad 236,233,216 Ciudad: TxtCiudad 251,250,213 FixedSingle Upper Lucida Console, Tamao 10 Borrar el texto en esta propiedad LblMensaje 236,233,216 Borrar el texto en esta propiedad

22

Label

23

TextBox

24

Label

Ing. Adolfo Machado.

PROCEDIMIENTOS ALMACENADOS DE LA BASE DE DATOS Nombre del Procedimiento: GuardarEditorial.

Universidad de Managua

CREATE PROCEDURE GuardarEditorial @codigo char(10), @nombre nvarchar(80), @direccion nvarchar(100),@pais nvarchar(50),@ciudad nvarchar(50) AS INSERT INTO Editorial(IDEditorial,NombreEditorial,Direccion,Pais,Ciudad) VALUES (RTRIM(LTRIM(@codigo)),RTRIM(LTRIM(@nombre)),RTRIM(LTRIM(@direccion)),RTRIM(LTRIM(@pais)),RTRIM(LTRIM(@ciudad))) GO Nombre del Procedimiento: ModificarEditorial. CREATE PROCEDURE ModificarEditorial @codigo char(10), @nombre nvarchar(80), @direccion nvarchar(100),@pais nvarchar(50),@ciudad nvarchar(50) AS UPDATE Editorial SET IDEditorial=RTRIM(LTRIM(@codigo)),NombreEditorial=RTRIM(LTRIM(@nombre)),Direccion=RTRIM(LTRIM(@direccion)),Pais=RTRIM(LTRIM(@pais)),Ciudad=RTRIM(LTRIM(@ciudad )) WHERE IDEditorial=RTRIM(LTRIM(@codigo)) GO Nombre del Procedimiento: EliminarEditorial. CREATE PROCEDURE EliminarEditorial @codigo char(10) AS DELETE FROM Editorial WHERE IDEditorial=@codigo GO

Ing. Adolfo Machado.

CODIGOS Cdigo de la clase: CEditorial. using System; using System.Data; using System.Data.SqlClient; namespace SAB { /// <summary> /// Descripcin breve de CEditorial. /// </summary> public class CEditorial { //**************************************************** //* Atributos de la clase CEditorial * //**************************************************** private string strCodigoEditorial; private string strNombre; private string strDireccion; private string strPais; private string strCiudad; //**************************************************** //* Variables de la conexion a la base de datos * //**************************************************** System.Data.SqlClient.SqlConnection oConexion; System.Data.SqlClient.SqlCommand oComando; //************************************** //* Propiedades de la clase CAutor * //************************************** public string IDEditorial { get { return this.strCodigoEditorial; } set { this.strCodigoEditorial =value; } } public string NombreEditorial

Universidad de Managua

Ing. Adolfo Machado.

{ get { } set { } } public string Direccion { get { return this.strDireccion; } set { this.strDireccion =value; } } public string Pais { get { return this.strPais; } set { this.strPais =value; } } public string Ciudad { get { return this.strCiudad; } set { this.strCiudad =value; } return this.strNombre;

Universidad de Managua

this.strNombre =value;

Ing. Adolfo Machado.

} //**************************************************** //* Constructor de la clase CEditorial * //**************************************************** public CEditorial() { this.strCodigoEditorial =""; this.strNombre =""; this.strDireccion =""; this.strPais =""; this.strCiudad =""; } //**************************************************** //* Mtodos pblicos de la clase CEditorial * //**************************************************** public bool GuardarEditorial(string strCadenaConexion) { bool Resultado=false; try { if(this.ValidarDatos ()) { //Se crea el objeto oConexion con la base de datos. Se le transfiere la cadena de conexion this.oConexion =new SqlConnection (strCadenaConexion + "initial catalog=Biblioteca"); //Abrir la conexion this.oConexion.Open (); //Crear el objeto oComando this.oComando =new SqlCommand(); //Se le tranfiere a oComando la conexion con la base de datos this.oComando.Connection =this.oConexion; //En CommandText se estipula el nombre del procedimiento almacenado this.oComando.CommandText ="GuardarEditorial"; /************************************************************************** En CommmandType se establece el tipo de consulta a ejecutar. Como es un procedimiento almacenado se coloca CommandType.StoredProcedure para especificar que es un procedimiento almacenado ***************************************************************************/ this.oComando.CommandType= CommandType.StoredProcedure; /************************************************************************** Definicion de los parametros del procedimiento almacenado GuardarAutor.

Universidad de Managua

Ing. Adolfo Machado.

Al final se le transfiere el valor que poseera cada parametro, para ello se le pasa el valor de la propiedad correspondiente de la clase. ***************************************************************************/ this.oComando.Parameters.Add (new SqlParameter ("@codigo",System.Data.SqlDbType.Char,10,ParameterDirection.Input,true,0,0,"",DataRowVersion.Current,this.strCodigoEditorial)); this.oComando.Parameters.Add (new SqlParameter ("@nombre",System.Data.SqlDbType.NVarChar,80,ParameterDirection.Input,true,0,0,"",DataRowVersion.Current ,this.strNombre)); this.oComando.Parameters.Add (new SqlParameter ("@direccion",System.Data.SqlDbType.NVarChar,100,ParameterDirection.Input,true,0,0,"",DataRowVersion.Current,this.strDireccion)); this.oComando.Parameters.Add (new SqlParameter ("@pais",System.Data.SqlDbType.NVarChar,50,ParameterDirection.Input,true,0,0,"",DataRowVersion.Current,this.strPais)); this.oComando.Parameters.Add (new SqlParameter ("@ciudad",System.Data.SqlDbType.NVarChar,50,ParameterDirection.Input,true,0,0,"",DataRowVersion.Current,this.strCiudad)); //Ejecutar el procedimiento almacenado. //Si el valor retornado es distinto de cero la operacin no ha tenido ningn problema if(this.oComando.ExecuteNonQuery ()!=0) { System.Windows.Forms.MessageBox.Show ("Registro guardado satisfactoriamente","Sistema de Automatizacin de Biblioteca",System.Windows.Forms.MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Information); Resultado=true; } else {

Universidad de Managua

System.Windows.Forms.MessageBox.Show ("Error en la operacin, operacin cancelada","Sistema de Automatizacin de Biblioteca",System.Windows.Forms.MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Error); Resultado=false;

} } else this.oConexion.Close ();

Resultado=false; } catch(Exception e) { //Muestra un mensaje si ocurre algun error interno System.Windows.Forms.MessageBox.Show(e.Message,"Sistema de Automatizacin de Biblioteca",System.Windows.Forms.MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Error); } return Resultado;

Ing. Adolfo Machado.

Universidad de Managua
} public bool ModificarEditorial(string strCadenaConexion) { bool Resultado=false; try { if(this.ValidarDatos ()) { //Se crea el objeto oConexion con la base de datos. Se le transfiere la cadena de conexion this.oConexion =new SqlConnection (strCadenaConexion + "initial catalog=Biblioteca"); //Abrir la conexion this.oConexion.Open (); //Crear el objeto oComando this.oComando =new SqlCommand(); //Se le tranfiere a oComando la conexion con la base de datos this.oComando.Connection =this.oConexion; //En CommandText se estipula el nombre del procedimiento almacenado this.oComando.CommandText ="ModificarEditorial"; /************************************************************************** En CommmandType se establece el tipo de consulta a ejecutar. Como es un procedimiento almacenado se coloca CommandType.StoredProcedure para especificar que es un procedimiento almacenado ***************************************************************************/ this.oComando.CommandType= CommandType.StoredProcedure; /************************************************************************** Definicion de los parametros del procedimiento almacenado GuardarAutor. Al final se le transfiere el valor que poseera cada parametro, para ello se le pasa el valor de la propiedad correspondiente de la clase. ***************************************************************************/ this.oComando.Parameters.Add (new SqlParameter ("@codigo",System.Data.SqlDbType.Char,10,ParameterDirection.Input,true,0,0,"",DataRowVersion.Current,this.strCodigoEditorial)); this.oComando.Parameters.Add (new SqlParameter ("@nombre",System.Data.SqlDbType.NVarChar,80,ParameterDirection.Input,true,0,0,"",DataRowVersion.Current ,this.strNombre)); this.oComando.Parameters.Add (new SqlParameter ("@direccion",System.Data.SqlDbType.NVarChar,100,ParameterDirection.Input,true,0,0,"",DataRowVersion.Current,this.strDireccion)); this.oComando.Parameters.Add (new SqlParameter ("@pais",System.Data.SqlDbType.NVarChar,50,ParameterDirection.Input,true,0,0,"",DataRowVersion.Current,this.strPais)); this.oComando.Parameters.Add (new SqlParameter ("@ciudad",System.Data.SqlDbType.NVarChar,50,ParameterDirection.Input,true,0,0,"",DataRowVersion.Current,this.strCiudad)); //Ejecutar el procedimiento almacenado.

Ing. Adolfo Machado.

//Si el valor retornado es distinto de cero la operacin ha tenido xito if(this.oComando.ExecuteNonQuery ()!=0) { System.Windows.Forms.MessageBox.Show ("Registro actualizado satisfactoriamente","Sistema de Automatizacin de Biblioteca",System.Windows.Forms.MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Information); Resultado=true; } else { System.Windows.Forms.MessageBox.Show ("Error en la operacin, operacin cancelada","Sistema de Automatizacin de Biblioteca",System.Windows.Forms.MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Error); Resultado=false; } this.oConexion.Close (); } else Resultado=false; } catch(Exception e) { //Muestra un mensaje si ocurre algun error interno System.Windows.Forms.MessageBox.Show(e.Message,"Sistema de Automatizacin de Biblioteca",System.Windows.Forms.MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Error); } return Resultado; } public void EliminarEditorial(string strCadenaConexion) { try { int resultado; //Se crea el objeto oConexion con la base de datos. Se le transfiere la cadena de conexion this.oConexion =new SqlConnection (strCadenaConexion + "initial catalog=Biblioteca"); //Abrir la conexion this.oConexion.Open (); //Crear el objeto oComando this.oComando =new SqlCommand(); //Se le tranfiere a oComando la conexion con la base de datos this.oComando.Connection =this.oConexion; //En CommandText se estipula el nombre del procedimiento almacenado this.oComando.CommandText ="EliminarEditorial"; /**************************************************************************

Universidad de Managua

Ing. Adolfo Machado.

10

En CommmandType se establece el tipo de consulta a ejecutar. Como es un procedimiento almacenado se coloca CommandType.StoredProcedure para especificar que es un procedimiento almacenado ***************************************************************************/ this.oComando.CommandType= CommandType.StoredProcedure;

Universidad de Managua

/************************************************************************** Definicion de los paramteros del procedimiento almacenado GuardarAutor. Al final se le transfiere el valor que poseera cada parametro, para ello se le pasa el valor de la propiedad correspondiente de la clase. ***************************************************************************/ this.oComando.Parameters.Add (new SqlParameter ("@codigo",System.Data.SqlDbType.Char,10,ParameterDirection.Input,true,0,0,"",DataRowVersion.Current,this.strCodigoEditorial)); //Ejecutar el procedimiento almacenado. //El valor retornado se almacena en la variable resultado resultado=this.oComando.ExecuteNonQuery (); if(resultado!=0) System.Windows.Forms.MessageBox.Show ("Registro eliminado satisfactoriamente","Sistema de Automatizacin de Biblioteca",System.Windows.Forms.MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Information); else System.Windows.Forms.MessageBox.Show ("Error en la operacin, operacin cancelada","Sistema de Automatizacin de Biblioteca",System.Windows.Forms.MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Error); } catch(Exception e) { //Muestra un mensaje si ocurre algun error interno System.Windows.Forms.MessageBox.Show(e.Message,"Sistema de Automatizacin de Biblioteca",System.Windows.Forms.MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Error); } } this.oConexion.Close ();

private bool ValidarDatos() { bool Resultado; if(this.strNombre =="") Resultado=false; else if(this.strDireccion =="") Resultado=false; else if(this.strPais =="") Resultado=false;

Ing. Adolfo Machado.

11

else if(this.strCiudad =="") Resultado=false; else Resultado=true; } } } return Resultado;

Universidad de Managua

Cdigo del Formulario: FrmEditorial. using using using using using using using System; System.Drawing; System.Collections; System.ComponentModel; System.Windows.Forms; System.Data; System.Data.SqlClient;

namespace SAB { /// <summary> /// Descripcin breve de FrmEditorial. /// </summary> public class FrmEditorial : System.Windows.Forms.Form { private System.Windows.Forms.Button CmdBuscar; private System.Windows.Forms.Button CmdEliminar; private System.Windows.Forms.Button CmdModificar; private System.Windows.Forms.Button CmdCancelar; private System.Windows.Forms.Button CmdGuardar; private System.Windows.Forms.Button CmdNuevo; private System.Windows.Forms.Button CmdUltimo; private System.Windows.Forms.Button CmdAnterior; private System.Windows.Forms.Button CmdSiguiente; private System.Windows.Forms.Button CmdInicio; private System.Windows.Forms.Button CmdCerrar; private System.Windows.Forms.GroupBox GrpInformacion; private System.Windows.Forms.Label LblIDEditorial; private System.Windows.Forms.TextBox TxtIDEditorial; private System.Windows.Forms.Label LblNombreEditorial; private System.Windows.Forms.TextBox TxtNombreEditorial; private System.Windows.Forms.Label LblDireccion;

Ing. Adolfo Machado.

12

private private private private private private private private

System.Windows.Forms.TextBox TxtDireccion; System.Windows.Forms.Label LblPais; System.Windows.Forms.TextBox TxtPais; System.Windows.Forms.Label LblCiudad; System.Windows.Forms.TextBox TxtCiudad; System.ComponentModel.IContainer components; System.Windows.Forms.Label LblMensaje; System.Windows.Forms.ToolTip toolTipMensaje;

Universidad de Managua

/********************************************** *Variables globales de conexion, acceso y * *almacenamiento de datos * ***********************************************/ System.Data.SqlClient.SqlConnection oConexion; System.Data.SqlClient.SqlDataAdapter oAdaptador; System.Data.DataSet oDatosEditorial; int Posicion, Temp; bool Modificar; string strCadenaConexion; public FrmEditorial() { // // Necesario para admitir el Diseador de Windows Forms // InitializeComponent(); // // TODO: agregar cdigo de constructor despus de llamar a InitializeComponent // } /// <summary> /// Limpiar los recursos que se estn utilizando. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); }

Ing. Adolfo Machado.

13

} base.Dispose( disposing );

Universidad de Managua

#region Cdigo generado por el Diseador de Windows Forms /// <summary> /// Mtodo necesario para admitir el Diseador. No se puede modificar /// el contenido del mtodo con el editor de cdigo. /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(FrmEditorial)); this.CmdBuscar = new System.Windows.Forms.Button(); this.CmdEliminar = new System.Windows.Forms.Button(); this.CmdModificar = new System.Windows.Forms.Button(); this.CmdCancelar = new System.Windows.Forms.Button(); this.CmdGuardar = new System.Windows.Forms.Button(); this.CmdNuevo = new System.Windows.Forms.Button(); this.CmdUltimo = new System.Windows.Forms.Button(); this.CmdAnterior = new System.Windows.Forms.Button(); this.CmdSiguiente = new System.Windows.Forms.Button(); this.CmdInicio = new System.Windows.Forms.Button(); this.GrpInformacion = new System.Windows.Forms.GroupBox(); this.TxtCiudad = new System.Windows.Forms.TextBox(); this.LblCiudad = new System.Windows.Forms.Label(); this.TxtPais = new System.Windows.Forms.TextBox(); this.LblPais = new System.Windows.Forms.Label(); this.TxtDireccion = new System.Windows.Forms.TextBox(); this.LblDireccion = new System.Windows.Forms.Label(); this.TxtNombreEditorial = new System.Windows.Forms.TextBox(); this.LblNombreEditorial = new System.Windows.Forms.Label(); this.TxtIDEditorial = new System.Windows.Forms.TextBox(); this.LblIDEditorial = new System.Windows.Forms.Label(); this.CmdCerrar = new System.Windows.Forms.Button(); this.LblMensaje = new System.Windows.Forms.Label(); this.toolTipMensaje = new System.Windows.Forms.ToolTip(this.components); this.GrpInformacion.SuspendLayout(); this.SuspendLayout(); // // CmdBuscar // this.CmdBuscar.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.CmdBuscar.Image = ((System.Drawing.Image)(resources.GetObject("CmdBuscar.Image"))); this.CmdBuscar.Location = new System.Drawing.Point(504, 41);

Ing. Adolfo Machado.

14

this.CmdBuscar.Name = "CmdBuscar"; this.CmdBuscar.Size = new System.Drawing.Size(80, 32); this.CmdBuscar.TabIndex = 20; this.toolTipMensaje.SetToolTip(this.CmdBuscar, "Buscar registro"); this.CmdBuscar.Click += new System.EventHandler(this.CmdBuscar_Click); // // CmdEliminar // this.CmdEliminar.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.CmdEliminar.Image = ((System.Drawing.Image)(resources.GetObject("CmdEliminar.Image"))); this.CmdEliminar.Location = new System.Drawing.Point(423, 41); this.CmdEliminar.Name = "CmdEliminar"; this.CmdEliminar.Size = new System.Drawing.Size(80, 32); this.CmdEliminar.TabIndex = 19; this.toolTipMensaje.SetToolTip(this.CmdEliminar, "Eliminar registro"); this.CmdEliminar.Click += new System.EventHandler(this.CmdEliminar_Click); // // CmdModificar // this.CmdModificar.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.CmdModificar.Image = ((System.Drawing.Image)(resources.GetObject("CmdModificar.Image"))); this.CmdModificar.Location = new System.Drawing.Point(342, 41); this.CmdModificar.Name = "CmdModificar"; this.CmdModificar.Size = new System.Drawing.Size(80, 32); this.CmdModificar.TabIndex = 18; this.toolTipMensaje.SetToolTip(this.CmdModificar, "Modificar registro"); this.CmdModificar.Click += new System.EventHandler(this.CmdModificar_Click); // // CmdCancelar // this.CmdCancelar.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.CmdCancelar.Image = ((System.Drawing.Image)(resources.GetObject("CmdCancelar.Image"))); this.CmdCancelar.Location = new System.Drawing.Point(504, 8); this.CmdCancelar.Name = "CmdCancelar"; this.CmdCancelar.Size = new System.Drawing.Size(80, 32); this.CmdCancelar.TabIndex = 17; this.toolTipMensaje.SetToolTip(this.CmdCancelar, "Cancelar operacin"); this.CmdCancelar.Click += new System.EventHandler(this.CmdCancelar_Click); // // CmdGuardar // this.CmdGuardar.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.CmdGuardar.Image = ((System.Drawing.Image)(resources.GetObject("CmdGuardar.Image"))); this.CmdGuardar.Location = new System.Drawing.Point(423, 8); this.CmdGuardar.Name = "CmdGuardar";

Universidad de Managua

Ing. Adolfo Machado.

15

this.CmdGuardar.Size = new System.Drawing.Size(80, 32); this.CmdGuardar.TabIndex = 16; this.toolTipMensaje.SetToolTip(this.CmdGuardar, "Guardar registro"); this.CmdGuardar.Click += new System.EventHandler(this.CmdGuardar_Click); // // CmdNuevo // this.CmdNuevo.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.CmdNuevo.Image = ((System.Drawing.Image)(resources.GetObject("CmdNuevo.Image"))); this.CmdNuevo.Location = new System.Drawing.Point(342, 8); this.CmdNuevo.Name = "CmdNuevo"; this.CmdNuevo.Size = new System.Drawing.Size(80, 32); this.CmdNuevo.TabIndex = 15; this.toolTipMensaje.SetToolTip(this.CmdNuevo, "Nuevo registro"); this.CmdNuevo.Click += new System.EventHandler(this.CmdNuevo_Click); // // CmdUltimo // this.CmdUltimo.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.CmdUltimo.Image = ((System.Drawing.Image)(resources.GetObject("CmdUltimo.Image"))); this.CmdUltimo.Location = new System.Drawing.Point(240, 41); this.CmdUltimo.Name = "CmdUltimo"; this.CmdUltimo.Size = new System.Drawing.Size(80, 32); this.CmdUltimo.TabIndex = 14; this.toolTipMensaje.SetToolTip(this.CmdUltimo, "Ir al ltimo registro"); this.CmdUltimo.Click += new System.EventHandler(this.CmdUltimo_Click); // // CmdAnterior // this.CmdAnterior.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.CmdAnterior.Image = ((System.Drawing.Image)(resources.GetObject("CmdAnterior.Image"))); this.CmdAnterior.Location = new System.Drawing.Point(159, 41); this.CmdAnterior.Name = "CmdAnterior"; this.CmdAnterior.Size = new System.Drawing.Size(80, 32); this.CmdAnterior.TabIndex = 13; this.toolTipMensaje.SetToolTip(this.CmdAnterior, "Ir al registro anterior"); this.CmdAnterior.Click += new System.EventHandler(this.CmdAnterior_Click); // // CmdSiguiente // this.CmdSiguiente.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.CmdSiguiente.Image = ((System.Drawing.Image)(resources.GetObject("CmdSiguiente.Image"))); this.CmdSiguiente.Location = new System.Drawing.Point(240, 8); this.CmdSiguiente.Name = "CmdSiguiente"; this.CmdSiguiente.Size = new System.Drawing.Size(80, 32);

Universidad de Managua

Ing. Adolfo Machado.

16

this.CmdSiguiente.TabIndex = 12; this.toolTipMensaje.SetToolTip(this.CmdSiguiente, "Ir al siguiente registro"); this.CmdSiguiente.Click += new System.EventHandler(this.CmdSiguiente_Click); // // CmdInicio // this.CmdInicio.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.CmdInicio.Image = ((System.Drawing.Image)(resources.GetObject("CmdInicio.Image"))); this.CmdInicio.Location = new System.Drawing.Point(159, 8); this.CmdInicio.Name = "CmdInicio"; this.CmdInicio.Size = new System.Drawing.Size(80, 32); this.CmdInicio.TabIndex = 11; this.toolTipMensaje.SetToolTip(this.CmdInicio, "Ir al primer registro"); this.CmdInicio.Click += new System.EventHandler(this.CmdInicio_Click); // // GrpInformacion // this.GrpInformacion.Controls.Add(this.TxtCiudad); this.GrpInformacion.Controls.Add(this.LblCiudad); this.GrpInformacion.Controls.Add(this.TxtPais); this.GrpInformacion.Controls.Add(this.LblPais); this.GrpInformacion.Controls.Add(this.TxtDireccion); this.GrpInformacion.Controls.Add(this.LblDireccion); this.GrpInformacion.Controls.Add(this.TxtNombreEditorial); this.GrpInformacion.Controls.Add(this.LblNombreEditorial); this.GrpInformacion.Controls.Add(this.TxtIDEditorial); this.GrpInformacion.Controls.Add(this.LblIDEditorial); this.GrpInformacion.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.GrpInformacion.ForeColor = System.Drawing.Color.Navy; this.GrpInformacion.Location = new System.Drawing.Point(8, 86); this.GrpInformacion.Name = "GrpInformacion"; this.GrpInformacion.Size = new System.Drawing.Size(576, 176); this.GrpInformacion.TabIndex = 21; this.GrpInformacion.TabStop = false; this.GrpInformacion.Text = "Informacin Editorial"; // // TxtCiudad // this.TxtCiudad.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(251)), ((System.Byte)(250)), ((System.Byte)(213))); this.TxtCiudad.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.TxtCiudad.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper; this.TxtCiudad.Font = new System.Drawing.Font("Lucida Console", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.TxtCiudad.Location = new System.Drawing.Point(128, 140);

Universidad de Managua

Ing. Adolfo Machado.

17

this.TxtCiudad.Name = "TxtCiudad"; this.TxtCiudad.Size = new System.Drawing.Size(248, 20); this.TxtCiudad.TabIndex = 9; this.TxtCiudad.Text = ""; this.TxtCiudad.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.TxtCiudad_KeyPress); // // LblCiudad // this.LblCiudad.Location = new System.Drawing.Point(24, 139); this.LblCiudad.Name = "LblCiudad"; this.LblCiudad.TabIndex = 8; this.LblCiudad.Text = "Ciudad:"; // // TxtPais // this.TxtPais.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(251)), ((System.Byte)(250)), ((System.Byte)(213))); this.TxtPais.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.TxtPais.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper; this.TxtPais.Font = new System.Drawing.Font("Lucida Console", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.TxtPais.Location = new System.Drawing.Point(128, 116); this.TxtPais.Name = "TxtPais"; this.TxtPais.Size = new System.Drawing.Size(248, 20); this.TxtPais.TabIndex = 7; this.TxtPais.Text = ""; this.TxtPais.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.TxtPais_KeyPress); // // LblPais // this.LblPais.Location = new System.Drawing.Point(24, 114); this.LblPais.Name = "LblPais"; this.LblPais.TabIndex = 6; this.LblPais.Text = "Pas:"; // // TxtDireccion // this.TxtDireccion.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(251)), ((System.Byte)(250)), ((System.Byte)(213))); this.TxtDireccion.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.TxtDireccion.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper; this.TxtDireccion.Font = new System.Drawing.Font("Lucida Console", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.TxtDireccion.Location = new System.Drawing.Point(128, 72); this.TxtDireccion.Multiline = true; this.TxtDireccion.Name = "TxtDireccion";

Universidad de Managua

Ing. Adolfo Machado.

18

this.TxtDireccion.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.TxtDireccion.Size = new System.Drawing.Size(440, 40); this.TxtDireccion.TabIndex = 5; this.TxtDireccion.Text = ""; this.TxtDireccion.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.TxtDireccion_KeyPress); // // LblDireccion // this.LblDireccion.Location = new System.Drawing.Point(24, 72); this.LblDireccion.Name = "LblDireccion"; this.LblDireccion.TabIndex = 4; this.LblDireccion.Text = "Direccin:"; // // TxtNombreEditorial // this.TxtNombreEditorial.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(251)), ((System.Byte)(250)), ((System.Byte)(213))); this.TxtNombreEditorial.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.TxtNombreEditorial.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper; this.TxtNombreEditorial.Font = new System.Drawing.Font("Lucida Console", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.TxtNombreEditorial.Location = new System.Drawing.Point(128, 48); this.TxtNombreEditorial.Name = "TxtNombreEditorial"; this.TxtNombreEditorial.Size = new System.Drawing.Size(440, 20); this.TxtNombreEditorial.TabIndex = 3; this.TxtNombreEditorial.Text = ""; this.TxtNombreEditorial.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.TxtNombreEditorial_KeyPress); // // LblNombreEditorial // this.LblNombreEditorial.Location = new System.Drawing.Point(24, 48); this.LblNombreEditorial.Name = "LblNombreEditorial"; this.LblNombreEditorial.TabIndex = 2; this.LblNombreEditorial.Text = "Nombre:"; // // TxtIDEditorial // this.TxtIDEditorial.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(251)), ((System.Byte)(250)), ((System.Byte)(213))); this.TxtIDEditorial.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.TxtIDEditorial.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper; this.TxtIDEditorial.Font = new System.Drawing.Font("Lucida Console", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.TxtIDEditorial.Location = new System.Drawing.Point(128, 24); this.TxtIDEditorial.Name = "TxtIDEditorial"; this.TxtIDEditorial.TabIndex = 1;

Universidad de Managua

Ing. Adolfo Machado.

19

this.TxtIDEditorial.Text = ""; // // LblIDEditorial // this.LblIDEditorial.Location = new System.Drawing.Point(24, 24); this.LblIDEditorial.Name = "LblIDEditorial"; this.LblIDEditorial.TabIndex = 0; this.LblIDEditorial.Text = "Id. Editorial:"; // // CmdCerrar // this.CmdCerrar.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.CmdCerrar.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.CmdCerrar.Image = ((System.Drawing.Image)(resources.GetObject("CmdCerrar.Image"))); this.CmdCerrar.Location = new System.Drawing.Point(504, 272); this.CmdCerrar.Name = "CmdCerrar"; this.CmdCerrar.Size = new System.Drawing.Size(80, 32); this.CmdCerrar.TabIndex = 22; this.toolTipMensaje.SetToolTip(this.CmdCerrar, "Cerrar"); this.CmdCerrar.Click += new System.EventHandler(this.CmdCerrar_Click); // // LblMensaje // this.LblMensaje.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.LblMensaje.ForeColor = System.Drawing.Color.Navy; this.LblMensaje.Location = new System.Drawing.Point(32, 272); this.LblMensaje.Name = "LblMensaje"; this.LblMensaje.Size = new System.Drawing.Size(256, 23); this.LblMensaje.TabIndex = 23; // // FrmEditorial // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(236)), ((System.Byte)(233)), ((System.Byte)(216))); this.ClientSize = new System.Drawing.Size(594, 312); this.Controls.Add(this.LblMensaje); this.Controls.Add(this.CmdCerrar); this.Controls.Add(this.GrpInformacion); this.Controls.Add(this.CmdBuscar); this.Controls.Add(this.CmdEliminar); this.Controls.Add(this.CmdModificar); this.Controls.Add(this.CmdCancelar); this.Controls.Add(this.CmdGuardar); this.Controls.Add(this.CmdNuevo);

Universidad de Managua

Ing. Adolfo Machado.

20

this.Controls.Add(this.CmdUltimo); this.Controls.Add(this.CmdAnterior); this.Controls.Add(this.CmdSiguiente); this.Controls.Add(this.CmdInicio); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MaximizeBox = false; this.Name = "FrmEditorial"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Registro de Editoriales"; this.Closing += new System.ComponentModel.CancelEventHandler(this.FrmEditorial_Closing); this.Load += new System.EventHandler(this.FrmEditorial_Load); this.GrpInformacion.ResumeLayout(false); this.ResumeLayout(false); } #endregion static void Main() { } private void Cargar() { try { this.oConexion =new SqlConnection (this.strCadenaConexion + "initial catalog=Biblioteca"); this.oConexion.Open (); this.oAdaptador =new SqlDataAdapter ("SELECT * FROM EDITORIAL ORDER BY IDEditorial ASC",this.oConexion ); this.oDatosEditorial =new System.Data.DataSet(); this.oAdaptador.Fill (this.oDatosEditorial,"EDITORIAL"); if(this.oDatosEditorial.Tables ["EDITORIAL"].Rows.Count !=0) this.Posicion=0; //Cerrar la conexion con la base de datos this.oConexion.Close(); //Liberar los recursos asignados a los objetos oConexion y oAdaptador this.oConexion.Dispose (); this.oAdaptador.Dispose ();

Universidad de Managua

} catch(Exception e) { System.Windows.Forms.MessageBox.Show (e.Message ,"Sistema de Automatizacin de

Ing. Adolfo Machado.

21

Biblioteca",System.Windows.Forms.MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Error ); } }

Universidad de Managua

private void Llenar() { try { System.Data.DataRow Fila; if(this.oDatosEditorial.Tables ["EDITORIAL"].Rows.Count !=0) { Fila=this.oDatosEditorial.Tables ["EDITORIAL"].Rows[this.Posicion]; this.Limpiar (); this.TxtIDEditorial.Text =Fila["IDEditorial"].ToString (); this.TxtNombreEditorial.Text =Fila["NombreEditorial"].ToString (); this.TxtDireccion.Text =Fila["Direccion"].ToString (); this.TxtPais.Text =Fila["Pais"].ToString (); this.TxtCiudad.Text =Fila["Ciudad"].ToString (); this.InhabilitarTexto (); this.HabilitarBotones (); this.LblMensaje.Text ="Registro: " + (this.Posicion+1) + " de " + this.oDatosEditorial.Tables["EDITORIAL"].Rows.Count; this.CmdGuardar.Enabled =false; this.CmdCancelar.Enabled =false; this.CmdNuevo.Focus (); } else { this.Limpiar (); this.InhabilitarBotones (); this.InhabilitarTexto (); this.LblMensaje.Text ="Resgistro: 0 de 0"; this.CmdNuevo.Enabled =true; this.CmdCerrar.Enabled =true; this.CmdNuevo.Focus (); } } catch(Exception e) { System.Windows.Forms.MessageBox.Show (e.Message ,"Sistema de Automatizacin de Biblioteca",System.Windows.Forms.MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Error ); } } private string GenerarCodigo() {

Ing. Adolfo Machado.

22

string NuevoCodigo; string Cadena1,Cadena2; System.Data.DataRow Fila; if(this.oDatosEditorial.Tables ["EDITORIAL"].Rows.Count>0) { Fila=this.oDatosEditorial.Tables ["EDITORIAL"].Rows[this.oDatosEditorial.Tables ["EDITORIAL"].Rows.Count -1]; Cadena1=(string)Fila["IDEditorial"]; Cadena2=Cadena1.Substring (1,5); CAgregarCeros Agregar=new CAgregarCeros (); NuevoCodigo=Agregar.ObtenerCadena (System.Convert.ToInt32 (Cadena2)+1,5); } else NuevoCodigo="00001"; } return NuevoCodigo;

Universidad de Managua

private int BuscarPosicion() { System.Data.DataRow FilaActual; string IDEditorial; int i; for(i=0;i<this.oDatosEditorial.Tables ["EDITORIAL"].Rows.Count -1;i++) { FilaActual=this.oDatosEditorial.Tables ["EDITORIAL"].Rows[i]; IDEditorial=(string)FilaActual["IDEditorial"]; if(IDEditorial.Trim ()==this.TxtIDEditorial.Text.Trim ()) break; } return i; } private void HabilitarTexto() { this.TxtIDEditorial.Enabled =true; this.TxtNombreEditorial.Enabled =true; this.TxtDireccion.Enabled =true; this.TxtPais.Enabled =true; this.TxtCiudad.Enabled =true; } private void InhabilitarTexto()

Ing. Adolfo Machado.

23

{ this.TxtIDEditorial.Enabled =false; this.TxtNombreEditorial.Enabled =false; this.TxtDireccion.Enabled =false; this.TxtPais.Enabled =false; this.TxtCiudad.Enabled =false;

Universidad de Managua

private void InhabilitarBotones() { this.CmdInicio.Enabled =false; this.CmdAnterior.Enabled =false; this.CmdSiguiente.Enabled =false; this.CmdUltimo.Enabled =false; this.CmdNuevo.Enabled =false; this.CmdGuardar.Enabled =false; this.CmdCancelar.Enabled =false; this.CmdModificar.Enabled =false; this.CmdEliminar.Enabled =false; this.CmdBuscar.Enabled =false; this.CmdCerrar.Enabled =false; } private void HabilitarBotones() { this.CmdInicio.Enabled =true; this.CmdAnterior.Enabled =true; this.CmdSiguiente.Enabled =true; this.CmdUltimo.Enabled =true; this.CmdNuevo.Enabled =true; this.CmdGuardar.Enabled =true; this.CmdCancelar.Enabled =true; this.CmdModificar.Enabled =true; this.CmdEliminar.Enabled =true; this.CmdBuscar.Enabled =true; this.CmdCerrar.Enabled =true; } private void Limpiar() { this.TxtIDEditorial.Text =""; this.TxtNombreEditorial.Text =""; this.TxtDireccion.Text =""; this.TxtPais.Text =""; this.TxtCiudad.Text ="";

Ing. Adolfo Machado.

24

} private void FrmEditorial_Load(object sender, System.EventArgs e) { this.Cargar (); this.Llenar (); } private void FrmEditorial_Closing(object sender, System.ComponentModel.CancelEventArgs e) { this.PrincipalLocal.NumeroFormularios--; this.PrincipalLocal.MnuEditoriales.Enabled =true; } private void CmdCerrar_Click(object sender, System.EventArgs e) { this.Cursor=Cursors.WaitCursor; this.Close (); this.Cursor=Cursors.Default; } private void CmdInicio_Click(object sender, System.EventArgs e) { this.Posicion =0; this.Llenar (); } private void CmdSiguiente_Click(object sender, System.EventArgs e) { if(this.Posicion==this.oDatosEditorial.Tables ["EDITORIAL"].Rows.Count -1) return; else { this.Posicion +=1; this.Llenar (); } }

Universidad de Managua

private void CmdAnterior_Click(object sender, System.EventArgs e) { if(this.Posicion==0) return; else {

Ing. Adolfo Machado.

25

} }

this.Posicion -=1; this.Llenar ();

Universidad de Managua

private void CmdUltimo_Click(object sender, System.EventArgs e) { this.Posicion =this.oDatosEditorial.Tables ["EDITORIAL"].Rows.Count -1; this.Llenar (); } private void CmdNuevo_Click(object sender, System.EventArgs e) { this.Limpiar (); this.InhabilitarBotones (); this.HabilitarTexto (); this.TxtIDEditorial.Enabled =false; this.CmdGuardar.Enabled =true; this.CmdCancelar.Enabled =true; this.Modificar =false; this.Temp =this.oDatosEditorial.Tables ["EDITORIAL"].Rows.Count - 1; this.TxtIDEditorial.Text ="E" + this.GenerarCodigo (); this.TxtNombreEditorial.Focus (); } private void CmdGuardar_Click(object sender, System.EventArgs e) { this.Cursor=Cursors.WaitCursor; if(this.Modificar) { CEditorial Editorial=new CEditorial (); Editorial.IDEditorial =this.TxtIDEditorial.Text.Trim (); Editorial.NombreEditorial =this.TxtNombreEditorial.Text.Trim (); Editorial.Direccion =this.TxtDireccion.Text.Trim (); Editorial.Pais =this.TxtPais.Text.Trim (); Editorial.Ciudad =this.TxtCiudad.Text.Trim (); if(Editorial.ModificarEditorial (this.strCadenaConexion)) { this.Cargar (); this.Posicion =this.Temp; this.Llenar (); this.Cursor=Cursors.Default; } else

Ing. Adolfo Machado.

26

Universidad de Managua
this.Cursor=Cursors.Default; System.Windows.Forms.MessageBox.Show ("Informacin de la editorial requerida incompleta" ,"Sistema de Automatizacin de Biblioteca",System.Windows.Forms.MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Error );

} } else {

CEditorial Editorial=new CEditorial (); Editorial.IDEditorial =this.TxtIDEditorial.Text.Trim (); Editorial.NombreEditorial =this.TxtNombreEditorial.Text.Trim (); Editorial.Direccion =this.TxtDireccion.Text.Trim (); Editorial.Pais =this.TxtPais.Text.Trim (); Editorial.Ciudad =this.TxtCiudad.Text.Trim (); if(Editorial.GuardarEditorial (this.strCadenaConexion)) { this.Cargar (); this.Posicion =this.Temp + 1; this.Llenar (); this.Cursor=Cursors.Default; } else { this.Cursor=Cursors.Default; System.Windows.Forms.MessageBox.Show ("Informacin de la editorial requerida incompleta" ,"Sistema de Automatizacin de Biblioteca",System.Windows.Forms.MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Error ); }

private void CmdCancelar_Click(object sender, System.EventArgs e) { this.Cargar (); this.Llenar (); } private void CmdModificar_Click(object sender, System.EventArgs e) { this.InhabilitarBotones (); this.HabilitarTexto (); this.TxtIDEditorial.Enabled =false; this.CmdGuardar.Enabled =true; this.CmdCancelar.Enabled =true; this.Modificar =true; this.Temp =this.Posicion;

Ing. Adolfo Machado.

27

this.TxtNombreEditorial.Focus (); }

Universidad de Managua

private void CmdEliminar_Click(object sender, System.EventArgs e) { if(System.Windows.Forms.MessageBox.Show ("Desea eliminar la editorial: " + this.TxtNombreEditorial.Text.Trim () + "?","Sistema de Automatizacin de Biblioteca",System.Windows.Forms.MessageBoxButtons.YesNo,System.Windows.Forms.MessageBoxIcon.Question)==DialogResult.Yes) { this.Cursor=Cursors.WaitCursor; CEditorial Editorial=new CEditorial (); Editorial.IDEditorial =this.TxtIDEditorial.Text; Editorial.EliminarEditorial (this.strCadenaConexion); this.Cargar (); this.Llenar (); this.Cursor=Cursors.Default; } } private void CmdBuscar_Click(object sender, System.EventArgs e) { System.Data.DataRow[] FilaBuscar; string Filtro; switch(System.Windows.Forms.MessageBox.Show ("Desea buscar por el ID de la Editorial?","Sistema de Automatizacin de Biblioteca",System.Windows.Forms.MessageBoxButtons.YesNoCancel,System.Windows.Forms.MessageBoxIcon.Question)) { case DialogResult.Yes: this.PrincipalLocal.Enabled =false; FrmInputBox InputBox=new FrmInputBox (ref PrincipalLocal,"Introduzca el ID de la Editorial"); InputBox.ShowDialog (); if(this.PrincipalLocal.ValorInputBox.Trim ()!="") { Filtro="IDEditorial LIKE '" + this.PrincipalLocal.ValorInputBox.Trim () + "%'"; FilaBuscar=this.oDatosEditorial.Tables ["EDITORIAL"].Select (Filtro); if (FilaBuscar.Length > 0) { this.TxtIDEditorial.Text =FilaBuscar[0]["IDEditorial"].ToString (); this.TxtNombreEditorial.Text =FilaBuscar[0]["NombreEditorial"].ToString (); this.TxtDireccion.Text =FilaBuscar[0]["Direccion"].ToString (); this.TxtPais.Text =FilaBuscar[0]["Pais"].ToString (); this.TxtCiudad.Text =FilaBuscar[0]["Ciudad"].ToString (); this.Posicion =this.BuscarPosicion (); this.LblMensaje.Text ="Registro: " + (this.Posicion+1) + " de " + this.oDatosEditorial.Tables ["EDITORIAL"].Rows.Count; System.Windows.Forms.MessageBox.Show ("El ID de Editorial: " + this.PrincipalLocal.ValorInputBox.Trim () + " ha sido

Ing. Adolfo Machado.

28

} else

encontrado","Sistema de Automatizacin de Biblioteca",System.Windows.Forms.MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Information);

Universidad de Managua

System.Windows.Forms.MessageBox.Show ("El ID de Editorial: " + this.PrincipalLocal.ValorInputBox.Trim () + sido encontrado","Sistema de Automatizacin de Biblioteca",System.Windows.Forms.MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Error);

" no ha

} break; case DialogResult.No: this.PrincipalLocal.Enabled =false; InputBox=new FrmInputBox (ref PrincipalLocal,"Introduzca el Nombre de la Editorial"); InputBox.ShowDialog (); if(this.PrincipalLocal.ValorInputBox.Trim ()!="") { Filtro="NombreEditorial LIKE '" + this.PrincipalLocal.ValorInputBox.Trim () + "%'"; FilaBuscar=this.oDatosEditorial.Tables ["EDITORIAL"].Select (Filtro); if (FilaBuscar.Length > 0) { this.TxtIDEditorial.Text =FilaBuscar[0]["IDEditorial"].ToString (); this.TxtNombreEditorial.Text =FilaBuscar[0]["NombreEditorial"].ToString (); this.TxtDireccion.Text =FilaBuscar[0]["Direccion"].ToString (); this.TxtPais.Text =FilaBuscar[0]["Pais"].ToString (); this.TxtCiudad.Text =FilaBuscar[0]["Ciudad"].ToString (); this.Posicion =this.BuscarPosicion (); this.LblMensaje.Text ="Registro: " + (this.Posicion+1) + " de " + this.oDatosEditorial.Tables ["EDITORIAL"].Rows.Count; System.Windows.Forms.MessageBox.Show ("Se ha encontrado coincidencia para la Editorial: " + this.PrincipalLocal.ValorInputBox.Trim (),"Sistema de Automatizacin de Biblioteca",System.Windows.Forms.MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Information); } else System.Windows.Forms.MessageBox.Show ("No se ha encontrado coincidencia para la Editorial: " + this.PrincipalLocal.ValorInputBox.Trim (),"Sistema de Automatizacin de Biblioteca",System.Windows.Forms.MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Information); } break; } }

private void TxtNombreEditorial_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if(e.KeyChar==(char)Keys.Enter) this.TxtDireccion.Focus (); }

Ing. Adolfo Machado.

29

Universidad de Managua
private void TxtDireccion_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if(e.KeyChar==(char)Keys.Enter) this.TxtPais.Focus (); } private void TxtPais_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if(e.KeyChar==(char)Keys.Enter) this.TxtCiudad.Focus (); else if((char.IsDigit (e.KeyChar )) || (char.IsSymbol (e.KeyChar ))) e.Handled =true; } private void TxtCiudad_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if(e.KeyChar==(char)Keys.Enter) this.CmdGuardar.Focus (); else if((char.IsDigit (e.KeyChar )) || (char.IsSymbol (e.KeyChar ))) e.Handled =true; }

} }

Ing. Adolfo Machado.

30

Você também pode gostar