private void CargarEmpresas() { try { var lstBeEmpresa = new BD.Empresa().Listar(); this.cboEmpresa.DataSource = lstBeEmpresa; this.cboEmpresa.DisplayMember = "Nombre"; this.cboEmpresa.ValueMember = "Id"; this.cboEmpresa.SelectedIndex = 0; } catch (Exception ex) { throw ex; } }
private void CargarSociedades() { try { var lstBeEmpresas = new BD.Empresa().Listar(); var beEmpresa = new BE.Empresa(); beEmpresa.Id = 0; beEmpresa.Nombre = "Todos"; lstBeEmpresas.Insert(0, beEmpresa); this.cboSociedades.DataSource = lstBeEmpresas; this.cboSociedades.DisplayMember = "Nombre"; this.cboSociedades.ValueMember = "Id"; this.cboSociedades.SelectedIndex = 0; } catch (Exception ex) { throw ex; } }
private void btnEnviar_Click(object sender, EventArgs e) { try { this.btnEnviar.Enabled = false; this.stlMensaje.Text = string.Empty; if (this.dgvDocumentosError.CurrentRow == null) { return; } var uiDocumento = (Documento)this.dgvDocumentosError.CurrentRow.DataBoundItem; if (uiDocumento.Estado != ERROR) { return; } int errCode = 0; string errMessage = ""; var beEmpresa = new BD.Empresa().Obtener(uiDocumento.EmpresaId); var beConfiguracion = new BD.Configuracion().Obtener(beEmpresa); string server = beConfiguracion.Servidor; string licenseServer = beConfiguracion.LicenciaSAP; string companyDB = beConfiguracion.BaseDatos; string dbUserName = beConfiguracion.UsuarioBD; string dbPassword = beConfiguracion.ClaveBD; string userName = beConfiguracion.UsuarioSAP; string password = beConfiguracion.ClaveSAP; this.stlMensaje.Text = $"Conectando al SBO de la compañia { beConfiguracion.Empresa.Nombre }"; using (var sbo = new DI.DiConexion(server, licenseServer, companyDB, dbUserName, dbPassword, userName, password)) { var sapBd = new BD.Sap(server, companyDB, dbUserName, dbPassword); var errorBd = new BD.Error(); switch (uiDocumento.TipoId) { case SALIDA: // "Salida de Almacen": var bdSalida = new BD.SalidaAlmacen(); var beSalida = bdSalida.Obtener(uiDocumento.Id); if (beSalida != null) { var seSalida = TD.BeToSe.SalidaAlmacen(beSalida); this.stlMensaje.Text = $"Enviando Salida de Almacen"; string docEntry = new DI.DiSalidaAlmacen(sbo.oCompany).Enviar(seSalida, out errCode, out errMessage); if (docEntry.Length > 0) { beSalida.CodSap = int.Parse(docEntry); } var rpta = bdSalida.Actualizar(beSalida); if (rpta == true && errCode != 0) { this.RegistrarErrorSap(SALIDA, beSalida.IdSalidaAlmacen, errMessage); } } break; case ENTRADA: // "Entrada de Almacen": var bdEntrada = new BD.EntradaAlmacen(); var beEntrada = bdEntrada.Obtener(uiDocumento.Id); if (beEntrada != null) { var seEntrada = TD.BeToSe.EntradaAlmacen(beEntrada); this.stlMensaje.Text = $"Enviando Entrada de Almacen"; string docEntry = new DI.DiEntradaAlmacenPorCompra(sbo.oCompany).Enviar(seEntrada, out errCode, out errMessage); if (docEntry.Length > 0) { beEntrada.CodSap = int.Parse(docEntry); } var rpta = bdEntrada.Actualizar(beEntrada); if (rpta == true && errCode != 0) { this.RegistrarErrorSap(SALIDA, beEntrada.IdEntradaAlmacen, errMessage); } } break; case SOLICITUD: // "Solicitud de Compra": var bdSolicitud = new BD.SolicitudCompra(); var beSolicitud = bdSolicitud.Obtener(uiDocumento.Id); if (beSolicitud != null) { var seSolicitud = TD.BeToSe.SolicitudCompra(beSolicitud); this.stlMensaje.Text = $"Enviando Solicitud de Compra"; string docEntry = new DI.DiSolicitudCompra(sbo.oCompany).Enviar(seSolicitud, out errCode, out errMessage); if (docEntry.Length > 0) { beSolicitud.CodSap = int.Parse(docEntry); } var rpta = bdSolicitud.Actualizar(beSolicitud); if (rpta == true && errCode != 0) { this.RegistrarErrorSap(SOLICITUD, beSolicitud.IdSolicitudCompra, errMessage); } } break; default: break; } } this.stlMensaje.Text = "Sincronización Completada"; this.CargarDocumentosError(); } catch (Exception ex) { General.ErrorMessage(ex.Message); } finally { this.btnEnviar.Enabled = true; } }
private void btnGuardar_Click(object sender, EventArgs e) { try { if (this.beEmpresa == null) { this.beEmpresa = new BE.Empresa(); } #region Validaciones if (this.txtCodigo.Text.Trim().Length == 0) { this.txtCodigo.Focus(); General.CriticalMessage("Ingrese una Codigo"); return; } int idEmpresa = 0; if (int.TryParse(this.txtCodigo.Text.Trim(), out idEmpresa) == false) { this.txtCodigo.Focus(); General.CriticalMessage("El Codigo debe ser un valor númerico"); return; } if (this.txtNombre.Text.Trim().Length == 0) { this.txtNombre.Focus(); General.CriticalMessage("Ingrese una Nombre"); return; } #endregion this.beEmpresa.Id = idEmpresa; this.beEmpresa.Nombre = this.txtNombre.Text.Trim(); this.beEmpresa.Descripcion = this.txtDescripcion.Text.Trim(); bool rpta = false; var bdEmpresa = new BD.Empresa(); if (bdEmpresa.Obtener(idEmpresa) == null) { rpta = bdEmpresa.Insertar(this.beEmpresa); } else { rpta = bdEmpresa.Actualizar(this.beEmpresa); } if (rpta) { this.Close(); } } catch (Exception ex) { General.ErrorMessage(ex.Message); } }