public static DataTable Listar_Cliente(int idEmpresa, string ruc_empresa, string esquema, string Id_Cliente) { DataTable dtTabla = new DataTable(); try { blTareo bl = new blTareo(); //Lista Producción por recibir DataSet ds1 = bl.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + "\n" + "declare @p3 varchar(50)\n " + "declare @p4 bit \n " + "set @p3 = null\n" + "set @p4 = null\n" + "exec " + esquema + "..VBG01134 '{0}', 1, @p3 output, @p4 output ", Id_Cliente ) ); //Busca registro de interfaz dtTabla = ds1.Tables[0]; } catch (Exception ex) { throw ex; } return(dtTabla); }
public static System.Data.DataTable Documentos_Listar(int idEmpresa, string ruc_empresa, string esquema, DateTime FechaBuscar) { System.Data.DataTable dtTabla = new System.Data.DataTable(); try { blTareo bl = new blTareo(); //Lista Producción por recibir DataSet ds1 = bl.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + "\n" + "exec " + esquema + "..VBG00062_Amerra_Pendientes '{0}' ", FechaBuscar.ToShortDateString() ) ); //Busca registro de interfaz dtTabla = ds1.Tables[0]; } catch (Exception ex) { throw ex; } return(dtTabla); }
public static void Actualizar_ProcesoDetalle_Letra(int idEmpresa, string esquema, int ID_Proceso, int OP_OV, int OP_DOC, int Usuario) { DataTable dtTabla = new DataTable(); try { blTareo bl = new blTareo(); //Lista Producción por recibir DataSet ds2 = bl.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + " \n" + "exec " + esquema + "..gsPedidos_ProcesoDetalleUpdate {0},{1}, {2}, {3}, 1 \n", ID_Proceso, OP_OV, OP_DOC, Usuario )); //dtTabla = ds2.Tables[0]; //var @p1 = ds2.Tables[0].Rows[0][0]; } catch (Exception ex) { throw ex; } }
public static void Actualizar_Fechas_Letra(int idEmpresa, string esquema, int ID_Proceso, int id_letra, int Usuario, DateTime Fecha) { DataTable dtTabla = new DataTable(); try { blTareo bl = new blTareo(); //Lista Producción por recibir DataSet ds2 = bl.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + " \n" + "exec " + esquema + "..gsFactura_FechasLetrasUpdate {0},{1},'{2}',{3} \n", ID_Proceso, id_letra, Fecha, Usuario )); //dtTabla = ds2.Tables[0]; //var @p1 = ds2.Tables[0].Rows[0][0]; } catch (Exception ex) { throw ex; } }
public static DataTable Letras_Registrar(int idEmpresa, string ruc_empresa, string esquema, int Periodo, int Op, string ID_Agenda, int ID_Moneda, decimal Importe, DateTime FechaEmision, DateTime FechaVencimiento, string Glosa) { DataTable dtTabla = new DataTable(); try { blTareo bl = new blTareo(); //Lista Producción por recibir DataSet ds2 = bl.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + " \n" + "declare @p1 numeric(18, 0) \n" + "set @p1 = null \n" + "exec " + esquema + "..VBG00575 @p1 output, {0}, {1}, '{2}', null, {3}, {4},'{5}', '{6}','Miraflores', '{7}' \n" + "select @p1", Periodo, Op, ID_Agenda, ID_Moneda, Importe, FechaEmision.ToShortDateString(), FechaVencimiento.ToShortDateString(), Glosa )); dtTabla = ds2.Tables[0]; //var @p1 = ds2.Tables[0].Rows[0][0]; } catch (Exception ex) { throw ex; } return(dtTabla); }
public static DataTable Listar_Fechas(int idEmpresa, string ruc_empresa, string esquema, int Id_Amarre) { DataTable dtTabla = new DataTable(); try { blTareo bl = new blTareo(); //Lista Producción por recibir DataSet ds1 = bl.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + "\n" + "exec " + esquema + "..gsFechasOP_Listar {0} ", Id_Amarre ) ); //Busca registro de interfaz dtTabla = ds1.Tables[0]; } catch (Exception ex) { throw ex; } return(dtTabla); }
public static DataTable Listar_NumerosUnicos(int idEmpresa, int id_proceso, string esquema) { DataTable dtTabla = new DataTable(); try { blTareo bl = new blTareo(); //Lista Producción por recibir DataSet ds1 = bl.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + "\n" + "exec " + esquema + "..gsNumerosUnicos_Listar {0} ", id_proceso ) ); //Busca registro de interfaz dtTabla = ds1.Tables[0]; } catch (Exception ex) { throw ex; } return(dtTabla); }
public static DataTable Listar_Documento(int idEmpresa, string ruc_empresa, string esquema, string ID_Documento) { DataTable dtTabla = new DataTable(); try { blTareo bl = new blTareo(); //Lista Producción por recibir DataSet ds1 = bl.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + "\n" + "exec " + esquema + "..VBG01362_Letra '{0}' ", ID_Documento ) ); //Busca registro de interfaz dtTabla = ds1.Tables[0]; } catch (Exception ex) { throw ex; } return(dtTabla); }
public static DataTable Listar_DocumentosPendiente(int idEmpresa, string ruc_empresa, string esquema, int OP_OV) { DataTable dtTabla = new DataTable(); try { blTareo bl = new blTareo(); //Lista Producción por recibir DataSet ds1 = bl.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + "\n" + "exec " + esquema + "..USP_SEL_CtaCte {0}", //"exec " + esquema + "..VBG00062_LetrasElectronicas {0}, null, null, null, 506, null, default, default, default, default, default, default, default, default " , OP_OV ) ); //Busca registro de interfaz dtTabla = ds1.Tables[0]; } catch (Exception ex) { throw ex; } return(dtTabla); }
public static DataTable Finan_Detalle_Registrar(int idEmpresa, string ruc_empresa, string esquema, int Id_Amarre, int Op, int ID_Doc, decimal Importe) { DataTable dtTabla = new DataTable(); try { blTareo bl = new blTareo(); //Lista Producción por recibir DataSet ds2 = bl.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + " \n" + "declare @p1 numeric(18, 0) \n" + "set @p1 = {3} \n" + "exec " + esquema + "..VBG00687 @p1 output, '{0}', {1}, '{2}' \n" + "select @p1", Op, ID_Doc, Importe, Id_Amarre )); dtTabla = ds2.Tables[0]; //var @p1 = ds2.Tables[0].Rows[0][0]; } catch (Exception ex) { throw ex; } return(dtTabla); }
public static DataTable Buscar_Financiamiento(int idEmpresa, string esquema, string ID_Agenda, int Id_doc) { DataTable dtTabla = new DataTable(); try { blTareo bl = new blTareo(); //Lista Producción por recibir DataSet ds1 = bl.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + "\n" + "exec " + esquema + "..VBG00679_Letras '{0}', {1} ", ID_Agenda, Id_doc ) ); //Busca registro de interfaz dtTabla = ds1.Tables[0]; } catch (Exception ex) { throw ex; } return(dtTabla); }
public static void Eliminar_Financimiento(int idEmpresa, string esquema, int OP_Finan) { DataTable dtTabla = new DataTable(); try { blTareo bl = new blTareo(); //Lista Producción por recibir DataSet ds2 = bl.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + " \n" + "exec " + esquema + "..gsEliminar_Financimiento '{0}' \n", OP_Finan )); //dtTabla = ds2.Tables[0]; //var @p1 = ds2.Tables[0].Rows[0][0]; } catch (Exception ex) { throw ex; } }
public static void Actualizar_Documentos(int idEmpresa, string esquema, int Op, int OpOrigen, string TablaOrigen, string Respuesta, int Activo) { DataTable dtTabla = new DataTable(); try { blTareo bl = new blTareo(); //Lista Producción por recibir DataSet ds2 = bl.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + " \n" + "exec " + esquema + "..gsDocumentosEletronicos_Update {0},{1}, '{2}', '{3}', {4} \n", Op, OpOrigen, TablaOrigen, Respuesta, Activo )); //dtTabla = ds2.Tables[0]; //var @p1 = ds2.Tables[0].Rows[0][0]; } catch (Exception ex) { throw ex; } }
public static DataTable Listar_Pedidos_Confirmacion(int idEmpresa, string ruc_empresa, string esquema) { DataTable dtTabla = new DataTable(); try { blTareo bl = new blTareo(); //Lista Producción por recibir DataSet ds1 = bl.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + "\n" + "exec " + esquema + "..Cargar_Recepcion_Confirmacion {0}", ruc_empresa ) ); //Busca registro de interfaz dtTabla = ds1.Tables[0]; } catch (Exception ex) { throw ex; } return(dtTabla); }
public static DataTable Documentos_Listar(int idEmpresa, string ruc_empresa, string esquema, int OP_OV, int OP_DOC) { DataTable dtTabla = new DataTable(); try { blTareo bl = new blTareo(); //Lista Producción por recibir DataSet ds1 = bl.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + "\n" + "exec " + esquema + "..gsDocumentosEletronicos_Listar" ) ); //Busca registro de interfaz dtTabla = ds1.Tables[0]; } catch (Exception ex) { throw ex; } return(dtTabla); }
public static List <string> ObtenerLetrasPendientesdeEnvio(string esquema, string id_agenda) { DataTable dtTabla = new DataTable(); List <string> lst = new List <string>(); try { blTareo bl = new blTareo(); //Lista Producción por recibir DataSet ds1 = bl.ListarDataSet("exec " + esquema + "..USP_SEL_LetrasPorEnviarEmail '" + id_agenda + "'"); //Busca registro de interfaz dtTabla = ds1.Tables[0]; foreach (DataRow row in dtTabla.Rows) { lst.Add(row["Op_DocVenta"].ToString()); } } catch (Exception ex) { throw ex; } return(lst); }
public static DataTable ProcesoDetalle_Listar(int idEmpresa, string ruc_empresa, string esquema, int Id_Amarre, int OP_OV, int OP_DOC) { DataTable dtTabla = new DataTable(); try { blTareo bl = new blTareo(); //Lista Producción por recibir DataSet ds1 = bl.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + "\n" + "exec " + esquema + "..gsProcesoLetras_DetalleListar {0}, {1}, {2} ", Id_Amarre, OP_OV, OP_DOC ) ); //Busca registro de interfaz dtTabla = ds1.Tables[0]; } catch (Exception ex) { throw ex; } return(dtTabla); }
public static DataTable Finan_Cabecera_Registrar(int idEmpresa, string ruc_empresa, string esquema, int OpOLD, int ID_Moneda, string ID_Aceptante, int ID_DireccionAceptante, decimal Total, int NroPeriodos, decimal Cuota, int ID_DocumentoLetra) { DataTable dtTabla = new DataTable(); try { blTareo bl = new blTareo(); //Lista Producción por recibir DataSet ds2 = bl.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + "\n" + "declare @p1 numeric(18, 0)\n" + "set @p1 = {9} \n" + "exec " + esquema + "..VBG00686 @p1 output, '{0}', {1}, '{2}', null, {3}, NULL,{4}, null,null,null, '{5}', {6}, 0, {7},0,0, {8}, null,1 \n" + "select @p1", DateTime.Now.ToShortDateString(), ID_Moneda, ID_Aceptante, ID_DireccionAceptante, Total, "Interfaz Intranet - Test", NroPeriodos, Cuota, ID_DocumentoLetra, OpOLD )); dtTabla = ds2.Tables[0]; //var @p1 = ds2.Tables[0].Rows[0][0]; } catch (Exception ex) { throw ex; } return(dtTabla); }
public static DataTable Listar_Direcciones(int idEmpresa, string ruc_empresa, string esquema, string Id_Cliente) { DataTable dtTabla = new DataTable(); try { blTareo bl = new blTareo(); //Lista Producción por recibir DataSet ds1 = bl.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + "\n" + "exec " + esquema + "..VBG00209 'Agenda', '{0}', 104 ", Id_Cliente ) ); //Busca registro de interfaz dtTabla = ds1.Tables[0]; } catch (Exception ex) { throw ex; } return(dtTabla); }
public static void RegistrarLetraEmail(int idempresa, string esquema, string op_docventa, string id_agenda) { try { blTareo bl = new blTareo(); bl.RegistrarLetraEmail("exec " + esquema + "..USP_INS_EnvioLetrasEmail " + op_docventa.ToString() + ",'" + id_agenda + "'"); } catch (Exception ex) { throw ex; } }
public static void RegistrarFlagEnvioEmail(string esquema, string id_agenda, string op_docventa) { try { blTareo bl = new blTareo(); //Lista Producción por recibir bl.RegistrarLetraEmail("exec " + esquema + "..USP_UDP_LetrasPorEnviarEmail '" + id_agenda + "'," + op_docventa); } catch (Exception ex) { throw ex; } }
public static void RegistrarErrorEnvioEmail(string esquema, string id_agenda, string op_docventa, string mensajerror) { try { blTareo bl = new blTareo(); //Lista Producción por recibir bl.RegistrarLetraEmail("exec " + esquema + "..USP_INS_ErrorEnvioEmail '" + id_agenda + "'," + op_docventa + ",'" + mensajerror + "'"); } catch (Exception ex) { throw ex; } }
private void SincronizarLotes() { try { for (int i = 1; i <= 2; i++) { RowItemCollection ocol = new RowItemCollection(); blTareo bl = new blTareo(); Transaction transaction = Common.InitTransaction(); RowItemCollection itemcollection = bl.GetLotesActivos(i, out transaction); const string file = "LotesActivos"; if (!Directory.Exists(@"C:\Data")) { Directory.CreateDirectory(@"C:\Data"); } if (!Directory.Exists(@"C:\Data\temp")) { Directory.CreateDirectory(@"C:\Data\temp"); } string name = string.Format(@"{0}_{1}.txt", DateTime.Now.ToString("yyyyMMddHHmmss"), file); string temp = string.Format(@"C:\Data\temp\{0}", name); //File.Create(temp); List <string> lines = new List <string>(); foreach (var row in itemcollection.rows) { lines.Add(string.Format("{0}", row.v01)); } File.WriteAllLines(temp, lines.ToArray()); try { //string.Format(ruta_ftp_lotes_dinamico,Entities.Common.Constant.getesquemaFTP(i)) UploadFTP(temp, string.Format(ruta_ftp_lotes_dinamico, Entities.Common.Constant.getesquemaFTP(i)), "ftpwms", "wmsapia"); } catch (Exception ex) { } File.Delete(temp); //lblSincronzarLotes.Text = estado_msg_esperando + " " + DateTime.Now.ToString("HH:mm:ss"); } Environment.Exit(0); //lblSincronzarLotes.Text = estado_msg_esperando + " " + DateTime.Now.AddMinutes(Convert.ToDouble(UpInterval_sincronizarlotes.Text)).ToString("HH:mm:ss"); //hiloSincronizarLotes.Interrupt(); //hiloSincronizarLotes = new Thread(SincronizarLotes); } catch (Exception ex) { Transaction transaction = Common.GetTransaction(TypeTransaction.ERR, ex.Message); } }
public static void RegistrarErrorEnvioEmail(string esquema, string id_agenda, string op_docventa, string mensajerror) { try { blTareo bl = new blTareo(); //Lista Producción por recibir //bl.RegistrarLetraEmail("exec " + esquema + "..USP_INS_ErrorEnvioEmail '" + id_agenda + "'," + op_docventa + ",'" + mensajerror +"'"); bl.RegistrarLetraEmail(string.Format( //"set dateformat DMY\n" + "exec " + esquema + "..USP_INS_ErrorEnvioEmail '{0}',{1},'{2}' ", id_agenda, op_docventa, mensajerror.Replace("'", "") )); } catch (Exception ex) { throw ex; } }
public static void Reproceso_Pedidos_Confirmacion(int idEmpresa, string ruc_empresa, string esquema) { try { blTareo bl = new blTareo(); //Lista Producción por recibir DataSet ds1 = bl.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + "\n" + "exec " + esquema + "..Cargar_Pedidos_ReprocesoEstilos '{0}'", ruc_empresa ) ); } catch (Exception ex) { throw ex; } }
public static DataTable ObtenerClientesPendientesEnvioEmail(string esquema) { DataTable dtTabla = new DataTable(); try { blTareo bl = new blTareo(); //Lista Producción por recibir DataSet ds1 = bl.ListarDataSet("exec " + esquema + "..USP_SEL_LetrasPendientesEnvio "); //Busca registro de interfaz dtTabla = ds1.Tables[0]; } catch (Exception ex) { throw ex; } return(dtTabla); }
public static DataSet Listar_FinanciamientoTotal(int idEmpresa, string esquema, int Op) { DataTable dtTabla = new DataTable(); DataSet ds1 = new DataSet(); try { blTareo bl = new blTareo(); //Lista Producción por recibir ds1 = bl.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + "\n" + "declare @Bloqueado bit=null \n" + "declare @MensajeBloqueo varchar(100)=null \n" + "exec " + esquema + "..VBG00685_Letras {0}, @Bloqueado output, @MensajeBloqueo output \n" + "select @Bloqueado, @MensajeBloqueo", Op )); //declare //@Bloqueado bit = Null , // @MensajeBloqueo varchar(100) = Null // exec VBG00685_Letras 35886, @Bloqueado, @MensajeBloqueo // select @Bloqueado, @MensajeBloqueo //Busca registro de interfaz //dtTabla = ds1.Tables[0]; } catch (Exception ex) { throw ex; } return(ds1); }
public static void ReadFileFromFTP_NumerosUnicos(int id_Empresa, string ruc_empresa, string esquema, int idCtaBanco) { var error = string.Empty; DateTime fecha1 = DateTime.Now.AddYears(-60); DateTime fecha2 = DateTime.Now.AddYears(+60); DateTime fechaActual = Convert.ToDateTime(DateTime.Now.ToShortDateString()); try { Console.WriteLine("-----------------------------------------"); DataTable listaProcesos = Listar_NumerosUnicos_Procesos(id_Empresa, ruc_empresa, esquema); Console.WriteLine("Procesos Pendientes: " + listaProcesos.Rows.Count.ToString()); Console.WriteLine("-----------------------------------------"); foreach (DataRow lineaProceso in listaProcesos.Rows) { int count = 0; string mensajeEtapa = ""; RowItem itemP = new RowItem(); itemP.v01 = lineaProceso["id"]; Console.WriteLine("Iniciando Proceso: " + itemP.v01.ToString()); blTareo bl0 = new blTareo(); DataTable listaArchivo = Listar_NumerosUnicos(id_Empresa, int.Parse(itemP.v01.ToString()), esquema); Console.WriteLine("Total: " + listaArchivo.Rows.Count.ToString()); if (listaArchivo.Rows.Count > 0) { foreach (DataRow lineaArchivo in listaArchivo.Rows) { try { count++; RowItem item = new RowItem(); item.v01 = lineaArchivo["Correlativo"]; item.v02 = lineaArchivo["ID_LetraL"]; item.v03 = lineaArchivo["EstadoLetra"]; item.v04 = lineaArchivo["Cliente"]; item.v05 = lineaArchivo["Importe"]; item.v06 = lineaArchivo["NumeroUnico"]; item.v07 = lineaArchivo["VencimientoL"]; item.v08 = lineaArchivo["id_proceso"]; item.v09 = ""; item.v10 = ""; item.v11 = ""; item.v12 = lineaArchivo["Banco"]; item.v13 = lineaArchivo["ID"]; Console.WriteLine(count.ToString() + ". ID_Letra: " + item.v02.ToString()); error = item.v02.ToString(); blTareo bl = new blTareo(); mensajeEtapa = "Al buscar letras. "; // Buscar Letra DataSet ds1 = bl.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + "\n" + "exec " + esquema + "..VBG00591_NumerosUnicos {0}, NULL,610,NULL,NULL ,'{1}','{2}'", item.v02.ToString(), fecha1, fecha2 ) ); //Busca registro de interfaz //DataRow[] result1 = ds1.Tables[0].Select(string.Format("Kardex={0} AND Op={1}", itemGroupKardex[0].v01, itemGroupKardex[0].v02)); DataTable dtTabla = ds1.Tables[0]; DataRow[] result1 = ds1.Tables[0].Select(); mensajeEtapa = "Asignación de cobranza"; //Asignacion de cobranza DataSet ds2 = bl.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + "\n" + "declare @p1 numeric(18, 0)\n" + "set @p1 = null\n" + "exec " + esquema + "..VBG00626 @p1 output, {2}, 'Credito BCP', {0}, 'IntranetGS', 683, '{1}'\n" + "select @p1", result1[0]["Importe"], DateTime.Now.ToShortDateString(), idCtaBanco )); var @p1 = ds2.Tables[0].Rows[0][0]; mensajeEtapa = "Agregar Numero Unico v1"; // Agregar Numero Unico DataSet ds3 = bl.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + "\n" + "declare @p1 numeric(18, 0)\n" + "set @p1 = null\n" + "exec " + esquema + "..VBG00627 @p1 output, {0}, '{1}'\n" + "select @p1", @p1, item.v02.ToString() )); var @p2 = ds3.Tables[0].Rows[0][0]; mensajeEtapa = "Agregar Numero Unico v2"; DataSet ds4 = bl.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + "\n" + "exec " + esquema + "..VBG02557 {0}, '{2}', '{1}'" , item.v02.ToString(), item.v06.ToString(), item.v12.ToString() )); //Aprobar Letra Cobranza mensajeEtapa = "Aprobar Letra Cobranza"; DataSet ds5 = bl.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + "\n" + "exec " + esquema + "..VBG00851 {0}, '{1}'" , @p1, DateTime.Now.ToShortDateString() )); // Actualizar Fecha Proceso mensajeEtapa = " Actualizar Fecha Proceso de Letra"; DataSet ds6 = bl.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + "\n" + "exec " + esquema + "..gsLetrasNumerosUnicos_Update {0} " , item.v13 )); Console.WriteLine("Mensaje: Se actualizo correctamente. "); } catch (Exception ex) { Console.WriteLine("Mensaje: Error en la etapa: " + mensajeEtapa); error = error; error = ex.Message; } } // Actualizar Fecha Proceso DataSet ds7 = bl0.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + "\n" + "exec " + esquema + "..gsProcesoLetras_Update {0} " , itemP.v01 )); DataSet ds8 = bl0.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + "\n" + "exec " + esquema + "..uspNOTI_ProcesoNumerosUnicos {0} " , itemP.v01 )); } } } catch (Exception ex) { error = error; error = ex.Message; Console.WriteLine("Error: " + ex.Message.ToString()); } }
public static void ReadFileFromFTP(int id_Empresa, string ruc_empresa, string esquema, string EmpresaPT) { var error = string.Empty; try { DataTable lista = Listar_Pedidos_Confirmacion(id_Empresa, ruc_empresa, esquema); foreach (DataRow linea in lista.Rows) { List <RowItem> itemlist = new List <RowItem>(); RowItem item = new RowItem(); item.v01 = linea["CodigoAlternativo"]; item.v02 = linea["DOCNumeroDePackinglist"]; item.v03 = linea["CodigoDeArticulo"]; item.v04 = ""; //Nombre Articulo item.v05 = linea["CodigoDeLote"]; item.v06 = linea["FechaFIFO"]; item.v07 = linea["FechaDeCaducidad"]; item.v08 = linea["IDUnidad"]; item.v09 = linea["Expr1"]; item.v10 = "6"; //Codigo Alamacén itemlist.Add(item); var itemGroupKardex = itemlist .GroupBy(be => be.v01) .Select(se => new RowItem() { v01 = se.First().v01, v02 = se.First().v02, v03 = se.First().v03, v04 = se.First().v04, v05 = se.First().v05, v06 = se.First().v06, v07 = se.First().v07, v08 = se.First().v08, v09 = se.Sum(x => Convert.ToDouble(x.v09)), v10 = se.First().v10, }) .ToList(); try { blTareo bl = new blTareo(); //Lista Producción por recibir DataSet ds1 = bl.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + "\n" + "exec " + esquema + "..VBG01941_WMSV1 {0}, NULL,NULL,NULL,NULL,NULL,NULL,default,default,default,default,default,default,default,default,NULL,default,default,default,default,default,default,default,default,default", itemGroupKardex[0].v02 ) ); //Busca registro de interfaz //DataRow[] result1 = ds1.Tables[0].Select(string.Format("Kardex={0} AND Op={1}", itemGroupKardex[0].v01, itemGroupKardex[0].v02)); DataRow[] result1 = ds1.Tables[0].Select(); DataSet ds2 = bl.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + "\n" + "declare @p1 numeric(18, 0)\n" + "set @p1 = null\n" + "exec " + esquema + "..VBG00599 @p1 output, '{0}', {3}, NULL, NULL, '{1}', NULL, 0, 0, 478, 0.0000, '{2}'\n" + "select @p1", result1[0]["ClienteCodigo"], DateTime.Now.ToShortDateString(), "Interfaz WMS - Test", itemGroupKardex[0].v10 )); var @p1 = ds2.Tables[0].Rows[0][0]; DataSet ds3 = bl.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + "\n" + "exec " + esquema + "..VBG01942_WMSV01 {0},NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL", itemGroupKardex[0].v02 )); //------------------------------- DataSet va1 = bl.ListarDataSet( string.Format( "select isnull(convert(varchar,MAX(ID_Amarre)),'null') 'IdAmarre' from " + esquema + "..ParteProduccionLinea where TablaOrigen = 'MovProduccion' and Id_Item = '{0}'", itemGroupKardex[0].v03 )); DataRow[] resultva1 = va1.Tables[0].Select(); DataSet ds4 = bl.ListarDataSet( string.Format( "declare @p1 numeric(18, 0)\n" + //"set @p1 = {6}\n"+ "set @p1 = null\n" + "exec " + esquema + "..VBG00597 @p1 output,{0},'MovProduccion',{1},'{2}',NULL,NULL,'5103','1020',{3},{4}.0000,0.0000,0.0000,{4}.0000,0.0000,'{5}',1.0000,{4}.0000,'{5}',{4}.0000,'{5}',{4}.0000,'...'\n" + "select @p1", @p1, itemGroupKardex[0].v02, itemGroupKardex[0].v03, itemGroupKardex[0].v01, itemGroupKardex[0].v09, ds3.Tables[0].Rows[0]["UnidadPresentacion"] //, resultva1[0]["IdAmarre"] )); var @p2 = ds4.Tables[0].Rows[0][0]; DataSet ds5 = bl.ListarDataSet( string.Format( "set dateformat DMY\n" + "exec " + esquema + "..VBG00969 'ParteProduccion',{0}\n" + "exec " + esquema + "..VBG00972 'ParteProduccion',{0}", @p1 )); DataSet ds6 = bl.ListarDataSet( string.Format( "exec " + esquema + "..VBG00167 '{0}',10,284", ruc_empresa )); //Busca registro de interfaz DataRow[] result2 = ds6.Tables[0].Select(string.Format("ID={0}", itemGroupKardex[0].v10)); //Busca el Id del lote DataSet va2 = bl.ListarDataSet( string.Format( "select isnull(convert(varchar,max(Id_Lote)),'null') 'Id_Lote' from " + esquema + "..tblLote where No_Lote = '{0}'", itemGroupKardex[0].v05 )); DataRow[] resultva2 = va2.Tables[0].Select(); DataSet ds7 = bl.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + "\n" + "declare @p1 numeric(18, 0)\n" + "set @p1 = {6}\n" + "declare @p3 numeric(18, 0)\n" + "set @p3 = {6}\n" + "exec " + esquema + "..VBG01024 @p1 output, {0}, @p3 output, '{1}', '{4}', 0, 0, 0, '{2}', '{3}', {5}, {5}, '...', '...'\n" + "select @p1, @p3" , @p2, itemGroupKardex[0].v05, itemGroupKardex[0].v06, itemGroupKardex[0].v07, result2[0]["ID_Agenda"], itemGroupKardex[0].v09, resultva2[0]["Id_Lote"] )); //Busca el Id del lote va2 = bl.ListarDataSet( string.Format( "select isnull(convert(varchar,max(Item_ID)),'null') 'Item_ID', isnull(convert(varchar,max(Id_Lote)),'null') 'Id_Lote' from " + esquema + "..tblLote where No_Lote = '{0}'", itemGroupKardex[0].v05 )); resultva2 = va2.Tables[0].Select(); string query = "declare @existe int \n" + "select @existe = count(1) from " + esquema + "..ItemAlmacen where ID_Item = {2} and Id_Anexo = {1} \n" + "if @existe = 0 \n" + " insert into " + esquema + "..ItemAlmacen values('{0}',{2}, {1},0,0,0,0,NULL,NULL,NULL,NULL,NULL,1,0,0) \n"; string strID_Agenda = result2[0]["ID_Agenda"].ToString(); string strID = result2[0]["ID"].ToString(); DataSet ds8 = bl.ListarDataSet( string.Format(query, result2[0]["ID_Agenda"], result2[0]["ID"], resultva2[0]["Item_ID"], itemGroupKardex[0].v09 )); query = "declare @existe int \n" + "select @existe = count(1) from " + esquema + "..tblKardexLoteTotal where Item_Id = {2} and ID_Lote = {3} \n" + "if @existe = 0 \n" + " insert into " + esquema + "..tblKardexLoteTotal values('{0}',{1},{2},{3},0,{4}.00,0.00,{4}.00,{4}.00,0.00,{4}.00, null) \n" + "else \n" + " update " + esquema + "..tblKardexLoteTotal \n" + " set Und1Entrada = {4}.00, \n" + " Und1Saldo = Und1Entrada - Und1Salida, \n" + " Und2Entrada = {4}.00, \n" + " Und2Saldo = Und2Entrada - Und2Salida \n" + " where Item_Id = {2} and ID_Lote = {3} \n"; DataSet ds9 = bl.ListarDataSet( string.Format(query, result2[0]["ID_Agenda"], result2[0]["ID"], itemGroupKardex[0].v01, resultva2[0]["Id_Lote"], itemGroupKardex[0].v09 )); DataSet ds10 = bl.ListarDataSet( string.Format( "set dateformat DMY\n" + "exec " + esquema + "..VBG00871 'ParteProduccion',{0}", @p1 )); DataSet ds11 = bl.ListarDataSet( string.Format( "set dateformat DMY\n" + "exec " + esquema + "..Cargar_Recepcion_UpdateEstilos '{1}','{0}'", linea["NumeroDeAlbaran"], EmpresaPT )); } catch (Exception ex) { error = ex.Message; } } } catch (Exception ex) { error = ex.Message; } }
public static void Generar_LetrasElectornicas(int id_Empresa, string ruc_empresa, string esquema) { var error = string.Empty; DateTime fecha1 = DateTime.Now.AddYears(-60); DateTime fecha2 = DateTime.Now.AddYears(+60); DateTime fechaActual = Convert.ToDateTime(DateTime.Now.ToShortDateString()); int auxId = 0; try { DataTable tblProceso = Proceso_Listar(id_Empresa, ruc_empresa, esquema, 0, 0); DataTable lstTipoCambio = Listar_TipoCambio(id_Empresa, ruc_empresa, esquema); DataTable lstTipoDocumento = Listar_TipoDocumento(id_Empresa, ruc_empresa, esquema); DataTable lstSedes = Listar_Sedes(id_Empresa, ruc_empresa, esquema); int Bloqueo = 0; Console.WriteLine("-----------------------------------------"); Console.WriteLine(esquema); Console.WriteLine("-----------------------------------------"); foreach (DataRow Proceso in tblProceso.Rows) { int count = 0; string mensajeEtapa = ""; RowItem itemProceso = new RowItem(); itemProceso.v01 = Proceso["Id_Proceso"]; auxId = Convert.ToInt32(itemProceso.v01); try { //------------------------ Etapa 1 ------------------------------ Console.WriteLine("Iniciando Proceso"); Console.WriteLine("-----------------------------------------"); Console.WriteLine("ID_Proceso: " + itemProceso.v01.ToString()); // Iniciando // Buscar detalle proceso DataTable tblProcesoDetalle = ProcesoDetalle_Listar(id_Empresa, ruc_empresa, esquema, Convert.ToInt32(itemProceso.v01), 0, 0); DataTable tblFechas = Listar_Fechas(id_Empresa, ruc_empresa, esquema, Convert.ToInt32(itemProceso.v01)); int CountDOC_PRO = 0; int CountDOC_Gsys = 0; //----------------------------------- CountDOC_PRO = tblProcesoDetalle.Rows.Count; foreach (DataRow iProceso_D in tblProcesoDetalle.Rows) { RowItem itemPEDIDO = new RowItem(); itemPEDIDO.v01 = iProceso_D["OP_OV"]; DataTable lstDocumentos = Listar_DocumentosPendiente(id_Empresa, ruc_empresa, esquema, Convert.ToInt32(itemPEDIDO.v01)); if (lstDocumentos.Rows.Count > 0) { CountDOC_Gsys++; } } if (CountDOC_PRO == CountDOC_Gsys & CountDOC_PRO > 0 & CountDOC_Gsys > 0) { //----------------------------------- decimal TotalImporte = 0; //------------------------ Etapa 2 ------------------------------ if (tblFechas.Rows.Count > 0) { var @Id_Direccion = 0; var @Total = 0.00; double @NroPeriodos = 0; double @Cuota = 0.00; var @ID_DocumentoLetra = lstTipoDocumento.Rows[0]["ID"]; var @ID_Moneda = 0; var @Id_Cliente = ""; double CuotaTemp = 0.00; List <RowItem> listDocumentos = new List <RowItem>(); foreach (DataRow iProceso_D in tblProcesoDetalle.Rows) { RowItem itemPEDIDO = new RowItem(); itemPEDIDO.v01 = iProceso_D["OP_OV"]; // Buscar Documentos DataTable lstDocumentos = Listar_DocumentosPendiente(id_Empresa, ruc_empresa, esquema, Convert.ToInt32(itemPEDIDO.v01)); if (lstDocumentos.Rows.Count > 0) { foreach (DataRow Documento in lstDocumentos.Rows) { Console.WriteLine("-----------------------------------------"); Console.WriteLine("Documentos Procesar: " + lstDocumentos.Rows.Count.ToString()); Console.WriteLine("-----------------------------------------"); RowItem itemDOC = new RowItem(); itemDOC.v01 = Documento["Op"]; itemDOC.v02 = Documento["Id_Agenda"]; itemDOC.v03 = Documento["ID_Doc"]; itemDOC.v04 = Documento["ID_Moneda"]; itemDOC.v05 = Documento["OP_OV"]; /// Buscar Cliente DataTable tblCliente = Listar_Cliente(id_Empresa, ruc_empresa, esquema, itemDOC.v02.ToString()); /// Buscar Direccion Cliente DataTable tblDireccion = Listar_Direcciones(id_Empresa, ruc_empresa, esquema, itemDOC.v02.ToString()); /// Buscar Documentos DataTable tblDocumento = Listar_Documento(id_Empresa, ruc_empresa, esquema, itemDOC.v03.ToString()); TotalImporte = TotalImporte + Convert.ToDecimal(tblDocumento.Rows[0]["Importe"]); itemDOC.v06 = Convert.ToDecimal(tblDocumento.Rows[0]["Importe"]); listDocumentos.Add(itemDOC); //-----------Varibles @Id_Direccion = Convert.ToInt32(tblDireccion.Rows[0]["ID"]); @Total = Convert.ToDouble(TotalImporte); @NroPeriodos = tblFechas.Rows.Count; @Cuota = (@Total / @NroPeriodos); @ID_DocumentoLetra = lstTipoDocumento.Rows[0]["ID"]; @ID_Moneda = Convert.ToInt32(itemDOC.v04); @Id_Cliente = itemDOC.v02.ToString(); //---------------------------------------- // Buscar Financiamiento de OP DataTable tblFinanOLD = Buscar_Financiamiento(id_Empresa, esquema, itemDOC.v02.ToString(), Convert.ToInt32(itemDOC.v03)); var @Op_FinOld = 0; var @Id_AmarreOLD = 0; DataTable tblDocumentos = new DataTable(); DataTable tblLetras = new DataTable(); DataTable tblBloqueo = new DataTable(); if (tblFinanOLD.Rows.Count > 0) { @Op_FinOld = Convert.ToInt32(tblFinanOLD.Rows[0][0]); DataSet ListaFinan = Listar_FinanciamientoTotal(id_Empresa, esquema, Convert.ToInt32(@Op_FinOld)); tblDocumentos = ListaFinan.Tables[0]; @Id_AmarreOLD = Convert.ToInt32(tblDocumentos.Rows[0][0]); tblLetras = ListaFinan.Tables[1]; tblBloqueo = ListaFinan.Tables[2]; /* * foreach (DataRow rowB in tblBloqueo.Rows) * { * string Respuesta = rowB[0].ToString(); * * if (Respuesta == "True") * { * Bloqueo++; * } * } */ if (Bloqueo == 0) { // Eliminar Letras foreach (DataRow iletra in tblLetras.Rows) { RowItem itemletra = new RowItem(); itemletra.v01 = iletra["Id_Amarre"]; Eliminar_Letra(id_Empresa, esquema, Convert.ToInt32(itemletra.v01)); } Eliminar_Financimiento(id_Empresa, esquema, @Op_FinOld); } } } } else { Console.WriteLine("-----------------------------------------"); Console.WriteLine("No existe la OP: " + itemPEDIDO.v01.ToString() + " en documentos pendientes. "); Console.WriteLine("-----------------------------------------"); } } if (Bloqueo == 0) { //---------------------------------------- // Registrar Cabecera Financiamiento DataTable tblFinanCab = Finan_Cabecera_Registrar(id_Empresa, ruc_empresa, esquema, 0, @ID_Moneda, @Id_Cliente, Convert.ToInt32(@Id_Direccion), Convert.ToDecimal(@Total), Convert.ToInt32(@NroPeriodos), Convert.ToDecimal(@Cuota), Convert.ToInt32(@ID_DocumentoLetra)); var @Op_Fin = tblFinanCab.Rows[0][0]; // Registrar Detalle Financiamiento foreach (RowItem iDoc in listDocumentos) { DataTable tblFinanDet = Finan_Detalle_Registrar(id_Empresa, ruc_empresa, esquema, 0, Convert.ToInt32(@Op_Fin), Convert.ToInt32(iDoc.v03), Convert.ToDecimal(iDoc.v06)); var @pId_Amarre_Fin = tblFinanDet.Rows[0][0]; } //---------------------------------------- // Registrar Letras int Periodo = 1; // Registrar Letras //int Op_Pedido = 0; CuotaTemp = 0; foreach (DataRow Letras in tblFechas.Rows) { string mensajeLetra = ""; RowItem itemLetra = new RowItem(); DataTable tblLetra = new DataTable(); itemLetra.v01 = Letras["Fecha"]; //Op_Pedido = Convert.ToInt32(Letras["Op"]); var FechaEmision = DateTime.Now.ToShortDateString(); if (@NroPeriodos == 1) { tblLetra = Letras_Registrar(id_Empresa, ruc_empresa, esquema, Periodo, Convert.ToInt32(@Op_Fin), @Id_Cliente, @ID_Moneda, Convert.ToDecimal((@Cuota)), Convert.ToDateTime(FechaEmision), Convert.ToDateTime(itemLetra.v01), ""); } else { if (@NroPeriodos == Periodo) { CuotaTemp = @Total - CuotaTemp; tblLetra = Letras_Registrar(id_Empresa, ruc_empresa, esquema, Periodo, Convert.ToInt32(@Op_Fin), @Id_Cliente, @ID_Moneda, Convert.ToDecimal(CuotaTemp), Convert.ToDateTime(FechaEmision), Convert.ToDateTime(itemLetra.v01), ""); } else { CuotaTemp = CuotaTemp + Math.Truncate(@Cuota); tblLetra = Letras_Registrar(id_Empresa, ruc_empresa, esquema, Periodo, Convert.ToInt32(@Op_Fin), @Id_Cliente, @ID_Moneda, Convert.ToDecimal(Math.Truncate(@Cuota)), Convert.ToDateTime(FechaEmision), Convert.ToDateTime(itemLetra.v01), ""); } } var @ID_Letra = tblLetra.Rows[0][0]; //--------------------------------------- // Actualizar Fechas Letras Actualizar_Fechas_Letra(id_Empresa, esquema, Convert.ToInt32(itemProceso.v01), Convert.ToInt32(@ID_Letra), 1, Convert.ToDateTime(itemLetra.v01)); //--------------------------------------- Periodo++; } // Actualizar proceso de letras Actualizar_Proceso_Letra(id_Empresa, esquema, Convert.ToInt32(itemProceso.v01), 1); foreach (RowItem iDoc in listDocumentos) { Actualizar_ProcesoDetalle_Letra(id_Empresa, esquema, Convert.ToInt32(itemProceso.v01), Convert.ToInt32(iDoc.v05), Convert.ToInt32(iDoc.v01), 1); //Convert.ToInt32(iDoc.v01), 1); RegistrarLetraEmail(id_Empresa, esquema, Convert.ToInt32(iDoc.v01).ToString(), @Id_Cliente); } } } } else { string strerr = "La cantidad de documentos del financiamiento, es distinta a la cantidad en genesys. "; Console.WriteLine("-----------------------------------------"); Console.WriteLine(strerr); Console.WriteLine("-----------------------------------------"); blTareo bl = new blTareo(); DataSet ds1 = bl.ListarDataSet( string.Format( "set dateformat " + getFormatDate() + "\n" + "update " + esquema + "..gsPedidoLetras_Proceso \n" + "set Estado = 2 \n" + "where Id_Proceso = {0}\n" + "insert into " + esquema + "..gsPedidoLetras_Proceso_Transact(ID_Proceso, Error, DetalleError) values ({0}, {1}, '{2}') \n " + "select {0} \n ", Convert.ToInt32(itemProceso.v01), 1, strerr ) ); } } catch (Exception ex) { error = ex.Message; Console.WriteLine("Error: " + ex.Message.ToString()); string strerr = ex.Message; strerr = strerr.Replace("\n", ". ").Replace("\"", "").Replace("'", ""); Console.WriteLine("-----------------------------------------"); Console.WriteLine(strerr); Console.WriteLine("-----------------------------------------"); blTareo bl = new blTareo(); DataSet ds1 = bl.ListarDataSet( string.Format( "set dateformat " + getFormatDate() + "\n" + "update " + esquema + "..gsPedidoLetras_Proceso \n" + "set Estado = 2 \n" + "where Id_Proceso = {0}\n" + "insert into " + esquema + "..gsPedidoLetras_Proceso_Transact(ID_Proceso, Error, DetalleError) values ({0}, {1}, '{2}') \n " + "select {0} \n ", Convert.ToInt32(itemProceso.v01), 1, strerr ) ); } } } catch (Exception ex) { error = ex.Message; Console.WriteLine("Error: " + ex.Message.ToString()); string strerr = ex.Message; strerr = strerr.Replace("\n", ". ").Replace("\"", "").Replace("'", ""); Console.WriteLine("-----------------------------------------"); Console.WriteLine(strerr); Console.WriteLine("-----------------------------------------"); blTareo bl = new blTareo(); DataSet ds1 = bl.ListarDataSet( string.Format( "set dateformat " + getFormatDate() + "\n" + "update " + esquema + "..gsPedidoLetras_Proceso \n" + "set Estado = 2 \n" + "where Id_Proceso = {0}\n" + "insert into " + esquema + "..gsPedidoLetras_Proceso_Transact(ID_Proceso, Error, DetalleError) values ({0}, {1}, '{2}') \n " + "select {0} \n ", Convert.ToInt32(auxId), 1, strerr ) ); } }