private void TxtPorcentaje_Validating(object sender, CancelEventArgs e) { if (string.IsNullOrEmpty((TxtPorcentaje.Text))) { errorP1.SetError(TxtPorcentaje, "Debe ingresar el porcentaje."); TxtPorcentaje.Focus(); } else { errorP1.SetError(TxtPorcentaje, ""); } }
private void BtnGuardar_Click(object sender, EventArgs e) { if (TxtCodigo.Text == null || TxtCodigo.Text == "") { Alerta = new ClassToast(ClassColorAlerta.Alerta.Validado.ToString(), "ALERTA", "Ingresar código."); TxtCodigo.Focus(); return; } if (TxtCodigoReferencia.Text == null || TxtCodigoReferencia.Text == "") { Alerta = new ClassToast(ClassColorAlerta.Alerta.Validado.ToString(), "ALERTA", "Ingresar código referencia."); TxtCodigoReferencia.Focus(); return; } if (TxtPorcentaje.Text == null || TxtPorcentaje.Text == "") { Alerta = new ClassToast(ClassColorAlerta.Alerta.Validado.ToString(), "ALERTA", "Ingresar el procentaje."); TxtPorcentaje.Focus(); return; } if (Convert.ToDecimal(TxtPorcentaje.Text) <= 0) { Alerta = new ClassToast(ClassColorAlerta.Alerta.Validado.ToString(), "ALERTA", "Ingresar el procentaje mayor a cero."); TxtPorcentaje.Focus(); return; } FrmPregunta FrmGuardar = new FrmPregunta(); FrmGuardar.ShowDialog(); if (FrmGuardar.Estado == true) { CADRetencion Guardar = new CADRetencion(); Guardar.InsertRetencion(Convert.ToInt32(CbTipoRetencion.SelectedValue), CJ3, CJ4, CJ5, TxtCodigo.Text.ToUpper(), TxtCodigoReferencia.Text.ToUpper(), TxtDescripcion.Text.ToUpper(), Convert.ToDecimal(TxtPorcentaje.Text)); Alerta = new ClassToast(ClassColorAlerta.Alerta.Guardado.ToString(), "GUARDADO", "Registro guardado perfectamente."); TxtCodCuenta.Text = null; TxtCodigo.Text = null; TxtCodigoReferencia.Text = null; TxtCuenta.Text = null; TxtDescripcion.Text = null; TxtPorcentaje.Text = "0"; DgvLLenar = new ClassDgvRetencion(); DgvLLenar.GetRetencion(DgvDato, Convert.ToInt32(CbTipoRetencion.SelectedValue)); } }
public bool Validar() { bool retorno = true; if (string.IsNullOrEmpty((TxtNombre.Text))) { errorP1.SetError(TxtNombre, "Debe ingresar el nombre."); TxtNombre.Focus(); retorno = false; } else { errorP1.SetError(TxtNombre, ""); } if (string.IsNullOrEmpty((TxtNumero.Text))) { errorP1.SetError(TxtNumero, "Debe ingresar el número."); TxtNumero.Focus(); retorno = false; } else { errorP1.SetError(TxtNumero, ""); } if (string.IsNullOrEmpty((TxtPorcentaje.Text))) { errorP1.SetError(TxtPorcentaje, "Debe ingresar el porcentaje."); TxtPorcentaje.Focus(); retorno = false; } else { errorP1.SetError(TxtPorcentaje, ""); } return(retorno); }