예제 #1
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         if (string.IsNullOrEmpty(txtRazonSocial.Text))
         {
             txtRazonSocial.Focus();
             epProveedor.SetError(txtRazonSocial, "Campo obligatorio - ingrese razon social de su proveedor");
         }
         else if (string.IsNullOrEmpty(txtNumDoc.Text))
         {
             txtNumDoc.Focus();
             epProveedor.SetError(txtNumDoc, "Campo obligatorio - ingrese numero de RUC / DNI");
         }
         else if (string.IsNullOrEmpty(txtTelefono.Text))
         {
             txtTelefono.Focus();
             epProveedor.SetError(txtTelefono, "Campo obligatorio - ingrese numero de telèfono");
         }
         else
         {
             if (_isNew)
             {
                 bool rpta_add = NProveedor.Insertar(
                     txtRazonSocial.Text.Trim(),
                     cboTipoDoc.Text,
                     txtNumDoc.Text.Trim(),
                     txtTelefono.Text.Trim(),
                     txtCorreo.Text.Trim(),
                     txtDireccion.Text.Trim()
                     );
                 mensajeYes("Proveedor insertado correctamente");
                 Limpiar();
                 txtRazonSocial.Focus();
                 objNP.LIstarDataGridViewProveedor(frmListProveedor.MyFormListProv.dgvProveedor);
                 frmListProveedor.MyFormListProv.dgvProveedor.Refresh();
             }
             else
             {
                 bool rpta_update = NProveedor.Actualizar(
                     txtRazonSocial.Text.Trim(),
                     cboTipoDoc.Text,
                     txtNumDoc.Text.Trim(),
                     txtTelefono.Text.Trim(),
                     txtCorreo.Text.Trim(),
                     txtDireccion.Text.Trim(),
                     idProveedor
                     );
                 mensajeYes("Proveedor actualizado correctamente");
                 Limpiar();
                 txtRazonSocial.Focus();
                 _isNew = true;
                 objNP.LIstarDataGridViewProveedor(frmListProveedor.MyFormListProv.dgvProveedor);
                 frmListProveedor.MyFormListProv.dgvProveedor.Refresh();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error ...... ???", MessageBoxButtons.OK, MessageBoxIcon.Error);
         throw;
     }
 }