private bool RegistrarSolicitudBD(ref BD.Sap bdSap, BE.Empresa beEmpresa) { bool rpta = false; try { var beTipoSolicitud = new BD.TipoDocumento().Obtener(SOLICITUD); var bdSolicitud = new BD.SolicitudCompra(); foreach (var solicitudJson in this.lstWsSolicitudes) { SE.SolicitudCompra seSolicitud = TD.JsonToSe.SolicitudCompra(solicitudJson); seSolicitud.Serie = bdSap.ObtenerSerieSalidaAlmacen(this.serie); for (int i = 0; i < seSolicitud.Detalle.Count; i++) { seSolicitud.Detalle[i].CodAlmacen = bdSap.ObtenerCodigoAlmacen(seSolicitud.Detalle[i].Codigo); } var beSolicitud = TD.SeToBe.SolicitudCompra(seSolicitud); beSolicitud.Empresa = beEmpresa; beSolicitud.TipoDocumento = beTipoSolicitud; var flag = bdSolicitud.Insertar(ref beSolicitud); } return(rpta); } catch (Exception ex) { throw ex; } }
private bool RegistrarEntradaBD(ref BD.Sap bdSap, BE.Empresa beEmpresa) { bool rpta = false; try { var beTipoEntrada = new BD.TipoDocumento().Obtener(ENTRADA); var bdEntrada = new BD.EntradaAlmacen(); foreach (var entradaJson in this.lstWsEntradas) { SE.EntradaAlmacen seEntrada = TD.JsonToSe.EntradaAlmacen(entradaJson); seEntrada.Serie = bdSap.ObtenerSerieSalidaAlmacen(this.serie); for (int i = 0; i < seEntrada.Detalle.Count; i++) { seEntrada.Detalle[i].CodAlmacen = bdSap.ObtenerCodigoAlmacen(seEntrada.Detalle[i].Codigo); } var beEntrada = TD.SeToBe.EntradaAlmacen(seEntrada); beEntrada.Empresa = beEmpresa; beEntrada.TipoDocumento = beTipoEntrada; var flag = bdEntrada.Insertar(ref beEntrada); } return(rpta); } catch (Exception ex) { throw ex; } }
private void CargarTiposDocumentos() { try { var lstBeTiposDocumentos = new BD.TipoDocumento().Listar(); var beTipoDocumento = new BE.TipoDocumento(); beTipoDocumento.Id = 0; beTipoDocumento.Nombre = "Todos"; lstBeTiposDocumentos.Insert(0, beTipoDocumento); this.cboTiposDocumentos.DataSource = lstBeTiposDocumentos; this.cboTiposDocumentos.DisplayMember = "Nombre"; this.cboTiposDocumentos.ValueMember = "Id"; this.cboTiposDocumentos.SelectedIndex = 0; var beTipoDocumento2 = new List <BE.TipoDocumento>(lstBeTiposDocumentos); this.cboDocumentos.DataSource = beTipoDocumento2; this.cboDocumentos.DisplayMember = "Nombre"; this.cboDocumentos.ValueMember = "Id"; this.cboDocumentos.SelectedIndex = 0; } catch (Exception ex) { throw ex; } }
private void EnviarSolicitudesSap(ref DI.DiConexion diConexion, BE.Empresa beEmpresa) { int errCode = 0; string errMessage = ""; try { var beTipoSolicitud = new BD.TipoDocumento().Obtener(SOLICITUD); var bdSap = new BD.Sap(diConexion.Server, diConexion.CompanyDB, diConexion.DbUserName, diConexion.DbPassword); var bdError = new BD.Error(); var diSolicitud = new DI.DiSolicitudCompra(diConexion.oCompany); var bdSolicitud = new BD.SolicitudCompra(); foreach (var SolicitudJson in this.lstWsSolicitudes) { var Solicitudese = TD.JsonToSe.SolicitudCompra(SolicitudJson); Solicitudese.Serie = bdSap.ObtenerSerieSolicitudCompra(this.serie); for (int i = 0; i < Solicitudese.Detalle.Count; i++) { Solicitudese.Detalle[i].CodAlmacen = bdSap.ObtenerCodigoAlmacen(Solicitudese.Detalle[i].Codigo); } string docEntry = diSolicitud.Enviar(Solicitudese, out errCode, out errMessage); if (docEntry.Length > 0) { Solicitudese.DocEntry = int.Parse(docEntry); } var beSolicitud = TD.SeToBe.SolicitudCompra(Solicitudese); beSolicitud.Empresa = beEmpresa; beSolicitud.TipoDocumento = beTipoSolicitud; var rpta = bdSolicitud.Insertar(ref beSolicitud); if (rpta == true && docEntry.Length == 0) { this.RegistrarErrorSap(SOLICITUD, beSolicitud.IdSolicitudCompra, errMessage); } } } catch (Exception ex) { throw ex; } }
private void EnviarEntradasSap(ref DI.DiConexion diConexion, BE.Empresa beEmpresa) { int errCode = 0; string errMessage = ""; try { var beTipoEntrada = new BD.TipoDocumento().Obtener(ENTRADA); var bdSap = new BD.Sap(diConexion.Server, diConexion.CompanyDB, diConexion.DbUserName, diConexion.DbPassword); var bdError = new BD.Error(); var diEntrada = new DI.DiEntradaAlmacenPorCompra(diConexion.oCompany); var bdEntrada = new BD.EntradaAlmacen(); foreach (var EntradaJson in this.lstWsEntradas) { var EntradaSe = TD.JsonToSe.EntradaAlmacen(EntradaJson); EntradaSe.Serie = bdSap.ObtenerSerieEntradaAlmacenPorCompra(this.serie); for (int i = 0; i < EntradaSe.Detalle.Count; i++) { EntradaSe.Detalle[i].CodAlmacen = bdSap.ObtenerCodigoAlmacen(EntradaSe.Detalle[i].Codigo); } string docEntry = diEntrada.Enviar(EntradaSe, out errCode, out errMessage); if (docEntry.Length > 0) { EntradaSe.DocEntry = int.Parse(docEntry); } var beEntrada = TD.SeToBe.EntradaAlmacen(EntradaSe); beEntrada.Empresa = beEmpresa; beEntrada.TipoDocumento = beTipoEntrada; var rpta = bdEntrada.Insertar(ref beEntrada); if (rpta == true && docEntry.Length == 0) { this.RegistrarErrorSap(ENTRADA, beEntrada.IdEntradaAlmacen, errMessage); } } } catch (Exception ex) { throw ex; } }
public List <BE.Error> Listar(int idTipoDocumento, int idDocumento) { var lstError = new List <BE.Error>(); try { string sp = "SpTbErrorListar"; int idDoc = 0; var bdTipoDocumento = new TipoDocumento(); using (var cnn = new SqlConnection(Conexion.strCnxBD)) { cnn.Open(); var cmd = new SqlCommand(sp, cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@IDTIPODOCUMENTO", idTipoDocumento)); cmd.Parameters.Add(new SqlParameter("@IDDOCUMENTO", idDocumento)); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { var beError = new BE.Error(); beError.Id = int.Parse(reader["idError"].ToString()); idDoc = int.Parse(reader["idTipoDocumento"].ToString()); beError.Documento = bdTipoDocumento.Obtener(idDoc); beError.IdDocumento = int.Parse(reader["idDocumento"].ToString()); beError.Mensaje = reader["Mensaje"].ToString(); lstError.Add(beError); } cnn.Close(); } return(lstError); } catch (Exception ex) { throw ex; } }