예제 #1
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         string respuesta = "";
         if (txtidCategoria.Text == "")
         {
             if (txtNombre.Text == string.Empty)
             {
                 Error.SetError(txtNombre, "Ingrese un nombre");
             }
             else
             {
                 respuesta = NCategoria.Insertar(txtNombre.Text.Trim(), txtDescripcion.Text.Trim());
                 if (respuesta.Equals("OK"))
                 {
                     this.Alert("Guardado exitosamente", FrmAlert.alertTypeEnum.Success);
                     this.Limpiar();
                     this.Listar();
                 }
                 else
                 {
                     FrmError.Confirmacion("Error", "Algo salió mal");
                 }
             }
         }
         else
         {
             if (txtNombre.Text == string.Empty || txtidCategoria.Text == string.Empty)
             {
                 Error.SetError(txtNombre, "Ingrese un nombre");
             }
             else
             {
                 respuesta = NCategoria.Actualizar(Convert.ToInt32(txtidCategoria.Text), this.nombreAnt, txtNombre.Text.Trim(), txtDescripcion.Text.Trim());
                 if (respuesta.Equals("OK"))
                 {
                     this.Alert("Actualizado exitosamente", FrmAlert.alertTypeEnum.Success);
                     this.Limpiar();
                     this.Listar();
                 }
                 else
                 {
                     FrmError.Confirmacion("Error", "Algo salió mal a");
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + ex.StackTrace);
     }
 }
예제 #2
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     //int rpta = 0;
     try
     {
         if (txtNombre.Text.Equals(""))
         {
             txtNombre.Focus();
             epCategoria.SetError(txtNombre, "Campo obligatorio - ingrese nombre de la categoria");
         }
         else
         {
             // error here change a negation
             if (isNew)
             {
                 int rpta_insert = NCategoria.Insertar(txtNombre.Text.Trim(), txtDescripcion.Text.Trim());
                 mensajeYes("Categoria insertado correctamente al registro");
                 Limpiar();
                 txtNombre.Focus();
                 objtNC.ListarDataGridViewCategoria(frmListCategoria.MyForm.dgvPresentacion);
                 frmListCategoria.MyForm.dgvPresentacion.Refresh();
             }
             else
             {
                 int rpta_update = NCategoria.Actualizar(txtNombre.Text.Trim(), txtDescripcion.Text.Trim(), idcategoria);
                 mensajeYes("Categoria actualizado correctamente al registro");
                 Limpiar();
                 txtNombre.Focus();
                 objtNC.ListarDataGridViewCategoria(frmListCategoria.MyForm.dgvPresentacion);
                 frmListCategoria.MyForm.dgvPresentacion.Refresh();
                 isNew = true;
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error.......... ???", MessageBoxButtons.OK, MessageBoxIcon.Error);
         MessageBox.Show(ex.Message + ex.StackTrace);
         throw;
     }
 }