//boton guardar private void btnGuardar_Click(object sender, EventArgs e) { try { string Rpta = ""; if (this.txtnombre.Text == string.Empty || this.txtapellidos.Text == string.Empty || txtUsuario.Text == string.Empty || txtContraseña.Text == string.Empty) { MensajeError("Falta ingresar algunos datos, serán remarcados"); errorIcono.SetError(txtnombre, "Ingrese un Valor"); errorIcono.SetError(txtapellidos, "Ingrese un Valor"); errorIcono.SetError(txtUsuario, "Ingrese un Valor"); errorIcono.SetError(txtContraseña, "Ingrese un Valor"); } else { if (this.IsNuevo) { Rpta = NTrabajador.Insertar(this.txtnombre.Text.Trim().ToUpper(), this.txtapellidos.Text.Trim().ToUpper(), cbsexo.Text, txtDireccion.Text, txttelefono.Text, txtEmail.Text, cbacceso.Text, txtUsuario.Text, txtContraseña.Text); } else { Rpta = NTrabajador.Editar(Convert.ToInt32(this.txtIdtrabajador.Text), this.txtnombre.Text.Trim().ToUpper(), this.txtapellidos.Text.Trim().ToUpper(), cbsexo.Text, txtDireccion.Text, txttelefono.Text, txtEmail.Text, cbacceso.Text, txtUsuario.Text, txtContraseña.Text); } if (Rpta.Equals("OK")) { if (this.IsNuevo) { this.MensajeOK("Insercion correcta"); } else { this.MensajeOK("Actualizacion correctar"); } } else { this.MensajeError(Rpta); } this.IsNuevo = false; this.IsEditar = false; this.Botones(); this.Limpiar(); this.Mostrar(); this.txtIdtrabajador.Text = ""; } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
private void btnGuardar_Click(object sender, EventArgs e) { try { string rpta = ""; if (this.txtNombre.Text == string.Empty || this.txtNumDocumento.Text == string.Empty || this.txtDireccion.Text == string.Empty || this.txtApellidos.Text == string.Empty || this.txtUsuario.Text == string.Empty || this.txtPassword.Text == string.Empty) { MensajeError("Falta Ingresar algunos datos, seran remarcados"); errorIcono.SetError(txtNombre, "Ingrese el nombre"); errorIcono.SetError(txtApellidos, "Ingrese los apellidos"); errorIcono.SetError(txtNumDocumento, "Ingrese el numero de documento"); errorIcono.SetError(txtDireccion, "Ingrese la direccion"); errorIcono.SetError(txtUsuario, "Ingrese el usuario"); errorIcono.SetError(txtPassword, "Ingrese el password"); } else { if (this.IsNuevo) { rpta = NTrabajador.Insertar(this.txtNombre.Text.Trim().ToUpper(), this.txtApellidos.Text.Trim().ToUpper(), this.cboxSexo.Text.Trim().ToUpper(), this.dtFechaNac.Value, this.txtNumDocumento.Text.Trim(), this.txtDireccion.Text.Trim(), this.txtTelefono.Text.Trim(), this.txtEmail.Text.Trim(), this.cboxAcceso.Text, this.txtUsuario.Text.Trim(), this.txtPassword.Text.Trim()); } else { rpta = NTrabajador.Editar(Convert.ToInt32(this.txtIdTrabajador.Text), this.txtNombre.Text.Trim().ToUpper(), this.txtApellidos.Text.Trim().ToUpper(), this.cboxSexo.Text.Trim().ToUpper(), this.dtFechaNac.Value, this.txtNumDocumento.Text.Trim(), this.txtDireccion.Text.Trim(), this.txtTelefono.Text.Trim(), this.txtEmail.Text.Trim(), this.cboxAcceso.Text, this.txtUsuario.Text.Trim(), this.txtPassword.Text.Trim()); } if (rpta.Equals("OK")) { if (this.IsNuevo) { MensajeOk("Se inserto de forma correcta el registro"); } else { MensajeOk("Se actualizo de forma correcta el registro"); } } else { MensajeError(rpta); } this.IsNuevo = false; this.IsEditar = false; this.Botones(); this.limpiar(); this.Mostrar(); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
//guardar private void BtnGuardar_Click(object sender, EventArgs e) { try { string rpta = ""; if (this.txtNombre.Text == string.Empty || this.txtApellidos.Text == string.Empty || this.cmbSexo.Text == string.Empty || this.dtFecha_nacimiento.Value.Year == DateTime.Now.Date.Year || this.txtNum_documento.Text == string.Empty || this.cmbAcceso.Text == string.Empty || this.txtUsuario.Text == string.Empty || this.txtPassword.Text == string.Empty) { MensajeError("Falta ingresar algunos datos,seran remarcados"); errorIcono.SetError(this.txtNombre, "Ingrese el nombre del trabajador"); errorIcono.SetError(this.txtApellidos, "Ingrese el apellido del trabajador"); errorIcono.SetError(this.cmbSexo, "seleccione e sexo del trabajador"); errorIcono.SetError(this.dtFecha_nacimiento, "seleccione la fecha de nacimiento del trabajador"); errorIcono.SetError(this.txtNum_documento, "Ingrese el numero de documento del trabajador"); errorIcono.SetError(this.cmbAcceso, "seleccione el tipo de acceso del trabajador"); errorIcono.SetError(this.txtUsuario, "Ingrese el nombre de usuario del trabajador"); errorIcono.SetError(this.txtNombre, "Ingrese el password del trabajador"); } else { if (this.isNuevo) //si es nuevo { //opcional txtNombre.Text.Trim.Upper rpta = NTrabajador.Insertar(this.txtNombre.Text, this.txtApellidos.Text, this.cmbSexo.Text, this.dtFecha_nacimiento.Value, this.txtNum_documento.Text, this.txtDireccion.Text, this.txtTelefono.Text, this.txtEmail.Text, this.cmbAcceso.Text, this.txtUsuario.Text, this.txtPassword.Text); } else { rpta = NTrabajador.Editar(Convert.ToInt32(this.txtIdtrabajador.Text), this.txtNombre.Text, this.txtApellidos.Text, this.cmbSexo.Text, this.dtFecha_nacimiento.Value, this.txtNum_documento.Text, this.txtDireccion.Text, this.txtTelefono.Text, this.txtEmail.Text, this.cmbAcceso.Text, this.txtUsuario.Text, this.txtPassword.Text); } if (rpta.Equals("Ok")) { if (this.isNuevo) { this.MensajeOk("Se inserto de forma correcta el registro"); } else { this.MensajeOk("Se actualizo de forma correcta el registro"); } } else { this.MensajeError(rpta); } //despues de editar o guardar dejarlos en false this.isNuevo = false; this.isEditar = false; this.Botones(); this.Limpiar(); this.Mostrar(); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
private void btnGuardar_Click(object sender, EventArgs e) { try { //La variable que almacena si se inserto //o se modifico la tabla string rpta = ""; if (this.txtNombre.Text == string.Empty || this.txtApellidos.Text == string.Empty || txtNum_Documento.Text == string.Empty || txtUsuario.Text == string.Empty || txtPassword.Text == string.Empty) { MensajeError("Falta ingresar algunos datos, serán remarcados"); errorIcono.SetError(txtNombre, "Ingrese un Valor"); errorIcono.SetError(txtApellidos, "Ingrese un Valor"); errorIcono.SetError(txtNum_Documento, "Ingrese un Valor"); errorIcono.SetError(txtUsuario, "Ingrese un Valor"); errorIcono.SetError(txtPassword, "Ingrese un Valor"); } else { if (this.IsNuevo) { //Vamos a insertar un Trabajador rpta = NTrabajador.Insertar(this.txtNombre.Text.Trim().ToUpper(), this.txtApellidos.Text.Trim().ToUpper(), cbSexo.Text, dtFechaNac.Value, txtNum_Documento.Text, txtDireccion.Text, txtTelefono.Text, txtEmail.Text, cbAcceso.Text, txtUsuario.Text, txtPassword.Text); } else { //Vamos a modificar un Trabajador rpta = NTrabajador.Editar(Convert.ToInt32(this.txtIdtrabajador.Text), this.txtNombre.Text.Trim().ToUpper(), this.txtApellidos.Text.Trim().ToUpper(), cbSexo.Text, dtFechaNac.Value, txtNum_Documento.Text, txtDireccion.Text, txtTelefono.Text, txtEmail.Text, cbAcceso.Text, txtUsuario.Text, txtPassword.Text); } //Si la respuesta fue OK, fue porque se modifico //o inserto el Trabajador //de forma correcta if (rpta.Equals("OK")) { if (this.IsNuevo) { this.MensajeOK("Se insertó de forma correcta el registro"); } else { this.MensajeOK("Se actualizó de forma correcta el registro"); } } else { //Mostramos el mensaje de error this.MensajeError(rpta); } this.IsNuevo = false; this.IsEditar = false; this.Botones(); this.Limpiar(); this.Mostrar(); this.txtIdtrabajador.Text = ""; } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
private void btnGuardar_Click(object sender, EventArgs e) { try { //Declaro una variable para evaluar si se insertó o modificó: string rpta = ""; //Voy a validar los datos. En éste caso, el campo Nombre no puede estar vacío. Los otros también. //string.Empty = quiere decir que está vacía: if (this.txtNombre.Text == string.Empty || this.txtApellidos.Text == string.Empty || this.txtNum_Documento.Text == string.Empty || this.txtDireccion.Text == string.Empty || this.txtUsuario.Text == string.Empty || this.txtPassword.Text == string.Empty) { MensajeError("Falta ingresar algunos datos, serán remarcados"); //Que el icono de error aparezca al costado de la caja de texto: txtNombre. errorIcono.SetError(txtNombre, "Ingrese un Valor"); errorIcono.SetError(txtApellidos, "Ingrese un Valor"); errorIcono.SetError(txtNum_Documento, "Ingrese un Valor"); errorIcono.SetError(txtDireccion, "Ingrese un Valor"); errorIcono.SetError(txtUsuario, "Ingrese un Valor"); errorIcono.SetError(txtPassword, "Ingrese un Valor"); } else { //El usuario quiere realizar un registro: if (this.IsNuevo) { //Se envían varios parámatros. //Trim: para borrar los espacios en blanco. //ToUpper: para convertir a mayúsculas. rpta = NTrabajador.Insertar(this.txtNombre.Text.Trim().ToUpper(), this.txtApellidos.Text.Trim().ToUpper(), this.cbSexo.Text, dtFechaNac.Value, txtNum_Documento.Text, txtDireccion.Text, txtTelefono.Text, txtEmail.Text, this.cbAcceso.Text, this.txtUsuario.Text, this.txtPassword.Text); } else { //Se envían varios parámatros. //Trim: para borrar los espacios en blanco. //ToUpper: para convertir a mayúsculas. rpta = NTrabajador.Editar(Convert.ToInt32(this.txtIdtrabajador.Text), this.txtNombre.Text.Trim().ToUpper(), this.txtApellidos.Text.Trim().ToUpper(), this.cbSexo.Text, dtFechaNac.Value, txtNum_Documento.Text, txtDireccion.Text, txtTelefono.Text, txtEmail.Text, cbAcceso.Text, this.txtUsuario.Text, this.txtPassword.Text); } //Esto es para la respuesta (rpta) de DProveedor, en el método insertar: //Equals: para comparar una cadena. if (rpta.Equals("OK")) //OK, es si se insertó o modificó. { //Recibo un OK del insertr, porque IsNuevo está en true en el if: if (this.IsNuevo) { this.MensajeOk("se insertó de forma correcta el registro"); } //Si no es Insertar(IsNuevo) es un editar: else { this.MensajeOk("se actualizó de forma correcta el registro"); } } //Si No recibo un OK: else { //rpta, es el que recibe los mensajes. this.MensajeError(rpta); } //Lo dejó en false, porque ya ingresé el registro: this.IsNuevo = false; this.IsEditar = false; this.Botones(); this.Limpiar(); //Para Mostrar actualizado nuestro datalistado: this.Mostrar(); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
private void btnGuardar_Click(object sender, EventArgs e) { try { //La variable que almacena si se inserto //o se modifico la tabla string Rpta = ""; if (this.txtNombre.Text == string.Empty || txtPassword.Text == string.Empty) { MensajeError("Falta ingresar algunos datos, serán remarcados"); errorIcono.SetError(txtNombre, "Ingrese un Valor"); errorIcono.SetError(txtPassword, "Ingrese un Valor"); } else if (!(email_bien_escrito(txtCorreo.Text))) { MensajeError("ERROR,ingrese un correo valido"); errorIcono.SetError(txtCorreo, "Ingrese un Valor"); } else { if (this.IsNuevo) { //Vamos a insertar un Trabajador //parametros en NTrabajador //Insertar(string Id_Trabajador, string Nombre_Trabajador, //string Direccion_Trabajador, string Sexo_Trabajador, //int Acceso_Trabajador, string Password_Trabajador, string Texto_Buscar) Rpta = NTrabajador.Insertar(this.txtIdtrabajador.Text.Trim().ToUpper(), this.txtNombre.Text.Trim().ToUpper(), txtDireccion.Text, cbSexo.Text, cbAcceso.SelectedIndex, txtPassword.Text, txtCorreo.Text.Trim().ToLower(), txtTelefono.Text); } else { //Vamos a modificar un Trabajador Rpta = NTrabajador.Editar(this.txtIdtrabajador.Text.Trim().ToUpper(), this.txtNombre.Text.Trim().ToUpper(), txtDireccion.Text, cbSexo.Text, cbAcceso.SelectedIndex, txtPassword.Text, txtCorreo.Text.Trim().ToLower(), txtTelefono.Text); } //Si la respuesta fue OK, fue porque se modifico //o inserto el Cliente //de forma correcta if (Rpta.Equals("OK")) { if (this.IsNuevo) { this.MensajeOK("Se insertó de forma correcta el registro"); } else { this.MensajeOK("Se actualizó de forma correcta el registro"); } } else { //Mostramos el mensaje de error this.MensajeError(Rpta); } this.IsNuevo = false; this.IsEditar = false; this.Botones(); this.Limpiar(); this.Mostrar(); this.txtIdtrabajador.Text = ""; } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
private void BtnGuardar_Click(object sender, EventArgs e) { try { string rpta = ""; if (this.txtNombre.Text == string.Empty || this.txtApellidos.Text == string.Empty || this.txtNDoc.Text == string.Empty || this.txtDireccion.Text == string.Empty || this.cbnAcceso.Text == string.Empty || this.txtPassword.Text == string.Empty ) { MensajeError("Falta ingresar datos, seran remarcados"); errorProviderIcono.SetError(txtNombre, "Ingrese un valor"); errorProviderIcono.SetError(txtNDoc, "Ingrese un valor"); errorProviderIcono.SetError(txtApellidos, "Ingrese un valor"); errorProviderIcono.SetError(txtDireccion, "Ingrese un valor"); } else { if (this.IsNuevo) { rpta = NTrabajador.Insertar(this.txtNombre.Text.Trim().ToUpper(), txtApellidos.Text, this.cbnSexo.Text, dateTimePickerFN.Value, txtNDoc.Text, txtDireccion.Text, txtTelefono.Text, txtEmail.Text, this.cbnAcceso.Text, txtUsuario.Text, txtPassword.Text); } else { rpta = NTrabajador.Editar(Convert.ToInt32(this.txtIdtrabajador.Text), this.txtNombre.Text.Trim().ToUpper(), txtApellidos.Text, this.cbnSexo.Text, dateTimePickerFN.Value, txtNDoc.Text, txtDireccion.Text, txtTelefono.Text, txtEmail.Text, this.cbnAcceso.Text, txtUsuario.Text, txtPassword.Text); } if (rpta.Equals("OK")) { if (this.IsNuevo) { this.MensajeOk("Se inserto correctamente"); } else { this.MensajeOk("se actualizo correctamente"); } } else { this.MensajeError(rpta); } this.IsNuevo = false; this.IsEditar = false; this.Botones(); this.limpiar(); this.Mostrar(); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
////------ BOTON GUARDAR ------------------------------------------------------------ private void btnGuardar_Click(object sender, EventArgs e) { try //Control de errores bien.... { //-->VALIDACION DE CAMPOS. NOTA en el curso de C# ví que esto se puede hacer en las propiedades GET/SET //---------------------------------------------------------------------------------------------------- string rpta = ""; //Controles que deben de tener valores obligatoriamente -- Si está vacía y como es un campo obligatorio, pues hay que meterlo //if (this.txtNombre.Text == string.Empty || this.txtIdCliente.Text == string.Empty || this.txtNumeroDocu.Text == string.Empty) if (this.txtNombreTraba.Text == string.Empty || this.txtcAcceso.Text == string.Empty || this.txtPassword.Text == string.Empty) { //--> MENSAJES A MOSTRAR SI LOS CAMPOS OBLIGATORIOS ESTUVIERAN VACIOS - Este metodo lo tengo en este mismo módulo MensajeError("Faltan por indicar datos, serán remarcados"); errorIcono.SetError(txtNombreTraba, "Indique el Nombre"); errorIcono.SetError(txtcAcceso, "Indique el usuario de acceso"); errorIcono.SetError(txtPassword, "Indique Contraseña"); } else //El textBox llega con valor, { if (this.IsNuevo) //Es un alta ?? { //-->Si tuvieramos que guardar una imagen, lo tratariamos de esta forma VIDEO 14 minuto 20 aprox: //---------------------------------------------------------------------- // System.IO.MemoryStream ms = new System.IO.MemoryStream(); // this.pxImagen.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Png); // byte[] imagen = ms.GetBuffer(); //-->Vamos a llamar al Metodo Insertar de la CapaNegocio enviandole los valores para insertar en la bb.dd //------------------------------------------------------------------------------------------------------- //Convert.ToDecimal(this.txtDescuento.Text), //Convert.ToString(this.txtCodPostal.Text), //this.dtFechaNac.Value, //this.txtBuscar.Text.Trim().ToUpper()); rpta = NTrabajador.Insertar(this.txtNombreTraba.Text.Trim().ToUpper(), this.txtApellidosTraba.Text.Trim().ToUpper(), this.txtcAcceso.Text.Trim().ToUpper(), //La password tal cual como este escrita sin convertir a mayúsculas //this.txtPassword.Text.Trim().ToUpper() this.txtPassword.Text.Trim(), this.txtUsuariol.Text.Trim().ToUpper() //this.txtBuscar.Text.Trim().ToUpper() ); } else //Es una modificacion { //-->Vamos a llamar al Metodo Editar de la CapaNegocio enviandole los valores rpta = NTrabajador.Editar(Convert.ToInt32(this.txtIdTraba.Text), this.txtNombreTraba.Text.Trim().ToUpper(), this.txtApellidosTraba.Text.Trim().ToUpper(), this.txtcAcceso.Text.Trim().ToUpper(), //La password tal cual como este escrita sin convertir a mayúsculas //this.txtPassword.Text.Trim().ToUpper() this.txtPassword.Text.Trim(), this.txtUsuariol.Text.Trim().ToUpper() ); } //-->Ahora vamos a ver si la operación tuvo éxito o no, el "OK" que estamos poniendo aquí es el que está // indicado en la CAPADATOS en los metodos // Insertar y Editar de esta forma : rpta = SqlCmd.ExecuteNonQuery() == 1 ? "OK" : "NO se Ingreso el Registro"; // Por eso pongo OK sino pondría lo que tuviera puesto... if (rpta.Equals("OK")) //Comparando cadenas con : Equals() { if (this.IsNuevo) { this.MensajeOk("Se Insertó de forma correcta el registro"); } else { this.MensajeOk("Se Actualizó de forma correcta el registro"); } } else //Si no han tenido éxito la inserción o modificacion ERROR { //-->Vamos a enviar al error el valor de rpta que va a ser lo que tengo puesto en la CAPADATOS this.MensajeError(rpta); } //Borra la pelotilla del error si estuviera errorIcono.Clear(); //->Una vez insertado el registro dejamos las variables como estaban. this.IsNuevo = false; this.IsEditar = false; this.Botones(); this.Limpiar(); this.Mostrar(); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
private void BtnGuardar_Click(object sender, EventArgs e) { try { string rpta = ""; if (this.txtNombre.Text == string.Empty || this.txtNum_Documento.Text == string.Empty || this.txtDireccion.Text == string.Empty || this.txtUsuario.Text == string.Empty || this.txtPassword.Text == string.Empty) { MensajeError("Faltan ingresar datos"); errorIcono.SetError(txtNombre, "Ingrese la Razon Social"); errorIcono.SetError(txtNum_Documento, "Ingrese un Numero de Documento"); errorIcono.SetError(txtDireccion, "Ingrese la Direccion"); errorIcono.SetError(txtUsuario, "Ingrese un Usuario"); errorIcono.SetError(txtPassword, "Ingrese un Password"); } else { if (this.IsNuevo) { rpta = NTrabajador.Insertar(this.txtNombre.Text.Trim().ToUpper(), this.txtApellidos.Text, this.cmbSexo.Text, this.dtpFechaNacimiento.Value, txtNum_Documento.Text, txtDireccion.Text, txtTelefono.Text, txtEmail.Text, this.cmbAcceso.Text, this.txtUsuario.Text, this.txtPassword.Text); } else { rpta = NTrabajador.Editar(Convert.ToInt32(this.txtIdTrabajador.Text), this.txtNombre.Text.Trim().ToUpper(), this.txtApellidos.Text, this.cmbSexo.Text, this.dtpFechaNacimiento.Value, txtNum_Documento.Text, txtDireccion.Text, txtTelefono.Text, txtEmail.Text, this.cmbAcceso.Text, this.txtUsuario.Text, this.txtPassword.Text); } } if (rpta.Equals("ok")) { if (this.IsNuevo) { this.MensajeOk("Se inserto correctamente el registro"); } else { this.MensajeOk("Se actualizo correctamente el registro"); } } else { this.MensajeError(rpta); } this.IsNuevo = false; this.IsEditar = false; this.Botones(); this.Limpiar(); this.Mostrar(); } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
private void btnGuardar_Click(object sender, EventArgs e) { try { string rpta = ""; if (this.txtNombre.Text == string.Empty || this.txtApellido.Text == string.Empty || this.txtNumDocumento.Text == string.Empty || this.txtDireccion.Text == string.Empty || this.txtUsuario.Text == string.Empty || this.txtPassword.Text == string.Empty) { MensajeError("Falta Ingresar Ingresar"); errorIcono.SetError(txtNombre, "Ingrese un Valor"); errorIcono.SetError(txtApellido, "Ingrese un Valor"); errorIcono.SetError(txtDireccion, "Ingrese un Valor"); errorIcono.SetError(txtNumDocumento, "Ingrese un Valor"); errorIcono.SetError(txtUsuario, "Ingrese un Usuario"); errorIcono.SetError(txtPassword, "Ingrese un Password"); } else { if (this.isNuevo) { rpta = NTrabajador.Insertar(this.txtNombre.Text.Trim().ToUpper(), this.txtApellido.Text.Trim().ToUpper(), this.cbSexo.Text, this.dtFechaNac.Value, txtNumDocumento.Text.Trim().ToUpper(), txtDireccion.Text.Trim().ToUpper(), txtTelefono.Text.Trim().ToUpper(), txtEmail.Text.Trim().ToUpper(), this.cbAcceso.Text, this.txtUsuario.Text.Trim(), this.txtPassword.Text); } else { rpta = NTrabajador.Editar(Convert.ToInt32(this.txtIdTrabajador.Text), this.txtNombre.Text.Trim().ToUpper(), this.txtApellido.Text.Trim().ToUpper(), this.cbSexo.Text, this.dtFechaNac.Value, txtNumDocumento.Text.Trim().ToUpper(), txtDireccion.Text.Trim().ToUpper(), txtTelefono.Text.Trim().ToUpper(), txtEmail.Text.Trim().ToUpper(), this.cbAcceso.Text, this.txtUsuario.Text.Trim(), this.txtPassword.Text); } if (rpta.Equals("OK")) { if (this.isNuevo) { this.MensajeOk("Se Inserto el Registro"); } else { this.MensajeOk("Se Actualizo el Registro"); } } else { this.MensajeError(rpta); } this.isNuevo = false; this.isEditar = false; this.HabilitarBotones(); this.Limpiar(); this.Mostrar(); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
private void Guardar() { try { string rpta = ""; string sexo = ""; DateTime fecNac; if (this.cbCargo.SelectedIndex == -1) { MensajeError("Seleccione un cargo"); errorIcono.SetError(cbCargo, "Seleccionar cargo"); } else if (this.txtNombre.Text.Trim() == string.Empty) { MensajeError("Ingrese el nombre del trabajador"); errorIcono.SetError(txtNombre, "Ingrese el nombre"); } else if (this.txtApellidos.Text.Trim() == string.Empty) { MensajeError("Ingrese los apellidos del trabajador"); errorIcono.SetError(txtApellidos, "Ingrese el nombre"); } else if (this.cbTipoDoc.SelectedIndex == -1) { MensajeError("Seleccione un tipo de documento"); errorIcono.SetError(cbTipoDoc, "Seleccionar tipo"); } else if (this.txtNumDoc.Text.Trim() == string.Empty) { MensajeError("Ingrese el número de documento"); errorIcono.SetError(txtNumDoc, "Ingrese el número de documento"); } else if (this.rbMasculino.Checked == false && this.rbFemenino.Checked == false) { MensajeError("Seleccione el sexo"); errorIcono.SetError(rbMasculino, "Seleccionar"); } else if (this.txtFechaNac.Text.Trim() == string.Empty) { MensajeError("Seleccione la fecha de Nacimiento"); errorIcono.SetError(txtFechaNac, "Seleccione la fecha de nacimiento"); } else if (this.txtDireccion.Text.Trim() == string.Empty) { MensajeError("Ingrese la dirección del trabajador"); errorIcono.SetError(txtDireccion, "Ingrese la dirección"); } else if (this.txtTelefono.Text.Trim() == string.Empty) { MensajeError("Ingrese el telefono del trabajador"); errorIcono.SetError(txtTelefono, "Ingrese el telefono"); } else { if (this.txtFechaNac.Text == "") { fecNac = DateTime.MinValue; } else { fecNac = Convert.ToDateTime(this.txtFechaNac.Text); } if (this.rbMasculino.Checked == true) { sexo = "M"; } else { sexo = "F"; } if (this.IsNuevo) { rpta = NTrabajador.Insertar(this.txtNombre.Text.Trim().ToUpper(), this.txtApellidos.Text.Trim().ToUpper(), this.cbTipoDoc.SelectedItem.ToString(), this.txtNumDoc.Text.Trim(), sexo, fecNac, this.txtDireccion.Text.Trim(), this.txtTelefono.Text.Trim(), this.txtEmail.Text.Trim(), "A", Convert.ToInt32(this.cbCargo.SelectedValue.ToString()), this.txtUsuario.Text.Trim(), this.txtPass.Text.Trim()); } else { rpta = NTrabajador.Editar(Convert.ToInt32(this.txtIdTrabajador.Text), this.txtNombre.Text.Trim().ToUpper(), this.txtApellidos.Text.Trim().ToUpper(), this.cbTipoDoc.SelectedItem.ToString(), this.txtNumDoc.Text.Trim(), sexo, fecNac, this.txtDireccion.Text.Trim(), this.txtTelefono.Text.Trim(), this.txtEmail.Text.Trim(), "A", Convert.ToInt32(this.cbCargo.SelectedValue.ToString()), this.txtUsuario.Text.Trim(), this.txtPass.Text.Trim()); } if (rpta.Equals("OK")) { if (this.IsNuevo) { this.MensajeOK("Se insertó correcatamente"); } else { this.MensajeOK("Se actualizó correctamente"); } } else { this.MensajeError(rpta); } this.IsNuevo = false; this.IsEditar = false; this.Botones(); this.Limpiar(); this.Mostrar(); this.tabControl2.SelectedIndex = 0; } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
private void btnGuardar_Click_1(object sender, EventArgs e) { try { string rpta = ""; if (this.txtnombre.Text == string.Empty || this.txtNumDocument.Text == string.Empty || this.txtApellido.Text == string.Empty || this.txtDireccion.Text == string.Empty || this.txtUsuario.Text == string.Empty || this.txtPassword.Text == string.Empty) { MensajeError("Incorrectos datos, ingresar bien"); errorIcono.SetError(txtnombre, "Ingrese un Valor"); errorIcono.SetError(txtApellido, "Ingrese un Valor"); errorIcono.SetError(txtNumDocument, "Ingrese un Valor"); errorIcono.SetError(txtDireccion, "Ingrese un Valor"); errorIcono.SetError(txtPassword, "Ingrese un Valor"); errorIcono.SetError(txtUsuario, "Ingrese un Valor"); } else { if (this.IsNuevo) { rpta = NTrabajador.Insertar(this.txtnombre.Text.Trim().ToUpper(), this.txtApellido.Text.Trim().ToUpper(), this.cbsexo.Text, dtFechaNac.Value, txtNumDocument.Text, txtDireccion.Text, txtTelefono.Text, txtEmail.Text, this.cbAcceso.Text, this.txtUsuario.Text, this.txtPassword.Text) ; } else { rpta = NTrabajador.Editar(Convert.ToInt32(this.txtidtrabajador.Text), this.txtnombre.Text.Trim().ToUpper(), this.txtApellido.Text.Trim().ToUpper(), this.cbsexo.Text, dtFechaNac.Value, txtNumDocument.Text, txtDireccion.Text, txtTelefono.Text, txtEmail.Text, this.cbAcceso.Text, this.txtUsuario.Text, this.txtPassword.Text); } } if (rpta.Equals("OK")) { if (this.IsNuevo) { this.MensajeOk("Se ingreso correctamente."); } else { this.MensajeOk("Se actualizo."); } } else { this.MensajeError(rpta); } this.IsNuevo = false; this.IsEditar = false; this.Botones(); this.Limpiar(); this.Mostrar(); } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
private void Guardarbutton_Click(object sender, EventArgs e) { try { string respuesta = string.Empty; //valido los campos: if (this.NombretextBox.Text == string.Empty || this.NumeroDocumentotextBox.Text == string.Empty || this.ApellidostextBox.Text == string.Empty || this.DirecciontextBox.Text == string.Empty || this.UsuariotextBox.Text == string.Empty || this.PasswordtextBox.Text == string.Empty) { MensajeError("Falta ingresar algunos datos, serán remarcados."); ErrorIconoerrorProvider.SetError(this.NombretextBox, "Ingrese un Valor....."); ErrorIconoerrorProvider.SetError(this.NumeroDocumentotextBox, "Ingrese un Valor....."); ErrorIconoerrorProvider.SetError(this.DirecciontextBox, "Ingrese un Valor....."); ErrorIconoerrorProvider.SetError(this.ApellidostextBox, "Ingrese un Valor....."); ErrorIconoerrorProvider.SetError(this.UsuariotextBox, "Ingrese un Valor....."); ErrorIconoerrorProvider.SetError(this.PasswordtextBox, "Ingrese un Valor....."); } else { if (this.IsNuevo) { respuesta = NTrabajador.Insertar( this.NombretextBox.Text.Trim().ToUpper(), this.ApellidostextBox.Text.Trim().ToUpper(), this.SexocomboBox.Text, this.fechaNacimientodateTimePicker.Value, this.NumeroDocumentotextBox.Text, this.DirecciontextBox.Text, this.TelefonotextBox.Text, this.EmailtextBox.Text, this.accesocomboBox.Text, this.UsuariotextBox.Text, this.PasswordtextBox.Text ); } else { respuesta = NTrabajador.Editar(Convert.ToInt32(IdTrabajadortextBox.Text), this.NombretextBox.Text.Trim().ToUpper(), this.ApellidostextBox.Text.Trim().ToUpper(), this.SexocomboBox.Text, this.fechaNacimientodateTimePicker.Value, this.NumeroDocumentotextBox.Text, this.DirecciontextBox.Text, this.TelefonotextBox.Text, this.EmailtextBox.Text, this.accesocomboBox.Text, this.UsuariotextBox.Text, this.PasswordtextBox.Text ); } if (respuesta.Equals("OK")) { if (this.IsNuevo) { this.MensajeOK("Se Insertó de forma correcta el Registro....."); } else { this.MensajeOK("Se Actualizó de forma correcta el Registro....."); } } else { this.MensajeError(respuesta); } this.IsNuevo = false; this.IsEditar = false; this.Botones(); this.Limpiar(); this.Mostrar(); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
private void btnGuardar_Click(object sender, EventArgs e) { try { string rpta = ""; if (this.txtNombre.Text == string.Empty || this.txtApellidos.Text == string.Empty || this.txtNum_Documento.Text == string.Empty || this.txtDireccion.Text == string.Empty || this.txtUsuario.Text == string.Empty || this.txtPassword.Text == string.Empty) { MensajeError("Falta ingresar algunos datos,serán remarcados"); errorIcono.SetError(txtNombre, "Ingrese un Valor"); errorIcono.SetError(txtApellidos, "Ingrese un Valor"); errorIcono.SetError(txtNum_Documento, "Ingrese un Valor"); errorIcono.SetError(txtDireccion, "Ingrese un Valor"); errorIcono.SetError(txtUsuario, "Ingrese un Valor"); errorIcono.SetError(txtPassword, "Ingrese un Valor"); } else { if (this.IsNuevo) { rpta = NTrabajador.Insertar(this.txtNombre.Text.Trim().ToUpper(), this.txtApellidos.Text.Trim().ToUpper(), txtNum_Documento.Text, txtDireccion.Text, txtTelefono.Text, txtCorreo.Text, this.cbAcceso.Text, this.txtUsuario.Text, this.txtPassword.Text); } else { rpta = NTrabajador.Editar(Convert.ToInt32(this.txtIdtrabajador.Text), this.txtNombre.Text.Trim().ToUpper(), this.txtApellidos.Text.Trim().ToUpper(), txtNum_Documento.Text, txtDireccion.Text, txtTelefono.Text, txtCorreo.Text, this.cbAcceso.Text, this.txtUsuario.Text, this.txtPassword.Text); } if (rpta.Equals("OK")) { if (this.IsNuevo) { this.MensajeOK("Se Inserto de forma correcta el registro"); } else { this.MensajeOK("Se Actualizó de forma correcta el registro"); } } else { this.MensajeError(rpta); } this.IsNuevo = false; this.IsEditar = false; this.Botones(); this.Limpiar(); this.Mostrar(); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }