private void btnGuardar_Click(object sender, EventArgs e) { try { string rpta = ""; if (this.txtNombre.Text == string.Empty) { MensajeError("Falta ingresar algunos datos, serán remarcados"); errorIcono.SetError(txtNombre, "Ingrese un Nombre"); } else { if (this.IsNuevo) { rpta = NPresentacion.Insertar(this.txtNombre.Text.Trim().ToUpper(), this.txtDescripcion.Text.Trim()); } else { rpta = NPresentacion.Editar(Convert.ToInt32(this.txtIdpresentacion.Text), this.txtNombre.Text.Trim().ToUpper(), this.txtDescripcion.Text.Trim()); } 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 { 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 (txtNombre.Text == string.Empty) { MensajeError("Falta ingresar algunos datos,seran remarcados"); erroricono.SetError(txtNombre, "debes ingresar un nombre"); } else { if (this.IsNuevo) { //metodo trim es para borrar los espacios rpta = NPresentacion.Insertar(this.txtNombre.Text.Trim().ToUpper(), this.txtDescripcion.Text.Trim()); } else { //hacemos una conversion porque en nuestra base de datos el campo IDcategoria en un 'Int' rpta = NPresentacion.Editar(Convert.ToInt32(txtIdpresentacion.Text), this.txtNombre.Text.Trim().ToUpper(), this.txtDescripcion.Text.Trim()); } //equals espara comparar una cadena if (rpta.Equals("OK")) { if (this.IsNuevo) { this.Mensajeok("Se inserto un nuevo registro"); } else { this.Mensajeok("Se modifico un registro exitosamente"); } } else { this.MensajeError(rpta); //respuesta nos de el resultado de la varibale rpta de la clase Ncategoria } this.IsNuevo = false; this.IsEditar = false; this.Botones(); this.Limpiar(); this.Mostar(); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace);//mostrar el posible error } }
private void btnGuardar_Click(object sender, EventArgs e) { try { string rpta = ""; if (this.txtNombre.Text == string.Empty) { MensajeError("Incorrectos datos, ingresar bien"); errorIcono.SetError(txtNombre, "Ingrese un Nombre"); } else { if (this.IsNuevo) { rpta = NPresentacion.Insertar(this.txtNombre.Text.Trim().ToUpper(), this.txtDescripcion.Text.Trim()); } else { rpta = NPresentacion.Editar(Convert.ToInt32(this.txtidpresentacion.Text), this.txtNombre.Text.Trim().ToUpper(), this.txtDescripcion.Text.Trim()); } } 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) { MensajeError("Falta ingresar algunos datos, serán remarcados."); ErrorIconoerrorProvider.SetError(NombretextBox, "Ingrese Nombre....."); } else { if (this.IsNuevo) { respuesta = NPresentacion.Insertar(this.NombretextBox.Text.Trim().ToUpper(), this.DescripciontextBox.Text.Trim().ToUpper()); } else { respuesta = NPresentacion.Editar(Convert.ToInt32(IdPresentaciontextBox.Text), NombretextBox.Text.Trim().ToUpper(), DescripciontextBox.Text.Trim().ToUpper()); } 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) { MensajeError("Falta el Nombre"); errorProvider1.SetError(txtNombre, "Ingrese el Nombre"); } else { if (this.IsNuevo) { rpta = NPresentacion.Insertar(this.txtNombre.Text.Trim().ToUpper(), this.txtDescripcion.Text.Trim().ToUpper()); } else { rpta = NPresentacion.Editar(Convert.ToInt32(txtIdPresentacion.Text), this.txtNombre.Text.Trim().ToUpper(), this.txtDescripcion.Text.Trim().ToUpper()); } if (rpta.Equals("Ok")) { if (this.IsNuevo) { this.MensajeOK("Se inserto el registro correctamente"); } else { this.MensajeOK("Editado 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); } }
private void BtnGuardar_Click(object sender, EventArgs e) { try { string rpta = ""; if (this.txtNombre.Text == string.Empty) { MensajeError("Falta ingresar algunos datos,seran remarcados"); errorIcono.SetError(txtNombre, "Ingrese un nombre"); } else //si no esta vacias las cajas { if (this.isNuevo) //si es nuevo { //opcional txtNombre.Text.Trim.Upper rpta = NPresentacion.Insertar(txtNombre.Text, txtDescripcion.Text); } else { rpta = NPresentacion.Editar(Convert.ToInt32(this.txtIdpresentacion.Text), txtNombre.Text, txtDescripcion.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 { string rpta = ""; if (this.txtNombre.Text == string.Empty) { MensajeError("falta ingresar el nombre del alumno,seran remarcados"); errorIcono.SetError(txtNombre, "ingrese el nombre "); } else { if (this.isNuevo) { rpta = NPresentacion.Insertar(this.txtNombre.Text.Trim().ToUpper(), this.txtDescripcion.Text.Trim()); } else { rpta = NPresentacion.Editar(Convert.ToInt32(this.txtIdPresentacion.Text), this.txtNombre.Text.Trim().ToUpper(), this.txtDescripcion.Text.TrimEnd()); } 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); } }
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: //string.Empty = quiere decir que está vacía: if (this.txtNombre.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 Nombre"); } else { //El usuario quiere realizar un registro: if (this.IsNuevo) { //Se envían 2 parámatros: txtNombre, para enviar el nombre. Y descripción. //Trim: para borrar los espacios en blanco. //ToUpper: para convertir a mayúsculas. rpta = NPresentacion.Insertar(this.txtNombre.Text.Trim().ToUpper(), this.txtDescripcion.Text.Trim()); } else { //Se envían 3 parámatros. //Como es un string: this.txtIdpresentacion.Text, lo paso a un int: Convert.ToInt32 //Trim: para borrar los espacios en blanco. //ToUpper: para convertir a mayúsculas. rpta = NPresentacion.Editar(Convert.ToInt32(this.txtIdpresentacion.Text), this.txtNombre.Text.Trim().ToUpper(), this.txtDescripcion.Text.Trim()); } //Esto es para la respuesta (rpta) de DCategoria, 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); } }