protected void grdOrdenVenta_DeleteCommand(object sender, GridCommandEventArgs e) { PedidoWCFClient objPedidoWCF = new PedidoWCFClient(); OrdenVentaWCFClient objOrdenVenta = new OrdenVentaWCFClient(); GridDataItem dataitem = (GridDataItem)e.Item; try { int Op = Convert.ToInt32(((GridDataItem)e.Item).GetDataKeyValue("Op")); string IdAgenda = dataitem["ID_Agenda"].Text; int IdPedido = int.Parse(dataitem["ID"].Text); decimal ValorVenta = decimal.Parse(dataitem["Total"].Text); string idSectorista = cbSectorista.SelectedValue; string Perfil = ((Usuario_LoginResult)Session["Usuario"]).nombrePerfil; string usuario = ((Usuario_LoginResult)Session["Usuario"]).nombres; //string idSectorista = cbSectorista.SelectedValue; string comentario = "Desaprobado por " + Perfil + " (" + usuario + ")."; objPedidoWCF.Pedido_DesAprobar(((Usuario_LoginResult)Session["Usuario"]).idEmpresa, ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario, IdPedido, Op, idSectorista, false); objOrdenVenta.OrdenVenta_Deasaprobar(((Usuario_LoginResult)Session["Usuario"]).idEmpresa, ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario, Op, comentario); OrdenVenta_Listar(null, dpFechaInicio.SelectedDate.Value, dpFechaFinal.SelectedDate.Value, null, cbSectorista.SelectedValue, int.Parse(cboEstado.SelectedValue), int.Parse(cboTipoPago.SelectedValue)); lblMensaje.Text = "Se desaprobo el pedido " + ((GridDataItem)e.Item).GetDataKeyValue("Op") + " con éxito."; lblMensaje.CssClass = "mensajeExito"; } catch (Exception ex) { lblMensaje.Text = ex.Message; lblMensaje.CssClass = "mensajeError"; } }
protected void grdOrdenVenta_DeleteCommand(object sender, GridCommandEventArgs e) { try { int OpDelete = 0; OpDelete = Convert.ToInt32(((GridDataItem)e.Item).GetDataKeyValue("Op")); OrdenVentaWCFClient objOrdenVenta = new OrdenVentaWCFClient(); objOrdenVenta.OrdenVenta_Eliminar(((Usuario_LoginResult)Session["Usuario"]).idEmpresa, ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario, OpDelete, ""); List <gsOV_ListarResult> lst = JsonHelper.JsonDeserialize <List <gsOV_ListarResult> >((string)ViewState["lstOrdenVenta"]); lst.Remove(lst.Find(x => x.Op == OpDelete)); grdOrdenVenta.DataSource = lst; grdOrdenVenta.DataBind(); ViewState["lstOrdenVenta"] = JsonHelper.JsonSerializer(lst); lblMensaje.Text = "Se eliminó el pedido " + OpDelete + " con éxito."; lblMensaje.CssClass = "mensajeExito"; } catch (Exception ex) { lblMensaje.Text = ex.Message; lblMensaje.CssClass = "mensajeError"; } }
//private void TipoDocumento_ComboBox() //{ // DocumentoWCFClient objDocumentoWCF; // VBG00716Result objDocumento; // List<VBG00716Result> lstDocumentos; // try // { // objDocumentoWCF = new DocumentoWCFClient(); // objDocumento = new VBG00716Result(); // objDocumento.Nombre = "Todos"; // objDocumento.ID = -1; // lstDocumentos = objDocumentoWCF.Documento_ListarDocVenta(((Usuario_LoginResult)Session["Usuario"]).idEmpresa, // ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario).ToList(); // lstDocumentos.Insert(0, objDocumento); // cboTipoDocumento.DataSource = lstDocumentos; // cboTipoDocumento.DataTextField = "Nombre"; // cboTipoDocumento.DataValueField = "ID"; // cboTipoDocumento.DataBind(); // if (cboTipoDocumento.Items.Count > 0) // cboTipoDocumento.SelectedIndex = 0; // } // catch (Exception ex) // { // throw ex; // } //} private void OrdenVenta_DesAprobar(int idOperacion) { try { OrdenVentaWCFClient objOrdenVenta = new OrdenVentaWCFClient(); string Perfil = ((Usuario_LoginResult)Session["Usuario"]).nombrePerfil; string usuario = ((Usuario_LoginResult)Session["Usuario"]).nombres; //string idSectorista = cbSectorista.SelectedValue; string Comentario = "Desaprobado por " + Perfil + " (" + usuario + ")."; objOrdenVenta.OrdenVenta_Deasaprobar(((Usuario_LoginResult)Session["Usuario"]).idEmpresa, ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario, idOperacion, Comentario); OrdenVenta_Listar(null, dpFechaInicio.SelectedDate.Value, dpFechaFinal.SelectedDate.Value, ((Usuario_LoginResult)Session["Usuario"]).nroDocumento); lblMensaje.Text = "Se Desaprobo el pedido " + idOperacion + " con éxito."; lblMensaje.CssClass = "mensajeExito"; } catch (Exception ex) { lblMensaje.Text = ex.Message; lblMensaje.CssClass = "mensajeError"; } }
static void Main(string[] args) { OrdenVentaWCFClient objOrdenVentaWCF = new OrdenVentaWCFClient(); AgendaWCFClient objAgendaWCF = new AgendaWCFClient(); int idEmpresa; int codUsuario; string idOrdenVenta; DateTime fechaInicial; DateTime fechaFinal; int contar = 0; for (int x = 1; x <= 3; x++) { idEmpresa = x; if (x == 3) { idEmpresa = 6; } Console.WriteLine("Iniciando Empresa: " + x.ToString()); codUsuario = 1; //idOrdenVenta = 20120.ToString(); fechaFinal = DateTime.Now; fechaInicial = fechaFinal.AddDays(-25); List <gsOV_Listar_SectoristaResult> ListaPedidos = objOrdenVentaWCF.OrdenVenta_Listar_Sectorista(idEmpresa, codUsuario, null, fechaInicial, fechaFinal, null, true, null, 0, 99 ).ToList().FindAll(y => y.Aprobacion1 == false && y.FormaPago.Contains("Contado") //|| y.CondicionCredito.Contains("Contado") ); Console.WriteLine("Total de pedidos: " + ListaPedidos.Count().ToString()); foreach (gsOV_Listar_SectoristaResult pedido in ListaPedidos) { //if (pedido.Op == 16891 && idEmpresa == 2) //{ contar = contar + 1; idOrdenVenta = pedido.Op.ToString(); try { Pedido_Cargar(idOrdenVenta, idEmpresa, codUsuario); Console.WriteLine("Actualizando Op " + contar.ToString() + ": " + idOrdenVenta.ToString()); } catch (Exception ex) { Console.WriteLine("Error Op " + contar.ToString() + ": " + idOrdenVenta.ToString() + " " + ex.Message.ToString()); } } } }
static void Pedido_Cargar(string idOrdenVenta, int idEmpresa, int codigoUsuario) { OrdenVentaWCFClient objOrdenVentaWCF = new OrdenVentaWCFClient(); gsOV_BuscarCabeceraResult objOrdenVentaCab; List <GlosaBE> lstGlosa = new List <GlosaBE>(); ImpuestoWCFClient objImpuestoWCF = new ImpuestoWCFClient(); gsOV_BuscarImpuestoResult[] lstImpuestos = null; List <gsImpuesto_ListarPorItemResult> lstImpuestoItem = new List <gsImpuesto_ListarPorItemResult>(); gsOV_BuscarDetalleResult[] objOrdenVentaDet = null; List <gsItem_BuscarResult> lstProductos = new List <gsItem_BuscarResult>(); bool? bloqueado = false; string mensajeBloqueo = null; AgendaWCFClient objAgendaWCFClient; AgendaWCF.VBG01134Result objAgendaCliente; decimal? lineaCredito = null; DateTime?fechaVecimiento = null; string strLETRAS = ""; try { objAgendaWCFClient = new AgendaWCFClient(); objAgendaCliente = new AgendaWCF.VBG01134Result(); //List<gsPedidos_FechasLetrasSelectResult> lstFechas = new List<gsPedidos_FechasLetrasSelectResult>(); objOrdenVentaCab = objOrdenVentaWCF.OrdenVenta_Buscar(idEmpresa, codigoUsuario, int.Parse(idOrdenVenta), ref objOrdenVentaDet, ref lstImpuestos, ref bloqueado, ref mensajeBloqueo); objAgendaCliente = objAgendaWCFClient.Agenda_BuscarCliente_Contado(idEmpresa, codigoUsuario, objOrdenVentaCab.ID_Agenda, ref lineaCredito, ref fechaVecimiento, (int)objOrdenVentaCab.ID_Moneda); List <GlosaBE> Impuesto_Obtener_R = new List <GlosaBE>(); gsPedidos_FechasLetrasSelectResult[] lstFechas = objOrdenVentaWCF.PedidoLetras_Detalle(idEmpresa, codigoUsuario, 0, int.Parse(idOrdenVenta)); strLETRAS = PedidosFechas_Letras(lstFechas.ToList(), (DateTime)objOrdenVentaCab.FechaEmision); objOrdenVentaWCF.OrdenVenta_Registrar_Contado(idEmpresa, 1, OrdenVenta_ObtenerCabecera(objOrdenVentaCab, idOrdenVenta, lstImpuestos, ref Impuesto_Obtener_R), OrdenVenta_ObtenerDetalle(objOrdenVentaCab, objOrdenVentaDet, idEmpresa, codigoUsuario).ToArray(), Impuesto_Obtener_R.ToArray(), decimal.Parse(idOrdenVenta), Math.Abs((decimal)lineaCredito), (DateTime)fechaVecimiento, lstFechas, strLETRAS); //string pedido = "Realizado."; } catch (Exception ex) { throw new ArgumentException(ex.Message, ex.TargetSite.Name + "No se pudo registrar el pedido en la base de datos."); } }
private void OrdenVenta_Listar(string ID_Agenda, DateTime fechaInicial, DateTime fechaFinal, string ID_Vendedor, string Id_sectorista, int Estado, int FormaPago) { try { OrdenVentaWCFClient objOrdenVentaWCF = new OrdenVentaWCFClient(); List <gsOV_Listar_SectoristaResult> lst = objOrdenVentaWCF.OrdenVenta_Listar_Sectorista(((Usuario_LoginResult)Session["Usuario"]).idEmpresa, ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario, ID_Agenda, fechaInicial, fechaFinal, ID_Vendedor, ((Usuario_LoginResult)Session["Usuario"]).modificarPedido, Id_sectorista, Estado, FormaPago).ToList(); //var mock = new gsOV_Listar_SectoristaResult //{ // Agenda = "San Pedroxxxxx", // ID_Agenda = "20481018791", // AlmacenDespacho = "001" // ,Aprobacion1 = true // ,Aprobacion2 = false // ,Bloqueado = false // ,CondicionCredito = "001" // ,Creditos = true // ,Dcto = 1 // ,EntregaParcial = false // ,Envio = "no" //}; //var lstMock = new List<gsOV_Listar_SectoristaResult>(); //lstMock.Add(mock); //ViewState["lstOrdenVenta"] = JsonHelper.JsonSerializer(lstMock); //grdOrdenVenta.DataSource = lstMock; //grdOrdenVenta.DataBind(); ViewState["lstOrdenVenta"] = JsonHelper.JsonSerializer(lst); grdOrdenVenta.DataSource = lst; grdOrdenVenta.DataBind(); ViewState["fechaInicial"] = fechaInicial; ViewState["fechaFinal"] = fechaFinal; } catch (Exception ex) { throw ex; } }
//private void FormaPago_ComboBox() //{ // FormaPagoWCFClient objFormaPagoWCF; // VBG00890Result objFormaPago; // List<VBG00890Result> lstFormaPago; // try // { // objFormaPagoWCF = new FormaPagoWCFClient(); // objFormaPago = new VBG00890Result(); // objFormaPago.ID = -1; // objFormaPago.Nombre = "Todos"; // lstFormaPago = objFormaPagoWCF.FormaPago_Listar(((Usuario_LoginResult)Session["Usuario"]).idEmpresa, // ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario).ToList(); // lstFormaPago.Insert(0, objFormaPago); // cboFormaPago.DataSource = lstFormaPago; // cboFormaPago.DataValueField = "ID"; // cboFormaPago.DataTextField = "Nombre"; // cboFormaPago.DataBind(); // if (cboFormaPago.Items.Count > 0) // cboFormaPago.SelectedIndex = 0; // } // catch (Exception ex) // { // throw ex; // } //} private void OrdenVenta_Listar(string ID_Agenda, DateTime fechaInicial, DateTime fechaFinal, string ID_Vendedor) { try { OrdenVentaWCFClient objOrdenVentaWCF = new OrdenVentaWCFClient(); List <gsOV_ListarResult> lst = objOrdenVentaWCF.OrdenVenta_Listar(((Usuario_LoginResult)Session["Usuario"]).idEmpresa, ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario, ID_Agenda, fechaInicial, fechaFinal, ID_Vendedor, ((Usuario_LoginResult)Session["Usuario"]).modificarPedido).ToList(); ViewState["lstOrdenVenta"] = JsonHelper.JsonSerializer(lst); grdOrdenVenta.DataSource = lst; grdOrdenVenta.DataBind(); ViewState["fechaInicial"] = fechaInicial; ViewState["fechaFinal"] = fechaFinal; } catch (Exception ex) { throw ex; } }
private void OrdenVenta_Listar(string ID_Agenda, DateTime fechaInicial, DateTime fechaFinal, string ID_Vendedor, string Id_sectorista, int Estado, int FormaPago, int Bloqueo, int Flujo) { try { OrdenVentaWCFClient objOrdenVentaWCF = new OrdenVentaWCFClient(); List <gsOV_Listar_SectoristaResult> lst = objOrdenVentaWCF.OrdenVenta_Listar_Sectorista(((Usuario_LoginResult)Session["Usuario"]).idEmpresa, ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario, ID_Agenda, fechaInicial, fechaFinal, ID_Vendedor, ((Usuario_LoginResult)Session["Usuario"]).modificarPedido, Id_sectorista, Estado, FormaPago).ToList(); //----------Filtro de bloqueo if (Bloqueo == 1) { lst = lst.FindAll(x => x.sinStock == false && x.LimiteCredito == false && x.documentoPendiente == false).ToList(); } if (Bloqueo == 2) { lst = lst.FindAll(x => x.sinStock == true).ToList(); } if (Bloqueo == 3) { lst = lst.FindAll(x => x.LimiteCredito == true && x.sinStock == false).ToList(); } if (Bloqueo == 4) { lst = lst.FindAll(x => x.documentoPendiente == true && x.sinStock == false && x.LimiteCredito == false).ToList(); } //----------Filtro de flujo if (Flujo == 1) { lst = lst.FindAll(x => x.Aprobacion2 == false).ToList(); } if (Flujo == 2) { lst = lst.FindAll(y => y.Guia == 0 && y.Aprobacion2 == true).ToList(); } if (Flujo == 3) { lst = lst.FindAll(x => x.Factura == 0 && x.Guia > 0).ToList(); } if (Flujo == 4) { lst = lst.FindAll(x => x.Factura > 0 && x.Guia > 0).ToList(); } ViewState["lstOrdenVenta"] = JsonHelper.JsonSerializer(lst); grdOrdenVenta.DataSource = lst; grdOrdenVenta.DataBind(); ViewState["fechaInicial"] = fechaInicial; ViewState["fechaFinal"] = fechaFinal; } catch (Exception ex) { lblMensaje.Text = ex.Message; lblMensaje.CssClass = "mensajeError"; } }
//public static void ReadFileFromFTP(int idEmpresa, List<string> files, string RutaOrigen, string RutaSubmit, string RutaFail, string user, string pass) public static void ReadFileFromFTP(int idEmpresa, List <Cargar_Pedidos_ConfirmacionResult> ListaPedido) { List <gsInterfacePedidos_LeerResult> lstPedidos; //string Nombre; int codigoUsuario = 1; int idOrdenVenta; //foreach (Cargar_Pedidos_ConfirmacionResult file in ListaPedido) //{ try { lstPedidos = new List <gsInterfacePedidos_LeerResult>(); foreach (Cargar_Pedidos_ConfirmacionResult file in ListaPedido) { gsInterfacePedidos_LeerResult Pedido = new gsInterfacePedidos_LeerResult(); //Pedido.NroPedido = "30313"; // file.NumeroDeDocumento; // Campos[0]; //Op OV //Pedido.ID_Item = "10210109003514"; //( file.CodigoDeArticulo; // Campos[1]; //Item //Pedido.Lote = "170831-0171-2050"; // file.CodigoDeLote; // Campos[2]; //Lote //Pedido.CantidadPedido = 6; // (decimal)file.UnidadesPedido; // decimal.Parse(Campos[3]); //Cantidad //Pedido.CantidadEntrega = 6; // (decimal)file.UnidadesEntregadas; // int.Parse(Campos[4]); //Cantidad entregada //Pedido.CantidadPendiente = 0; // (decimal)(file.Diferencia); // decimal.Parse(Campos[5]); //Diferencia //Pedido.EstadoPedido = "D"; // file.Anticipado; // Campos[7]; // Estado //Pedido.Id_Amarre = 76851; // decimal.Parse(file.IDDeLinea); // decimal.Parse(Campos[8]); // Id_Amarre //Pedido.TransferidoTabla = "SILPT"; // file.Empresa; //Pedido.Servicio = file.NumeroDeAlbaran; /////////////------------------------------------------------- Pedido.NroPedido = file.NumeroDeDocumento; // Campos[0]; //Op OV Pedido.ID_Item = file.CodigoDeArticulo; // Campos[1]; //Item Pedido.Lote = file.CodigoDeLote; // Campos[2]; //Lote Pedido.CantidadPedido = (decimal)file.UnidadesPedido; // decimal.Parse(Campos[3]); //Cantidad Pedido.CantidadEntrega = (decimal)file.UnidadesEntregadas; // int.Parse(Campos[4]); //Cantidad entregada Pedido.CantidadPendiente = (decimal)(file.Diferencia); // decimal.Parse(Campos[5]); //Diferencia Pedido.EstadoPedido = file.Anticipado; // Campos[7]; // Estado Pedido.Id_Amarre = decimal.Parse(file.IDDeLinea); // decimal.Parse(Campos[8]); // Id_Amarre Pedido.TransferidoTabla = file.Empresa; Pedido.Servicio = file.NumeroDeAlbaran; lstPedidos.Add(Pedido); } lstPedidos = lstPedidos.OrderBy(x => x.Op).ToList(); foreach (gsInterfacePedidos_LeerResult pedido in lstPedidos) { try { WmsWCF.WmsWCFClient objWmsInsert = new WmsWCF.WmsWCFClient(); objWmsInsert.WmsPedidosPendientes_Insertar(idEmpresa, 1, pedido.NroPedido, pedido.ID_Item, pedido.Lote, decimal.Parse(pedido.CantidadPedido.ToString()), decimal.Parse(pedido.CantidadEntrega.ToString()), decimal.Parse(pedido.CantidadPendiente.ToString()), pedido.EstadoPedido, int.Parse(pedido.Id_Amarre.ToString())); //1=SILVESTRE; 2=NEOAGRUM; 6=INATEC //objWmsInsert.WmsPedidosPendientes_UpdateEstilos(idEmpresa, codigoUsuario, pedido.TransferidoTabla, pedido.Servicio); Console.Write("Se registro Op" + pedido.NroPedido + " - " + pedido.Id_Amarre); } catch (Exception ex) { Console.Write("Error: Registrar TXT: " + pedido.NroPedido.ToString() + "-" + pedido.ID_Item.ToString() + ", " + ex.Message.ToString()); } } Console.Write("Se registro los pedidos consumidos."); //---------------------------Pedido-------------------------------- //var lstOpOV = lstPedidos.Select(x => x.NroPedido).Distinct(); foreach (gsInterfacePedidos_LeerResult pedido in lstPedidos) { try { GuiaWCFClient objGuiaVentaWCF = new GuiaWCFClient(); OrdenVentaWCFClient objOrdenVentaWCF = new OrdenVentaWCFClient(); gsOV_BuscarCabeceraResult objOrdenVentaCab; gsOV_BuscarDetalleResult[] objOrdenVentaDet = null; gsGuia_BuscarCabeceraResult objGuiaVentaCab = new gsGuia_BuscarCabeceraResult(); gsGuia_BuscarDetalleResult[] objGuiaVentaDet = null; gsGuia_BuscarDetalleResult objGuiaVentaDetUpdate = null; gsOV_BuscarDetalleResult objOrdenVenta_Linea = null; List <DM.gsItem_BuscarResult> lstProductos = new List <DM.gsItem_BuscarResult>(); gsOV_BuscarImpuestoResult[] lstImpuestos = null; GuiaVenta_LotesItemsResult[] lstLotes = null; bool? bloqueado = false; string mensajeBloqueo = null; AgendaWCFClient objAgendaWCFClient; VBG01134Result objAgendaCliente; decimal?lineaCredito = null; decimal?Id_Amarre = 0; decimal?TC = 0; DateTime?fechaVecimiento = null; Console.Write("OP:" + pedido.NroPedido); objAgendaWCFClient = new AgendaWCFClient(); objAgendaCliente = new VBG01134Result(); idOrdenVenta = int.Parse(pedido.NroPedido.ToString()); objOrdenVentaCab = objOrdenVentaWCF.OrdenVenta_Buscar_Guia(idEmpresa, codigoUsuario, idOrdenVenta, ref objOrdenVentaDet, ref lstImpuestos, ref bloqueado, ref mensajeBloqueo); objAgendaCliente = objAgendaWCFClient.Agenda_BuscarCliente(idEmpresa, codigoUsuario, objOrdenVentaCab.ID_Agenda, ref lineaCredito, ref fechaVecimiento, ref TC); Id_Amarre = pedido.Id_Amarre; objOrdenVenta_Linea = objOrdenVentaDet.ToList().FindAll(x => x.ID_Amarre == Id_Amarre).Single(); int idGuiaOp = 0; int idGuiaOpLinea = 0; int item_id = 0; idGuiaOp = int.Parse(objOrdenVentaCab.OpGuia.ToString()); idGuiaOpLinea = int.Parse(objOrdenVenta_Linea.OpGuia.ToString()); item_id = int.Parse(objOrdenVenta_Linea.Item_ID.ToString()); if (objOrdenVenta_Linea == null) { } else { if (idGuiaOpLinea > 0) { objGuiaVentaCab = objGuiaVentaWCF.GuiaVenta_Buscar(idEmpresa, codigoUsuario, idGuiaOp, ref objGuiaVentaDet, ref bloqueado, ref mensajeBloqueo); } else { objGuiaVentaCab = GuiaVenta_ObtenerCabecera(objOrdenVentaCab, idGuiaOp); objGuiaVentaDet = GuiaVenta_ObtenerDetalle(objOrdenVentaCab, objOrdenVentaDet, idEmpresa, codigoUsuario).ToArray(); } if (idGuiaOp > 0) { lstLotes = objGuiaVentaWCF.GuiaVenta_LotesItemBuscar(idEmpresa, codigoUsuario, int.Parse(idGuiaOp.ToString()), int.Parse(objOrdenVenta_Linea.Item_ID.ToString())); } List <GuiaVenta_LotesItemsResult> LotesUp = new List <GuiaVenta_LotesItemsResult>(); if (lstLotes == null) { LotesUp = new List <GuiaVenta_LotesItemsResult>(); } else { LotesUp = ((GuiaVenta_LotesItemsResult[])lstLotes).ToList(); } objGuiaVentaDetUpdate = GuiaVenta_ObtenerDetalle_Update(objGuiaVentaDet, lstPedidos, Id_Amarre, ref LotesUp, item_id); lstLotes = (GuiaVenta_LotesItemsResult[])LotesUp.ToArray(); try { int Error = 0; int cont = 0; WmsWCF.WmsWCFClient objWmsInsert = new WmsWCF.WmsWCFClient(); List <VBG00971Result> Lista_LoteVar = objGuiaVentaWCF.GuiaVenta_BuscarLotesxItem(idEmpresa, 1, int.Parse(pedido.NroPedido), (int)item_id, (int)objGuiaVentaCab.ID_AlmacenAnexo, (int)pedido.Id_Amarre).ToList(); foreach (VBG00971Result Lote in Lista_LoteVar) { if (Lote.Lote == pedido.Lote) { cont++; break; } } if (cont == 0) { objWmsInsert.WmsPedidosPendientes_Update(idEmpresa, codigoUsuario, pedido.Lote, (int)pedido.Id_Amarre, "F", "No se encuentra Lote para el Item"); } else { try { objGuiaVentaWCF.GuiaVenta_Registrar(idEmpresa, 1, objGuiaVentaCab, objGuiaVentaDetUpdate, decimal.Parse(idGuiaOp.ToString()), lstLotes); objWmsInsert.WmsPedidosPendientes_UpdateEstilos(idEmpresa, codigoUsuario, pedido.TransferidoTabla, pedido.Servicio); objWmsInsert.WmsPedidosPendientes_Update(idEmpresa, codigoUsuario, pedido.Lote, (int)pedido.Id_Amarre, "S", "Se registro correctamente."); } catch (Exception ex) { objWmsInsert.WmsPedidosPendientes_Update(idEmpresa, codigoUsuario, pedido.Lote, (int)pedido.Id_Amarre, "F", "Error, al registrar la Guia."); Console.Write("Error al registrar guias: " + ex.Message.ToString()); } } } catch (Exception ex) { } } } catch (Exception ex) { Console.Write("Error: Registrar Guia: " + pedido.NroPedido.ToString() + "-" + pedido.ID_Item.ToString() + ", " + ex.Message.ToString()); } } ////------------------Mover archivos--------- // //MoverArchivos(RutaOrigen, RutaSubmit, file, user, pass); ////} } catch (Exception ex) { Console.Write("Error: Registrar Guia, " + ex.Message.ToString()); //MoverArchivos(RutaOrigen, RutaFail, file, user, pass); } //} }
static void Pedido_Cargar(string idOrdenVenta, int idEmpresa, int codigoUsuario) { OrdenVentaWCFClient objOrdenVentaWCF = new OrdenVentaWCFClient();; gsOV_BuscarCabeceraResult objOrdenVentaCab; List <GlosaBE> lstGlosa = new List <GlosaBE>(); ImpuestoWCFClient objImpuestoWCF = new ImpuestoWCFClient(); gsOV_BuscarImpuestoResult[] lstImpuestos = null; List <gsImpuesto_ListarPorItemResult> lstImpuestoItem = new List <gsImpuesto_ListarPorItemResult>(); gsOV_BuscarDetalleResult[] objOrdenVentaDet = null; List <gsItem_BuscarResult> lstProductos = new List <gsItem_BuscarResult>(); bool? bloqueado = false; string mensajeBloqueo = null; AgendaWCFClient objAgendaWCFClient; AgendaWCF.VBG01134Result objAgendaCliente; decimal? lineaCredito = null; DateTime?fechaVecimiento = null; string strLETRAS = ""; decimal? TC = 0; try { objAgendaWCFClient = new AgendaWCFClient(); objAgendaCliente = new AgendaWCF.VBG01134Result(); objOrdenVentaCab = objOrdenVentaWCF.OrdenVenta_Buscar(idEmpresa, codigoUsuario, int.Parse(idOrdenVenta), ref objOrdenVentaDet, ref lstImpuestos, ref bloqueado, ref mensajeBloqueo); objAgendaCliente = objAgendaWCFClient.Agenda_BuscarCliente(idEmpresa, codigoUsuario, objOrdenVentaCab.ID_Agenda, ref lineaCredito, ref fechaVecimiento, ref TC); List <GlosaBE> Impuesto_Obtener_R = new List <GlosaBE>(); gsPedidos_FechasLetrasSelectResult[] lstFechas = objOrdenVentaWCF.PedidoLetras_Detalle(idEmpresa, codigoUsuario, 0, int.Parse(idOrdenVenta)); strLETRAS = PedidosFechas_Letras(lstFechas.ToList(), (DateTime)objOrdenVentaCab.FechaEmision); //----------------------------------------------------------- gsOV_BuscarCabeceraResult cabecera = OrdenVenta_ObtenerCabecera(objOrdenVentaCab, idOrdenVenta, lstImpuestos, ref Impuesto_Obtener_R); gsOV_BuscarDetalleResult[] detalle = OrdenVenta_ObtenerDetalle(objOrdenVentaCab, objOrdenVentaDet, idEmpresa, codigoUsuario).ToArray(); int KardexFlete = 0; List <gsOV_BuscarDetalleResult> kardex = new List <gsOV_BuscarDetalleResult>(); gsOV_BuscarDetalleResult objetoFlete = new gsOV_BuscarDetalleResult(); kardex = detalle.ToList().FindAll(x => x.Item.Contains("Flete") && x.Estado == 1).ToList(); if (kardex.Count > 0) { KardexFlete = Convert.ToInt32(kardex[0].Item_ID); //----------------------------------------------------------- if (KardexFlete > 0) { objetoFlete = detalle.ToList().Find(x => x.Item_ID == KardexFlete && x.Estado == 1); } } // ---------------------------------------------------------- objOrdenVentaWCF.OrdenVenta_Registrar(idEmpresa, 1, cabecera, detalle, Impuesto_Obtener_R.ToArray(), decimal.Parse(idOrdenVenta), (decimal)lineaCredito, (DateTime)fechaVecimiento, lstFechas, strLETRAS, KardexFlete, objetoFlete); //objOrdenVentaWCF.OrdenVenta_Registrar(codEmpresa, codUsuario, cabecera, detalle, impuesto, idPedido, LineaCredito, // dtFechaVencimiento, fechas, PlanLetras, KardexFlete, objetoFlete); //string pedido = "Realizado."; } catch (Exception ex) { throw new ArgumentException(ex.Message, ex.TargetSite.Name + "No se pudo registrar el pedido en la base de datos."); } }
//public static void ReadFileFromFTP(int idEmpresa, List<string> files, string RutaOrigen, string RutaSubmit, string RutaFail, string user, string pass) public static void ReadFileFromFTP(int idEmpresa, DataTable ListaPedido, string esquema, string EmpresaPT) { //string Nombre; int codigoUsuario = 1; int idOrdenVenta; try { List <gsInterfacePedidos_LeerResult> lstPedidos = new List <gsInterfacePedidos_LeerResult>(); foreach (DataRow file in ListaPedido.Rows) { gsInterfacePedidos_LeerResult Pedido = new gsInterfacePedidos_LeerResult(); //Pedido.NroPedido = "30313"; // file.NumeroDeDocumento; // Campos[0]; //Op OV //Pedido.ID_Item = "10210109003514"; //( file.CodigoDeArticulo; // Campos[1]; //Item //Pedido.Lote = "170831-0171-2050"; // file.CodigoDeLote; // Campos[2]; //Lote //Pedido.CantidadPedido = 6; // (decimal)file.UnidadesPedido; // decimal.Parse(Campos[3]); //Cantidad //Pedido.CantidadEntrega = 6; // (decimal)file.UnidadesEntregadas; // int.Parse(Campos[4]); //Cantidad entregada //Pedido.CantidadPendiente = 0; // (decimal)(file.Diferencia); // decimal.Parse(Campos[5]); //Diferencia //Pedido.EstadoPedido = "D"; // file.Anticipado; // Campos[7]; // Estado //Pedido.Id_Amarre = 76851; // decimal.Parse(file.IDDeLinea); // decimal.Parse(Campos[8]); // Id_Amarre //Pedido.TransferidoTabla = "SILPT"; // file.Empresa; //Pedido.Servicio = file.NumeroDeAlbaran; //------------------------------------------------- Pedido.NroPedido = file["NumeroDeDocumento"]; // Campos[0]; //Op OV Pedido.ID_Item = file["CodigoDeArticulo"]; // Campos[1]; //Item Pedido.Lote = file["CodigoDeLote"]; // Campos[2]; //Lote Pedido.CantidadPedido = decimal.Parse(file["UnidadesPedido"].ToString()); // decimal.Parse(Campos[3]); //Cantidad Pedido.CantidadEntrega = decimal.Parse(file["UnidadesEntregadas"].ToString()); // int.Parse(Campos[4]); //Cantidad entregada Pedido.CantidadPendiente = decimal.Parse(file["Diferencia"].ToString()); // decimal.Parse(Campos[5]); //Diferencia Pedido.EstadoPedido = file["Anticipado"]; // Campos[7]; // Estado Pedido.Id_Amarre = decimal.Parse(file["IDDeLinea"].ToString()); // decimal.Parse(Campos[8]); // Id_Amarre Pedido.TransferidoTabla = file["CIF"]; Pedido.Servicio = file["NumeroDeAlbaran"]; lstPedidos.Add(Pedido); } lstPedidos = lstPedidos.OrderBy(x => x.NroPedido).ToList(); foreach (gsInterfacePedidos_LeerResult pedido in lstPedidos) { try { WmsWCF.WmsWCFClient objWmsInsert = new WmsWCF.WmsWCFClient(); objWmsInsert.WmsPedidosPendientes_Insertar(idEmpresa, 1, pedido.NroPedido.ToString(), pedido.ID_Item.ToString(), pedido.Lote.ToString(), decimal.Parse(pedido.CantidadPedido.ToString()), decimal.Parse(pedido.CantidadEntrega.ToString()), decimal.Parse(pedido.CantidadPendiente.ToString()), pedido.EstadoPedido.ToString(), int.Parse(pedido.Id_Amarre.ToString())); //1=SILVESTRE; 2=NEOAGRUM; 6=INATEC //objWmsInsert.WmsPedidosPendientes_UpdateEstilos(idEmpresa, codigoUsuario, pedido.TransferidoTabla, pedido.Servicio); Console.Write("Se registro Op" + pedido.NroPedido + " - " + pedido.Id_Amarre); } catch (Exception ex) { Console.Write("Error: Registrar TXT: " + pedido.NroPedido.ToString() + "-" + pedido.ID_Item.ToString() + ", " + ex.Message.ToString()); } } Console.Write("Se registro los pedidos consumidos."); Console.Write("..:Procesando Guias:.."); //---------------------------Pedido-------------------------------- //var lstOpOV = lstPedidos.Select(x => x.NroPedido).Distinct(); foreach (gsInterfacePedidos_LeerResult pedido in lstPedidos) { try { GuiaWCFClient objGuiaVentaWCF = new GuiaWCFClient(); OrdenVentaWCFClient objOrdenVentaWCF = new OrdenVentaWCFClient(); gsOV_BuscarCabeceraResult objOrdenVentaCab; gsOV_BuscarDetalleResult[] objOrdenVentaDet = null; gsGuia_BuscarCabeceraResult objGuiaVentaCab = new gsGuia_BuscarCabeceraResult(); gsGuia_BuscarDetalleResult[] objGuiaVentaDet = null; gsGuia_BuscarDetalleResult objGuiaVentaDetUpdate = null; gsOV_BuscarDetalleResult objOrdenVenta_Linea = null; List <gsItem_BuscarResult> lstProductos = new List <gsItem_BuscarResult>(); gsOV_BuscarImpuestoResult[] lstImpuestos = null; GuiaVenta_LotesItemsResult[] lstLotes = null; bool? bloqueado = false; string mensajeBloqueo = null; AgendaWCFClient objAgendaWCFClient; VBG01134Result objAgendaCliente; decimal?lineaCredito = null; decimal?Id_Amarre = 0; decimal?TC = 0; int variable = Convert.ToInt32(pedido.NroPedido); if (variable == 23876) { TC = TC; } DateTime?fechaVecimiento = null; Console.Write("OP:" + pedido.NroPedido); Console.Write(" "); objAgendaWCFClient = new AgendaWCFClient(); objAgendaCliente = new VBG01134Result(); idOrdenVenta = int.Parse(pedido.NroPedido.ToString()); Console.WriteLine("Inicio: objOrdenVentaWCF.OrdenVenta_Buscar_Guia"); objOrdenVentaCab = objOrdenVentaWCF.OrdenVenta_Buscar_Guia(idEmpresa, codigoUsuario, idOrdenVenta, ref objOrdenVentaDet, ref lstImpuestos, ref bloqueado, ref mensajeBloqueo); Console.WriteLine("Inicio: objAgendaWCFClient.Agenda_BuscarCliente"); objAgendaCliente = objAgendaWCFClient.Agenda_BuscarCliente(idEmpresa, codigoUsuario, objOrdenVentaCab.ID_Agenda, ref lineaCredito, ref fechaVecimiento, ref TC); Id_Amarre = (decimal)pedido.Id_Amarre; objOrdenVenta_Linea = objOrdenVentaDet.ToList().FindAll(x => x.ID_Amarre == Id_Amarre).Single(); int idGuiaOp = 0; int idGuiaOpLinea = 0; int item_id = 0; idGuiaOp = int.Parse(objOrdenVentaCab.OpGuia.ToString()); idGuiaOpLinea = int.Parse(objOrdenVenta_Linea.OpGuia.ToString()); item_id = int.Parse(objOrdenVenta_Linea.Item_ID.ToString()); if (objOrdenVenta_Linea == null) { } else { if (idGuiaOpLinea > 0) { Console.WriteLine("Inicio: objGuiaVentaWCF.GuiaVenta_Buscar"); objGuiaVentaCab = objGuiaVentaWCF.GuiaVenta_Buscar(idEmpresa, codigoUsuario, idGuiaOp, ref objGuiaVentaDet, ref bloqueado, ref mensajeBloqueo); } else { Console.WriteLine("Inicio: GuiaVenta_ObtenerCabecera"); objGuiaVentaCab = GuiaVenta_ObtenerCabecera(objOrdenVentaCab, idGuiaOp); Console.WriteLine("Inicio: GuiaVenta_ObtenerDetalle"); objGuiaVentaDet = GuiaVenta_ObtenerDetalle(objOrdenVentaCab, objOrdenVentaDet, idEmpresa, codigoUsuario).ToArray(); } if (idGuiaOp > 0) { Console.WriteLine("Inicio: objGuiaVentaWCF.GuiaVenta_LotesItemBuscar"); lstLotes = objGuiaVentaWCF.GuiaVenta_LotesItemBuscar(idEmpresa, codigoUsuario, int.Parse(idGuiaOp.ToString()), int.Parse(objOrdenVenta_Linea.Item_ID.ToString())); } List <GuiaVenta_LotesItemsResult> LotesUp = new List <GuiaVenta_LotesItemsResult>(); if (lstLotes == null) { LotesUp = new List <GuiaVenta_LotesItemsResult>(); } else { LotesUp = ((GuiaVenta_LotesItemsResult[])lstLotes).ToList(); } Console.WriteLine("Inicio: GuiaVenta_ObtenerDetalle_Update"); objGuiaVentaDetUpdate = GuiaVenta_ObtenerDetalle_Update(objGuiaVentaDet, lstPedidos, Id_Amarre, ref LotesUp, item_id); lstLotes = (GuiaVenta_LotesItemsResult[])LotesUp.ToArray(); try { int Error = 0; int cont = 0; WmsWCF.WmsWCFClient objWmsInsert = new WmsWCF.WmsWCFClient(); //List<VBG00971Result> Lista_LoteVar = objGuiaVentaWCF.GuiaVenta_BuscarLotesxItem(idEmpresa, 1, int.Parse(pedido.NroPedido), (int)item_id, (int)objGuiaVentaCab.ID_AlmacenAnexo, (int)pedido.Id_Amarre).ToList(); //List<VBG00971Result> Lista_LoteVar = dcg.VBG00971(item_id, ID_AlmacenAnexo, "GuiaVenta", 0, "OV", id_amarre).ToList(); DataTable dtTabla = new DataTable(); blTareo bl = new blTareo(); Console.WriteLine("Inicio de VBG00971_WMS"); //Lista Producción por recibir DataSet ds1 = bl.ListarDataSet( string.Format( //"set dateformat DMY\n" + "set dateformat " + getFormatDate() + "\n" + "exec " + esquema + "..VBG00971_WMS {0},{1},'GuiaVenta', 0, 'OV',{2},'{3}'", (int)item_id, (int)objGuiaVentaCab.ID_AlmacenAnexo, pedido.Id_Amarre.ToString(), pedido.Lote.ToString() ) ); //Busca registro de interfaz dtTabla = ds1.Tables[0]; dtTabla.Columns.Add("Consumo", typeof(int)); Console.WriteLine("Fin de VBG00971_WMS"); int Pendiente = 0; Pendiente = Convert.ToInt32(pedido.CantidadEntrega); foreach (DataRow Lote in dtTabla.Rows)//traer solo lotes iguales al lote del kardex { string strLote = Lote["Lote"].ToString(); if (strLote == pedido.Lote.ToString()) { int Consumo = 0; int CantLote = Convert.ToInt32(Lote[10]); if (CantLote >= Pendiente) { Consumo = Pendiente; Pendiente = 0; } else { Consumo = CantLote; Pendiente = Pendiente - CantLote; } Lote["Consumo"] = Consumo; cont++; if (Pendiente <= 0) { break; } } } if (cont == 0) { //objWmsInsert.WmsPedidosPendientes_Update(idEmpresa, codigoUsuario, pedido.Lote, (int)pedido.Id_Amarre, "F", "No se encuentra Lote para el Item"); DataSet ds11 = bl.ListarDataSet( string.Format( "set dateformat DMY\n" + "exec " + esquema + "..gsInterfacePedidos_Update '{0}',{1},{2},'{3}'", pedido.Lote.ToString(), pedido.Id_Amarre.ToString(), "'F'", "No se encuentra Lote para el Item" )); //dcg.gsInterfacePedidos_Update(Lote, Id_Amarre, transferido, observacion); } else { try { Console.WriteLine("Registrando Guia y moviendo el Inv."); objGuiaVentaWCF.GuiaVenta_Registrar_wms(idEmpresa, 1, objGuiaVentaCab, objGuiaVentaDetUpdate, decimal.Parse(idGuiaOp.ToString()), lstLotes, EmpresaPT, pedido.Servicio.ToString(), pedido.Lote.ToString(), pedido.Id_Amarre.ToString()); Console.WriteLine("Finalizado"); //DataSet ds13 = bl.ListarDataSet( // string.Format( // "set dateformat DMY\n" + // "exec " + esquema + "..Cargar_Pedidos_UpdateEstilos '{0}','{1}'", // EmpresaPT, pedido.Servicio.ToString() // )); //DataSet ds14 = bl.ListarDataSet( // string.Format( // "set dateformat DMY\n" + // "exec " + esquema + "..gsInterfacePedidos_Update '{0}',{1},'{2}','{3}'", // pedido.Lote.ToString(), pedido.Id_Amarre.ToString(), "S", "Se registro correctamente." // )); } catch (Exception ex) { //objWmsInsert.WmsPedidosPendientes_Update(idEmpresa, codigoUsuario, pedido.Lote, (int)pedido.Id_Amarre, "F", "Error, al registrar la Guia."); //DataSet ds12 = bl.ListarDataSet( //string.Format( //"set dateformat DMY\n" + //"exec " + esquema + "..gsInterfacePedidos_Update '{0}',{1},'{2}','{3}'", //pedido.Lote.ToString(), pedido.Id_Amarre.ToString(), "F", "Error: al registrar Guía" //)); Console.Write("Error al registrar guias: " + ex.Message.ToString()); } } } catch (Exception ex) { blTareo bl = new blTareo(); DataSet ds15 = bl.ListarDataSet( string.Format( "set dateformat DMY\n" + "exec " + esquema + "..gsInterfacePedidos_Update '{0}',{1},'{2}','{3}'", pedido.Lote.ToString(), pedido.Id_Amarre.ToString(), "F", "Error: al registrar Guía" )); Console.Write("Error al registrar guias: " + ex.Message.ToString()); } } } catch (Exception ex) { blTareo bl = new blTareo(); DataSet ds16 = bl.ListarDataSet( string.Format( "set dateformat DMY\n" + "exec " + esquema + "..gsInterfacePedidos_Update '{0}',{1},'{2}','{3}'", pedido.Lote.ToString(), pedido.Id_Amarre.ToString(), "F", "Error: al registrar Guía" )); Console.Write("Error: Registrar Guia: " + pedido.NroPedido.ToString() + "-" + pedido.ID_Item.ToString() + ", " + ex.Message.ToString()); } } ////------------------Mover archivos--------- // //MoverArchivos(RutaOrigen, RutaSubmit, file, user, pass); ////} } catch (Exception ex) { Console.Write("Error: Registrar Guia, " + ex.Message.ToString()); //MoverArchivos(RutaOrigen, RutaFail, file, user, pass); } //} }