Beispiel #1
0
        private void Carga_Vendedores(int id_zona, string id_vendedor)
        {
            try
            {
                AgendaWCFClient                objAgendaWCF = new AgendaWCFClient();
                gsVendedor_ListarResult        objVendedor  = new gsVendedor_ListarResult();
                List <gsVendedor_ListarResult> lstVendedor;

                lstVendedor = objAgendaWCF.Agenda_ListarVendedorProyectado(((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).idEmpresa,
                                                                           ((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).codigoUsuario, id_zona, id_vendedor).ToList();

                lstVendedor.Insert(0, objVendedor);
                objVendedor.ID_Agenda    = "0";
                objVendedor.AgendaNombre = "Todos";

                var lstVendedores = from x in lstVendedor
                                    select new
                {
                    x.ID_Agenda,
                    DisplayID    = x.ID_Agenda.ToString(),
                    DisplayField = String.Format("{0} - {1}", x.ID_Agenda, x.AgendaNombre)
                };

                cboVendedor.DataSource     = lstVendedores;
                cboVendedor.DataTextField  = "DisplayField";
                cboVendedor.DataValueField = "DisplayID";
                cboVendedor.DataBind();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #2
0
        private void Sectorista_Cargar()
        {
            try
            {
                AgendaWCFClient                   objAgendaWCF  = new AgendaWCFClient();
                gsUsuario_SectoristaResult        objSectorista = new gsUsuario_SectoristaResult();
                List <gsUsuario_SectoristaResult> lstSectorista;

                lstSectorista = objAgendaWCF.Agenda_ListarSectorista(((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).idEmpresa,
                                                                     ((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).codigoUsuario, null, 1).ToList();

                var lstSect = from x in lstSectorista
                              select new
                {
                    x.ID_Agenda,
                    DisplayField = x.AgendaNombre
                                   //DisplayField = String.Format("{0} {1} {2} {3}", x.Placa, x.Modelo, x.Marca, x.Agenda)
                };

                cbSectorista.DataSource     = lstSect;
                cbSectorista.DataTextField  = "DisplayField";
                cbSectorista.DataValueField = "ID_Agenda";
                cbSectorista.DataBind();

                cbSectorista.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static AutoCompleteBoxData Agenda_UsuarioBuscar(object context)
        {
            string idempresa;
            string idCargo;

            AutoCompleteBoxData res = new AutoCompleteBoxData();
            string searchString     = ((Dictionary <string, object>)context)["Text"].ToString();

            if (!string.IsNullOrEmpty(searchString) && searchString.Length >= 4)
            {
                AgendaWCFClient objAgenda = new AgendaWCFClient();

                idempresa = HttpContext.Current.Session["idempresa"].ToString();



                List <gsAgenda_ListarClienteResult> lst = objAgenda.Agenda_ListarCliente(int.Parse(idempresa),
                                                                                         ((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).codigoUsuario, searchString, 0).ToList();
                List <AutoCompleteBoxItemData> result = new List <AutoCompleteBoxItemData>();

                foreach (gsAgenda_ListarClienteResult usuario in lst)
                {
                    if (result.FindAll(x => x.Text == usuario.ID_Agenda + "-" + usuario.Nombre).Count == 0)
                    {
                        AutoCompleteBoxItemData childNode = new AutoCompleteBoxItemData();
                        childNode.Text  = usuario.ID_Agenda + "-" + usuario.Nombre;
                        childNode.Value = usuario.ID_Agenda.ToString();

                        result.Add(childNode);
                    }
                }
                res.Items = result.ToArray();
            }
            return(res);
        }
Beispiel #4
0
        private void Cliente_Buscar(string idAgenda)
        {
            AgendaWCFClient objAgendaWCFClient;
            VBG01134Result  objAgendaCliente;
            decimal?        lineaCredito    = null;
            decimal?        TC              = null;
            DateTime?       fechaVecimiento = null;

            try
            {
                objAgendaWCFClient = new AgendaWCFClient();
                objAgendaCliente   = new VBG01134Result();

                objAgendaCliente = objAgendaWCFClient.Agenda_BuscarCliente(((Usuario_LoginResult)Session["Usuario"]).idEmpresa,
                                                                           ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario, idAgenda, ref lineaCredito, ref fechaVecimiento, ref TC);

                String txtClienteObj = objAgendaCliente.Nombre;

                ViewState["LineaCredito"]     = lineaCredito;
                ViewState["FechaVencimiento"] = fechaVecimiento;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void Transporte_Buscar(string idAgenda)
        {
            AgendaWCFClient objAgendaWCFClient;

            gsAgenda_ListarTransportistaResult[] objAgendaCliente;

            try
            {
                objAgendaWCFClient = new AgendaWCFClient();

                objAgendaCliente = objAgendaWCFClient.Agenda_ListarTransportista(((Usuario_LoginResult)Session["Usuario"]).idEmpresa,
                                                                                 ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario, idAgenda);

                //if (!string.IsNullOrEmpty(objAgendaCliente[0].Ruc))
                //    {
                //    txtRUCTransporte.Text = objAgendaCliente[0].Ruc;
                //    txtTransporte.Text = objAgendaCliente[0].Nombre;
                //    lblCodigoTransportista.Value = idAgenda;
                //    Session["Id_Transporte"] = idAgenda;
                //}
                //else
                //{
                //    txtRUCTransporte.Text = idAgenda;
                //    lblCodigoTransportista.Value = idAgenda;
                //    Session["Id_Transporte"] = idAgenda;
                //}
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        //private void Despacho_CargarTipo()
        //{
        //    DespachoWCFClient objDespachoWVF;
        //    try
        //    {
        //        objDespachoWVF = new DespachoWCFClient();
        //        cboOpDespacho.DataSource = objDespachoWVF.Despacho_ListarTipo(((Usuario_LoginResult)Session["Usuario"]).idEmpresa,
        //            ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario);
        //        cboOpDespacho.DataTextField = "Nombre";
        //        cboOpDespacho.DataValueField = "ID";
        //        cboOpDespacho.DataBind();

        //        if (cboOpDespacho.Items.Count > 0)
        //            cboOpDespacho.SelectedIndex = 0;
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //}

        //private void GuiaVentasFlujo_CargarTipo()
        //{
        //    GuiaVentasFlujoWCFClient objGuiaVentasFlujoWCF;
        //    try
        //    {
        //        objGuiaVentasFlujoWCF = new GuiaVentasFlujoWCFClient();
        //        cboOpTipoGuiaVentasFlujo.DataSource = objGuiaVentasFlujoWCF.GuiaVentasFlujo_ListarTipo(((Usuario_LoginResult)Session["Usuario"]).idEmpresa,
        //            ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario);
        //        cboOpTipoGuiaVentasFlujo.DataTextField = "Nombre";
        //        cboOpTipoGuiaVentasFlujo.DataValueField = "ID";
        //        cboOpTipoGuiaVentasFlujo.DataBind();

        //        if (cboOpTipoGuiaVentasFlujo.Items.Count > 0)
        //            cboOpTipoGuiaVentasFlujo.SelectedIndex = 0;
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //}

        //private void Documento_CagarTipoVenta()
        //{
        //    DocumentoWCFClient objDocumentoWCF;
        //    try
        //    {
        //        objDocumentoWCF = new DocumentoWCFClient();
        //        cboOpDocVenta.DataSource = objDocumentoWCF.Documento_ListarDocVenta(((Usuario_LoginResult)Session["Usuario"]).idEmpresa,
        //            ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario);
        //        cboOpDocVenta.DataTextField = "Nombre";
        //        cboOpDocVenta.DataValueField = "ID";
        //        cboOpDocVenta.DataBind();

        //        if (cboOpDocVenta.Items.Count > 0)
        //            cboOpDocVenta.SelectedIndex = 0;
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //}

        //private void Almacen_Cargar()
        //{
        //    AgendaWCFClient objAgendaWCF;
        //    try
        //    {
        //        objAgendaWCF = new AgendaWCFClient();
        //        cboAlmacen.DataSource = objAgendaWCF.AgendaAnexo_ListarAlmacen(((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).idEmpresa, ((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).codigoUsuario);
        //        cboAlmacen.DataTextField = "AlmacenAnexo";
        //        cboAlmacen.DataValueField = "ID_AlmacenAnexo";
        //        cboAlmacen.DataBind();

        //        if (cboAlmacen.Items.Count > 0)
        //            cboAlmacen.SelectedIndex = 0;
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //}

        //private void Credito_Cargar(string idAgenda)
        //{
        //    CreditoWCFClient objCreditoWCF;
        //    try
        //    {
        //        objCreditoWCF = new CreditoWCFClient();

        //        var datasource = from x in objCreditoWCF.Credito_ListarCondicion(((Usuario_LoginResult)Session["Usuario"]).idEmpresa,
        //            ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario, idAgenda)
        //                         select new
        //                         {
        //                             ValueField = String.Format("{0},{1}", x.ID_CondicionCredito, x.DiasCredito),
        //                             TextField = String.Format("{0}", x.Nombre)
        //                         };

        //        cboTipoCredito.DataSource = datasource;
        //        cboTipoCredito.DataTextField = "TextField";
        //        cboTipoCredito.DataValueField = "ValueField";
        //        cboTipoCredito.DataBind();

        //        if (cboTipoCredito.Items.Count > 0)
        //        {
        //            cboTipoCredito.SelectedIndex = 0;
        //            txtDiasCredito.Text = cboTipoCredito.SelectedValue.Split(',')[1];
        //            dpFechaEmision.SelectedDate = DateTime.Now;
        //            dpFechaVencimiento.SelectedDate = DateTime.Now.AddDays(Int32.Parse(txtDiasCredito.Text));
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //}

        //private void Envio_Cargar()
        //{
        //    EnvioWCFClient objEnvioWCF;
        //    try
        //    {
        //        objEnvioWCF = new EnvioWCFClient();

        //        cboTipoEnvio.DataSource = objEnvioWCF.Envio_ListarTipo(((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).idEmpresa, ((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).codigoUsuario);
        //        cboTipoEnvio.DataTextField = "Nombre";
        //        cboTipoEnvio.DataValueField = "ID";
        //        cboTipoEnvio.DataBind();

        //        if (cboTipoEnvio.Items.Count > 0)
        //            cboTipoEnvio.SelectedValue = "2";
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //}

        //private void Sede_Cagar()
        //{
        //    SedeWCFClient objSedeWCF;
        //    VBG02689Result objSede;
        //    List<VBG02689Result> lstSedes;
        //    try
        //    {
        //        objSedeWCF = new SedeWCFClient();
        //        objSede = new VBG02689Result();
        //        objSede.Nombre = "Ninguno";
        //        objSede.ID_Sede = -1;

        //        lstSedes = objSedeWCF.RRHHSede_Listar(((Usuario_LoginResult)Session["Usuario"]).idEmpresa, ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario).ToList();
        //        lstSedes.Insert(0, objSede);
        //        cboSede.DataSource = lstSedes;
        //        cboSede.DataTextField = "Nombre";
        //        cboSede.DataValueField = "ID_Sede";
        //        cboSede.DataBind();

        //        if (cboSede.Items.Count > 0)
        //            cboSede.SelectedIndex = 0;
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //}

        private void Sucursal_Cargar(string idAgenda, RadComboBox cbobox)
        {
            AgendaWCFClient       objAgendaWCFC;
            List <VBG00167Result> lstSucursal;
            VBG00167Result        objSucursal;

            try
            {
                objAgendaWCFC = new AgendaWCFClient();
                objSucursal   = new VBG00167Result();

                lstSucursal        = objAgendaWCFC.AgendaAnexo_ListarDireccionCliente(((Usuario_LoginResult)Session["Usuario"]).idEmpresa, ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario, idAgenda).ToList();
                objSucursal.ID     = -1;
                objSucursal.Nombre = "Central";
                lstSucursal.Insert(0, objSucursal);

                cbobox.DataSource     = lstSucursal;
                cbobox.DataTextField  = "Nombre";
                cbobox.DataValueField = "ID";
                cbobox.DataBind();

                if (cbobox.Items.Count > 0)
                {
                    cbobox.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void Cliente_Buscar(string idAgenda)
        {
            AgendaWCFClient objAgendaWCFClient;
            VBG01134Result  objAgendaCliente;
            decimal?        lineaCredito    = null;
            DateTime?       fechaVecimiento = null;
            decimal?        TC = null;

            try
            {
                objAgendaWCFClient = new AgendaWCFClient();
                objAgendaCliente   = new VBG01134Result();

                objAgendaCliente = objAgendaWCFClient.Agenda_BuscarCliente(((Usuario_LoginResult)Session["Usuario"]).idEmpresa,
                                                                           ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario, idAgenda, ref lineaCredito, ref fechaVecimiento, ref TC);

                //if (!string.IsNullOrEmpty(objAgendaCliente.RUC))
                //{
                //    txtRUCCliente.Text = objAgendaCliente.RUC;
                //    txtNombreCliente.Text = objAgendaCliente.Nombre;
                //    lblCodigoCliente.Value = objAgendaCliente.RUC;
                //}
                //else
                //{
                //    txtRUCCliente.Text = idAgenda;
                //}
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static AutoCompleteBoxData Agenda_ChoferBuscar(object context)
        {
            string transporte;
            string chofer;

            AutoCompleteBoxData res = new AutoCompleteBoxData();
            string searchString     = ((Dictionary <string, object>)context)["Text"].ToString();

            if (searchString.Length > 2)
            {
                transporte = HttpContext.Current.Session["Id_Transporte"].ToString();
                chofer     = null;


                AgendaWCFClient         objAgendaWCFClient = new AgendaWCFClient();
                gsChofer_ListarResult[] lst = objAgendaWCFClient.Agenda_ListarChofer(((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).idEmpresa,
                                                                                     ((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).codigoUsuario, transporte, chofer, searchString);
                List <AutoCompleteBoxItemData> result = new List <AutoCompleteBoxItemData>();


                foreach (gsChofer_ListarResult agenda in lst)
                {
                    AutoCompleteBoxItemData childNode = new AutoCompleteBoxItemData();
                    childNode.Text  = agenda.ID_Chofer + "-" + agenda.Nombre;
                    childNode.Value = agenda.ID_Chofer;
                    result.Add(childNode);
                }
                res.Items = result.ToArray();
            }
            return(res);
        }
        //private gsGuiaVenta_ListarxOPResult GuiaVenta_ObtenerCambios()
        //{
        //    gsGuiaVenta_ListarxOPResult objGuiaVentasFlujo;
        //    try
        //    {
        //        objGuiaVentasFlujo = new gsGuiaVenta_ListarxOPResult();

        //        objGuiaVentasFlujo.id_agenda = lblCodigoCliente.Value;
        //        objGuiaVentasFlujo.ID_AgendaDireccion = int.Parse(cboFacturacionCliente.SelectedValue);
        //        objGuiaVentasFlujo.ID_AgendaDireccion2 = int.Parse(cboDespacho.SelectedValue);

        //        objGuiaVentasFlujo.DireccionOrigenAgenda = lblCodigoOrigen.Value;
        //        objGuiaVentasFlujo.DireccionOrigenSucursal = int.Parse(cboSucursalOrigen.SelectedValue);
        //        objGuiaVentasFlujo.DireccionOrigenReferencia = int.Parse(cboReferenciaOrigen.SelectedValue);
        //        objGuiaVentasFlujo.DireccionOrigenDireccion = int.Parse(cboFacturacionOrigen.SelectedValue);

        //        objGuiaVentasFlujo.DireccionDestinoAgenda = lblCodigoDestino.Value;
        //        objGuiaVentasFlujo.DireccionDestinoSucursal = int.Parse(cboSucursalDestino.SelectedValue);
        //        objGuiaVentasFlujo.DireccionDestinoReferencia = int.Parse(cboReferenciaDestino.SelectedValue);
        //        objGuiaVentasFlujo.DireccionDestinoDireccion = int.Parse(cboFacturacionDestino.SelectedValue);

        //        objGuiaVentasFlujo.ID_Transportista = lblCodigoTransportista.Value;

        //        objGuiaVentasFlujo.ID_Chofer = txtIDChofer.Text;
        //        objGuiaVentasFlujo.TransportistaChofer = txtChofer.Text;
        //        objGuiaVentasFlujo.TransportistaCertInscripcion = txtCertificado.Text;
        //        objGuiaVentasFlujo.TransportistaLicencia = txtLicencia.Text;
        //        objGuiaVentasFlujo.TransportistaMarca = txtVehiculoMarca.Text;

        //        objGuiaVentasFlujo.ID_Vehiculo  = txtVehiculoPlaca.Text;
        //        objGuiaVentasFlujo.TransportistaModelo = txtVehiculoModelo.Text;
        //        objGuiaVentasFlujo.TransportistaPlaca = txtVehiculoPlaca.Text;
        //        objGuiaVentasFlujo.TransportistaRUC = txtRUCTransporte.Text;

        //        objGuiaVentasFlujo.FechaDespacho = dpFechaDespacho.SelectedDate.Value;
        //        objGuiaVentasFlujo.FechaTraslado = dpFechaTraslado.SelectedDate.Value;
        //        objGuiaVentasFlujo.FechaEmision = dpFechaEmision.SelectedDate.Value;

        //        return objGuiaVentasFlujo;
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //}

        private void Referencia_Cargar(string idAgenda, int idSucursal, RadComboBox cbobox)
        {
            AgendaWCFClient       objAgendaWCF;
            VBG02699Result        objReferencia;
            List <VBG02699Result> lstReferencias;

            try
            {
                objAgendaWCF         = new AgendaWCFClient();
                objReferencia        = new VBG02699Result();
                objReferencia.ID     = -1;
                objReferencia.Nombre = "Ninguno";

                lstReferencias = objAgendaWCF.AgendaAnexoReferencia_ListarPorSucursal(((Usuario_LoginResult)Session["Usuario"]).idEmpresa,
                                                                                      ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario, idSucursal, idAgenda).ToList();
                lstReferencias.Insert(0, objReferencia);

                cbobox.DataSource     = lstReferencias;
                cbobox.DataTextField  = "Nombre";
                cbobox.DataValueField = "ID";
                cbobox.DataBind();

                if (cbobox.Items.Count > 0)
                {
                    cbobox.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void Almacen_Cargar()
        {
            try
            {
                AgendaWCFClient       objAgendaWCF = new AgendaWCFClient();
                VBG00746Result        objAlmacen   = new VBG00746Result();
                List <VBG00746Result> lstAlmacen;

                lstAlmacen = objAgendaWCF.AgendaAnexo_ListarAlmacen(((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).idEmpresa,
                                                                    ((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).codigoUsuario).ToList();

                lstAlmacen.Insert(0, objAlmacen);
                objAlmacen.AlmacenAnexo = "Todos";
                objAlmacen.ID_Almacen   = "";

                cboAlmacen.DataSource     = lstAlmacen;
                cboAlmacen.DataTextField  = "AlmacenAnexo";
                cboAlmacen.DataValueField = "ID_AlmacenAnexo";
                cboAlmacen.DataBind();

                cboAlmacen.SelectedValue = "0";
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #11
0
        private void Zona_Cargar(int id_zona)
        {
            try
            {
                AgendaWCFClient            objAgendaWCF = new AgendaWCFClient();
                gsZona_ListarResult        objZona      = new gsZona_ListarResult();
                List <gsZona_ListarResult> lstZona;

                lstZona = objAgendaWCF.Agenda_ListarZona(((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).idEmpresa,
                                                         ((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).codigoUsuario, id_zona).ToList();

                lstZona.Insert(0, objZona);
                objZona.Zona    = "Todos";
                objZona.ID_Zona = 0;

                var lstZonas = from x in lstZona
                               select new
                {
                    x.ID_Zona,
                    DisplayID    = String.Format("{0}", x.ID_Zona),
                    DisplayField = String.Format("{0}", x.Zona)
                                   //DisplayField = String.Format("{0} {1} {2} {3}", x.Placa, x.Modelo, x.Marca, x.Agenda)
                };

                cboZona.DataSource     = lstZonas;
                cboZona.DataTextField  = "DisplayField";
                cboZona.DataValueField = "DisplayID";
                cboZona.DataBind();
            }
            catch (Exception ex)
            {
                lblMensaje.Text     = ex.Message;
                lblMensaje.CssClass = "mensajeError";
            }
        }
Beispiel #12
0
        private void Transporte_Cargar()
        {
            try
            {
                AgendaWCFClient               objAgendaWCF = new AgendaWCFClient();
                gsPlaca_DespachoResult        objPlaca     = new gsPlaca_DespachoResult();
                List <gsPlaca_DespachoResult> lstPlaca;

                lstPlaca = objAgendaWCF.Agenda_ListarPlaca_Despacho(((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).idEmpresa,
                                                                    ((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).codigoUsuario, null, null, null, "DESPACHO").ToList();
                lstPlaca.Insert(0, objPlaca);
                objPlaca.Placa = "Seleccionar";
                objPlaca.ID    = 0;

                var lstPlacas = from x in lstPlaca
                                select new
                {
                    x.ID,
                    DisplayField = String.Format("{0}", x.Placa)
                                   //DisplayField = String.Format("{0} {1} {2} {3}", x.Placa, x.Modelo, x.Marca, x.Agenda)
                };

                cboTransporte.DataSource     = lstPlacas;
                cboTransporte.DataTextField  = "DisplayField";
                cboTransporte.DataValueField = "ID";
                cboTransporte.DataBind();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static AutoCompleteBoxData Agenda_VehiculoBuscar(object context)
        {
            string transporte;
            string Vehiculo;

            AutoCompleteBoxData res = new AutoCompleteBoxData();
            string searchString     = ((Dictionary <string, object>)context)["Text"].ToString();

            if (searchString.Length > 2)
            {
                transporte = HttpContext.Current.Session["Id_Transporte"].ToString();
                Vehiculo   = null;

                AgendaWCFClient         objAgendaWCFClient = new AgendaWCFClient();
                gsPlaca_ListarResult [] lst = objAgendaWCFClient.Agenda_ListarPlaca(((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).idEmpresa,
                                                                                    ((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).codigoUsuario, transporte, Vehiculo, searchString);
                List <AutoCompleteBoxItemData> result = new List <AutoCompleteBoxItemData>();


                foreach (gsPlaca_ListarResult agenda in lst)
                {
                    AutoCompleteBoxItemData childNode = new AutoCompleteBoxItemData();
                    childNode.Text  = agenda.ID_Vehiculo + "/" + agenda.Marca + "/" + agenda.Modelo + "/" + agenda.Linea;
                    childNode.Value = agenda.ID_Vehiculo;
                    result.Add(childNode);
                }
                res.Items = result.ToArray();
            }
            return(res);
        }
        protected void btnBuscarUsuario_Click(object sender, EventArgs e)
        {
            if (Session["Usuario"] == null)
            {
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "mykey", "CancelEdit();", true);
            }
            AgendaWCFClient objAgenda = new AgendaWCFClient();

            gsAgenda_ListarClienteResult objUsuario = new gsAgenda_ListarClienteResult();

            try
            {
                objUsuario = objAgenda.Agenda_ListarCliente(
                    int.Parse(cboEmpresa.SelectedValue), ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario,
                    acbUsuario.Text.Split('-')[1], 0).Single();

                hfIdUsuario.Value = objUsuario.ID_Agenda.ToString();

                txtNroDocumento.Text = objUsuario.ID_Agenda;
                txtNombre.Text       = objUsuario.Nombre;

                btnGuardar.Enabled  = true;
                btnGuardar.Visible  = true;
                btnCancelar.Visible = true;
                btnEditar.Visible   = false;

                txtNombre.Enabled       = false;
                txtNroDocumento.Enabled = false;
                cboEmpresa.Enabled      = false;

                cboReporte.Enabled = false;
                cboEstado.Enabled  = true;

                ltbZonas.Enabled = true;

                if (objUsuario.Estado == "Activo")
                {
                    cboEstado.SelectedValue = "1";
                    lblMensaje.Text         = "Listo para registrar Colaborador";
                    lblMensaje.CssClass     = "mensajeExito";
                }
                else
                {
                    cboEstado.SelectedValue = "0";
                    lblMensaje.Text         = "La agenda está bloqueada. Comuníquese con el responsable.";
                    lblMensaje.CssClass     = "mensajeError";
                }


                //Reporte_Cargar(cboEmpresa.SelectedValue.ToString(), objUsuario.idUsuario);
            }
            catch (Exception ex)
            {
                lblMensaje.Text     = ex.Message;
                lblMensaje.CssClass = "mensajeError";
            }
        }
Beispiel #15
0
        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());
                    }
                }
            }
        }
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            if (Session["Usuario"] == null)
            {
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "mykey", "CancelEdit();", true);
            }

            VBG01134_validarCorreoResult objCliente = new VBG01134_validarCorreoResult();
            AgendaWCFClient objAgendaWCFClient      = new AgendaWCFClient();
            int?            Correlativo             = 0;

            try
            {
                if (IsValidEmail(txtCorreo.Text) == true)
                {
                    objCliente.ID_Agenda = lblId_Agenda.Text;
                    objCliente.Email     = txtCorreo.Text;


                    objAgendaWCFClient = new AgendaWCFClient();
                    objAgendaWCFClient.Agenda_RegistrarCorreo(((Usuario_LoginResult)Session["Usuario"]).idEmpresa,
                                                              ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario, objCliente.ID_Agenda, objCliente.Email, ref Correlativo);

                    if (Correlativo > 0)
                    {
                        lblMensaje.Text     = "El correo se registro correctamente, verificar.";
                        lblMensaje.CssClass = "mensajeExito";

                        ScriptManager.RegisterStartupScript(Page, this.GetType(), "mykey", "CloseAndRebind(" + objCliente.ID_Agenda + ");", true);
                    }
                    else
                    {
                        lblMensaje.Text     = "El correo no pudo ser registro, verificar.";
                        lblMensaje.CssClass = "mensajeError";
                    }
                }
                else
                {
                    lblMensaje.Text     = "El correo electrónico está mal escrito. ";
                    lblMensaje.CssClass = "mensajeError";
                }
            }
            catch (Exception ex)
            {
                lblMensaje.Text     = ex.Message;
                lblMensaje.CssClass = "mensajeError";
            }
        }
Beispiel #17
0
        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 Destino_Buscar(string idAgenda)
        {
            AgendaWCFClient objAgendaWCFClient;
            VBG01134Result  objAgendaCliente;
            decimal?        lineaCredito    = null;
            DateTime?       fechaVecimiento = null;
            decimal?        TC = null;

            try
            {
                objAgendaWCFClient = new AgendaWCFClient();
                objAgendaCliente   = new VBG01134Result();

                objAgendaCliente = objAgendaWCFClient.Agenda_BuscarCliente(((Usuario_LoginResult)Session["Usuario"]).idEmpresa,
                                                                           ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario, idAgenda, ref lineaCredito, ref fechaVecimiento, ref TC);

                //txtDestino.Text = objAgendaCliente.Nombre;
                //if (!string.IsNullOrEmpty(objAgendaCliente.RUC))
                //    txtRUCDestino.Text = objAgendaCliente.RUC;
                //else
                //{
                //    txtRUCDestino.Text = idAgenda;
                //    lblRUC.Text = "DNI";
                //}
                //txtTEA.Text = objAgendaCliente.TEA.ToString();
                //txtDiasCredito.Text = objAgendaCliente.DiasCredito.ToString();
                //cboMoneda.SelectedValue = objAgendaCliente.ID_MonedaCompra.ToString();
                ViewState["LineaCredito"]     = lineaCredito;
                ViewState["FechaVencimiento"] = fechaVecimiento;
                if (lineaCredito <= 0)
                {
                    //lblLineaCredito.Text = "Linea de crédito insuficiente $." + Math.Round(Convert.ToDouble(lineaCredito.ToString()), 3).ToString();
                    //lblLineaCredito.CssClass = "mensajeError";
                }
                else
                {
                    //lblLineaCredito.Text = "Linea de crédito disponible $." + Math.Round(Convert.ToDouble(lineaCredito.ToString()), 3).ToString();
                    //lblLineaCredito.CssClass = "mensajeExito";
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #19
0
        private void CargarVendedorZona()
        {
            AgendaWCFClient objAgendaWCF = new AgendaWCFClient();

            List <gsVendedorZona_ListarResult> lstVendedor;

            lstVendedor = objAgendaWCF.Agenda_VendedorZonaListar(
                ((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).idEmpresa,
                ((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).codigoUsuario, 0, "0").ToList();


            if (lstVendedor.Where(x => x.ID_Agenda.Trim() == ((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).nroDocumento).Any())
            {
                txt_idvendedor.Value = lstVendedor.Where(x => x.ID_Agenda.Trim() == ((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).nroDocumento).Select(x => x.ID_Agenda).First();
                txtvendedor.Text     = lstVendedor.Where(x => x.ID_Agenda.Trim() == ((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).nroDocumento).Select(x => x.AgendaNombre).First();
                txtzona.Text         = lstVendedor.Where(x => x.ID_Agenda.Trim() == ((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).nroDocumento).Select(x => x.Zona).First();
                txt_idzona.Value     = lstVendedor.Where(x => x.ID_Agenda.Trim() == ((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).nroDocumento).Select(x => x.ID_Zona.ToString()).First();
            }
        }
Beispiel #20
0
        public static AutoCompleteBoxData Agenda_BuscarCliente(object context)
        {
            AutoCompleteBoxData res = new AutoCompleteBoxData();
            string searchString     = ((Dictionary <string, object>)context)["Text"].ToString();

            if (searchString.Length > 2)
            {
                AgendaWCFClient objAgendaWCFClient = new AgendaWCFClient();
                gsAgenda_ListarClienteResult[] lst = objAgendaWCFClient.Agenda_ListarCliente(((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).idEmpresa,
                                                                                             ((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).codigoUsuario, searchString, 1);
                List <AutoCompleteBoxItemData> result = new List <AutoCompleteBoxItemData>();

                foreach (gsAgenda_ListarClienteResult agenda in lst)
                {
                    AutoCompleteBoxItemData childNode = new AutoCompleteBoxItemData();
                    childNode.Text  = agenda.ID_Agenda + "-" + agenda.Nombre;
                    childNode.Value = agenda.ID_Agenda;
                    result.Add(childNode);
                }
                res.Items = result.ToArray();
            }
            return(res);
        }
        private void Sectorista_Cargar()
        {
            try
            {
                AgendaWCFClient                   objAgendaWCF   = new AgendaWCFClient();
                gsUsuario_SectoristaResult        objSecotrista  = new gsUsuario_SectoristaResult();
                List <gsUsuario_SectoristaResult> lstSectoirista = new List <gsUsuario_SectoristaResult>();

                lstSectoirista = objAgendaWCF.Agenda_ListarSectorista(((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).idEmpresa,
                                                                      ((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).codigoUsuario, null, 1).ToList();



                lstSectoirista.Insert(0, objSecotrista);
                objSecotrista.AgendaNombre = "TODO";
                objSecotrista.ID_Agenda    = "0";

                var lstSectoiristas = from x in lstSectoirista
                                      select new
                {
                    x.ID_Agenda,
                    DisplayID    = String.Format("{0}", x.ID_Agenda),
                    DisplayField = String.Format("{0}", x.AgendaNombre)
                                   //DisplayField = String.Format("{0} {1} {2} {3}", x.Placa, x.Modelo, x.Marca, x.Agenda)
                };

                cboSectorista.DataSource     = lstSectoiristas;
                cboSectorista.DataTextField  = "DisplayField";
                cboSectorista.DataValueField = "DisplayID";
                cboSectorista.DataBind();
            }
            catch (Exception ex)
            {
                lblMensaje.Text     = ex.Message;
                lblMensaje.CssClass = "mensajeError";
            }
        }
        static void Main(string[] args)
        {
            for (int x = 1; x < 2; x++)
            {
                List <gsClientesCorreo_EnvioResult>      lstCorreo;
                ResponsableContratoWCFClient             objResponsablesWCF  = new ResponsableContratoWCFClient();
                List <ResponsablesContrato_ListarResult> objListResponsables = new List <ResponsablesContrato_ListarResult>();
                objListResponsables = objResponsablesWCF.ResponsablesContrato_Listar().ToList();
                AgendaWCFClient objAgendaWCF = new AgendaWCFClient();

                string Titulo;
                int    idEmpresa;
                int    idUsuario;

                var responsable       = "";
                var correoResponsable = "";
                var mensaje           = "";
                idEmpresa = x;
                idUsuario = 161;
                int vencidos;
                vencidos = 0;
                string ccCorreo;
                string ccResponsable;


                lstCorreo = objAgendaWCF.Agenda_ListarCorreos(idEmpresa, idUsuario, 0, null).ToList();

                foreach (gsClientesCorreo_EnvioResult Correo in lstCorreo)
                {
                    int tiene = 0;

                    if (vencidos == 0)
                    {
                        responsable       = Correo.AgendaNombre;
                        correoResponsable = Correo.EMail;
                        correoResponsable = "*****@*****.**";

                        ccResponsable = "Angelo Benavides";
                        ccCorreo      = "*****@*****.**";
                        //ccResponsable = "";
                        //ccCorreo = "";

                        Titulo   = "Grupo Silvestre: Estado de Cuenta al " + DateTime.Now.ToShortDateString();
                        mensaje += "Estimado Cliente " + responsable + ",";
                        mensaje += "<br/><br/>";
                        mensaje += "Se le envía de forma electrónica su estado de cuenta. ";
                        mensaje += "<br/><br/>";
                        mensaje += "<b>Lista de documentos pendientes: </b>";
                        mensaje += "<br/><br/>";

                        mensaje += Reporte_Cargar(Correo, idEmpresa, idUsuario, ref tiene);

                        if (tiene == 1)
                        {
                            EnviarEmail(responsable, correoResponsable, ccResponsable, ccCorreo, Titulo, mensaje);
                        }

                        vencidos = vencidos + 1;
                    }
                }
            }
        }
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            if (Session["Usuario"] == null)
            {
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "mykey", "CancelEdit();", true);
            }

            gsEgresosVarios_BuscarDetalleResult objEVDetalle;
            string idAgenda = "";

            try {
                if (!btnAgregar.Visible)
                {
                    AgendaWCFClient objAgendaWCF = new AgendaWCFClient();
                    if (txtNroRUC.Text.Length != 11)
                    {
                        throw new ArgumentException("El número RUC ingresado no es correcto");
                    }
                    if (string.IsNullOrEmpty(txtRazonSocial.Text))
                    {
                        throw new ArgumentException("Se debe ingresar la razón social del proveedor.");
                    }
                    idAgenda = objAgendaWCF.Agenda_RegistrarProveedor(((Usuario_LoginResult)Session["Usuario"]).idEmpresa,
                                                                      ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario, txtNroRUC.Text, txtRazonSocial.Text.ToUpper());
                }

                objEVDetalle = new gsEgresosVarios_BuscarDetalleResult();
                if (Request.QueryString["objRecibo"] != "0")
                {
                    objEVDetalle = JsonHelper.JsonDeserialize <gsEgresosVarios_BuscarDetalleResult>(Request.QueryString["objRecibo"]);
                }
                else
                {
                    objEVDetalle = new gsEgresosVarios_BuscarDetalleResult();
                }

                if (string.IsNullOrEmpty(txtImporte.Text) || txtImporte.Value <= 0)
                {
                    throw new ArgumentException("Se debe ingresar un importe mayor 0 soles.");
                }
                objEVDetalle.Importe = (decimal)txtImporte.Value;
                if (cboTipoGasto.SelectedIndex < 0)
                {
                    throw new ArgumentException("Se debe seleccionar un tipo de gasto valido.");
                }
                objEVDetalle.ID_Item = cboTipoGasto.SelectedValue;
                objEVDetalle.Item    = cboTipoGasto.Text;
                if (acbTipoDocumento.Entries.Count <= 0)
                {
                    throw new ArgumentException("Se debe ingresar un tipo de documento valido.");
                }
                objEVDetalle.ID_Documento    = decimal.Parse(acbTipoDocumento.Text.Split('-')[0]);
                objEVDetalle.NombreDocumento = acbTipoDocumento.Text.Split('-')[1];
                if (acbProveedor.Entries.Count <= 0 && btnAgregar.Visible)
                {
                    throw new ArgumentException("Se debe ingresar un proveedor valido.");
                }
                if (btnAgregar.Visible)
                {
                    objEVDetalle.ID_Agenda = acbProveedor.Text.Split('-')[0];
                    objEVDetalle.Agenda    = acbProveedor.Text.Split('-')[1];
                }
                else
                {
                    objEVDetalle.ID_Agenda = idAgenda;
                    objEVDetalle.Agenda    = txtRazonSocial.Text;
                }
                if (string.IsNullOrEmpty(txtSerie.Text))
                {
                    throw new ArgumentException("Se debe ingresar una serie valida.");
                }
                objEVDetalle.Serie = txtSerie.Text;
                if (string.IsNullOrEmpty(txtNumero.Text))
                {
                    throw new ArgumentException("Se debe ingresar un número valido.");
                }
                objEVDetalle.Numero          = (decimal)txtNumero.Value;
                objEVDetalle.Observaciones   = txtComentario.Text;
                objEVDetalle.FechaEmision    = dpFecEmision.SelectedDate.Value;
                objEVDetalle.ImporteBaseIGV  = Convert.ToDecimal(txtImpBase.Value);
                objEVDetalle.ImporteIGV      = Convert.ToDecimal(txtIGV.Value);
                objEVDetalle.ImporteInafecto = Convert.ToDecimal(txtInafecto.Value);
                objEVDetalle.Estado          = 1;

                ScriptManager.RegisterStartupScript(Page, this.GetType(), "mykey", "CloseAndRebind(" + JsonHelper.JsonSerializer(objEVDetalle) + ");", true);
            }
            catch (Exception ex) {
                lblMensaje.Text     = "ERROR: " + ex.Message;
                lblMensaje.CssClass = "mensajeError";
            }
        }
Beispiel #24
0
        //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);
            }
            //}
        }
Beispiel #25
0
        private PdfPTable Add_Content_To_PDF(PdfPTable tableLayout, string fechaHasta, int idEmpresa)
        {
            EmpresaWCFClient objEmpresaWCF = new EmpresaWCFClient();
            AgendaWCFClient  objAgendaWCF  = new AgendaWCFClient();
            List <gsLetrasEmitidas_CabeceraResult>   lstCabecera;
            List <gsLetrasEmitidas_DocumentosResult> lstDocumentos;
            List <gsLetrasEmitidas_LetrasResult>     lstLetras;

            Empresa_BuscarDetalleResult objEmpresa;
            string urlImagen;

            lstCabecera   = FinanciamientoCabecera();
            lstDocumentos = FinancimientoDocumentos();
            lstLetras     = FinancimientoLetras();


            Empresa_BuscarDetalleResult[] lst = objEmpresaWCF.Empresa_BuscarDetalle(idEmpresa);
            objEmpresa = lst[0];
            urlImagen  = objEmpresa.logotipo.ToString();

            float[] values = new float[11];
            values[0]  = 120;
            values[1]  = 145;
            values[2]  = 140;
            values[3]  = 110;
            values[4]  = 110;
            values[5]  = 120;
            values[6]  = 110;
            values[7]  = 110;
            values[8]  = 110;
            values[9]  = 100;
            values[10] = 100;

            tableLayout.SetWidths(values);        //Set the pdf headers
            tableLayout.WidthPercentage = 100;    //Set the PDF File witdh percentage

            //Add Title to the PDF file at the top

            //iTextSharp.text.Image logo = iTextSharp.text.Image.GetInstance(Server.MapPath(urlImagen));
            iTextSharp.text.Image logo = iTextSharp.text.Image.GetInstance(Server.MapPath("~/Images/Logos/grupo.png"));

            logo.ScaleAbsolute(205, 90);
            PdfPCell imageCell = new PdfPCell(logo);

            imageCell.Colspan             = 2; // either 1 if you need to insert one cell
            imageCell.Border              = 0;
            imageCell.HorizontalAlignment = Element.ALIGN_LEFT;

            //tableLayout.AddCell(imageCell);
            tableLayout.AddCell(new PdfPCell(new Phrase("CARTA CANJE DE LETRA", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 11, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
            {
                Colspan = 10, Border = 0, PaddingBottom = 10, HorizontalAlignment = Element.ALIGN_CENTER
            });
            tableLayout.AddCell(new PdfPCell(new Phrase(DateTime.Now.ToString(), new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 5, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
            {
                Colspan = 1, Border = 0, PaddingBottom = 10, HorizontalAlignment = Element.ALIGN_CENTER
            });

            tableLayout.AddCell(new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
            {
                Colspan = 11, Border = 0, PaddingBottom = 5, HorizontalAlignment = Element.ALIGN_CENTER
            });


            tableLayout.AddCell(new PdfPCell(new Phrase(objEmpresa.ruc + " " + objEmpresa.razonSocial, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 8, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
            {
                Colspan = 6, Border = 0, PaddingBottom = 1, HorizontalAlignment = Element.ALIGN_LEFT
            });
            tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 7, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
            {
                Colspan = 5, Border = 0, PaddingBottom = 1, HorizontalAlignment = Element.ALIGN_CENTER
            });

            tableLayout.AddCell(new PdfPCell(new Phrase(objEmpresa.direccion, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 8, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
            {
                Colspan = 6, Border = 0, PaddingBottom = 10, HorizontalAlignment = Element.ALIGN_LEFT
            });
            tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 7, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
            {
                Colspan = 5, Border = 0, PaddingBottom = 10, HorizontalAlignment = Element.ALIGN_CENTER
            });

            tableLayout.AddCell(new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
            {
                Colspan = 11, Border = 0, PaddingBottom = 5, HorizontalAlignment = Element.ALIGN_CENTER
            });

            //Add Cliente
            int cont = 0;

            foreach (gsLetrasEmitidas_CabeceraResult FinanResumen in lstCabecera)
            {
                cont = cont + 1;
                // ADD Cliente

                tableLayout.AddCell(new PdfPCell(new Phrase("1. Financiamiento de Cliente", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 7, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 7, Border = 0, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 6, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });

                List <gsAgenda_BuscarClienteDetalleResult> LimiteAgenda = objAgendaWCF.Agenda_BuscarClienteDetalle(((Usuario_LoginResult)Session["Usuario"]).idEmpresa, ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario, FinanResumen.ID_Aceptante.ToString()).ToList();
                if (LimiteAgenda.Count > 0)
                {
                    gsAgenda_BuscarClienteDetalleResult AgendaResumen = LimiteAgenda[0];
                    tableLayout.AddCell(new PdfPCell(new Phrase("Razón Social", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                    tableLayout.AddCell(new PdfPCell(new Phrase(AgendaResumen.ruc + " " + AgendaResumen.Agendanombre, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 7, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 7, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                    tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 3, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });

                    tableLayout.AddCell(new PdfPCell(new Phrase("Facturación", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                    tableLayout.AddCell(new PdfPCell(new Phrase(AgendaResumen.Direccion + " " + AgendaResumen.Distrito + " - " + AgendaResumen.Provincia + " - " + AgendaResumen.Departamento + " - " + AgendaResumen.Pais, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 7, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 7, BorderColorLeft = BaseColor.RED, BorderColorTop = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                    tableLayout.AddCell(new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 3, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                }
                else
                {
                    tableLayout.AddCell(new PdfPCell(new Phrase(FinanResumen.ID_Aceptante + " " + FinanResumen.agendanombre, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 7, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 5, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                    tableLayout.AddCell(new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 6, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                    tableLayout.AddCell(new PdfPCell(new Phrase("Registrar dirección fiscal. ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 7, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 5, BorderColorLeft = BaseColor.RED, BorderColorTop = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                    tableLayout.AddCell(new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 6, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                }

                tableLayout.AddCell(new PdfPCell(new Phrase("  ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
                {
                    Colspan = 11, Border = 0, PaddingBottom = 5, HorizontalAlignment = Element.ALIGN_CENTER
                });

                tableLayout.AddCell(new PdfPCell(new Phrase("Fecha Emisión", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("Periodos", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("Glosa", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 2, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("Cuotas", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("Tasa", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("Interés", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("Total", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 3, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });

                //---------------------------
                AddCellToBody(tableLayout, FinanResumen.Fecha.ToShortDateString());
                AddCellToBody(tableLayout, FinanResumen.NroPeriodos.ToString());
                AddCellToBodyColspan(tableLayout, FinanResumen.Observaciones, 2);
                AddCellToBody(tableLayout, string.Format("{0:$ #,##0.00}", FinanResumen.Cuota));
                AddCellToBody(tableLayout, FinanResumen.Tasa.ToString());
                AddCellToBody(tableLayout, FinanResumen.Intereses.ToString());

                string Importe;
                Importe = string.Format("{0:$ #,##0.00}", FinanResumen.Total);

                tableLayout.AddCell(new PdfPCell(new Phrase(Importe.ToString(), new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });
                tableLayout.AddCell(new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 3, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });


                //---------------------------

                tableLayout.AddCell(new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
                {
                    Colspan = 11, Border = 0, PaddingBottom = 5, HorizontalAlignment = Element.ALIGN_CENTER
                });

                //ADD Letras
                tableLayout.AddCell(new PdfPCell(new Phrase("2. Relación de Documentos Canjeados", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 7, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 7, Border = 0, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });
                tableLayout.AddCell(new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 4, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });

                tableLayout.AddCell(new PdfPCell(new Phrase("#", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("TIPODOC", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("NUMERO", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("FECHA", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("FEC. VEN.", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("MONEDA", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("IMPORTE", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("APLICADO", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });

                tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 3, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });

                var query_Documentos = from c in lstDocumentos
                                       orderby c.ID_Amarre, c.Fecha, c.FechaVencimiento
                    select new
                {
                    c.Transaccion,
                    c.Fecha,
                    c.FechaVencimiento,
                    c.ID_Moneda,
                    c.MonedaSigno,
                    c.Importe,
                    c.TC,
                    c.TipoDoc,
                    c.Aplicar
                };

                int     count = 0;
                decimal num   = 0;
                decimal suma  = 0;
                decimal tc    = 1;
                string  sumaTotal;
                decimal aplicado    = 0;
                decimal sumAplicado = 0;
                string  strAplicado;
                string  strsumAplicado;

                foreach (var query in query_Documentos)
                {
                    count = count + 1;

                    AddCellToBody(tableLayout, count.ToString());
                    AddCellToBody(tableLayout, query.TipoDoc);
                    AddCellToBodyColspan(tableLayout, query.Transaccion, 1);
                    AddCellToBody(tableLayout, query.Fecha.ToShortDateString());
                    AddCellToBody(tableLayout, query.FechaVencimiento.ToShortDateString());
                    AddCellToBody(tableLayout, query.MonedaSigno.ToString());
                    tc = Convert.ToDecimal(query.TC);

                    Importe = "";
                    if (query.ID_Moneda == 0)
                    {
                        Importe = string.Format("{0:$ #,##0.00}", query.Importe);
                        num     = Convert.ToDecimal(query.Importe);

                        strAplicado = string.Format("{0:$ #,##0.00}", query.Aplicar);
                        aplicado    = Convert.ToDecimal(query.Aplicar);
                    }
                    else
                    {
                        Importe = string.Format("{0:S/ #,##0.00}", query.Importe);
                        num     = Convert.ToDecimal(query.Importe);
                        num     = num / tc;

                        strAplicado = string.Format("{0:S/ #,##0.00}", query.Aplicar);
                        aplicado    = Convert.ToDecimal(query.Aplicar);
                        aplicado    = aplicado / tc;
                    }

                    sumAplicado = sumAplicado + aplicado;
                    suma        = suma + num;

                    tableLayout.AddCell(new PdfPCell(new Phrase(Importe.ToString(), new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                    tableLayout.AddCell(new PdfPCell(new Phrase(strAplicado.ToString(), new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });

                    tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 3, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                }

                sumaTotal      = string.Format("{0:$ #,##0.00}", suma);
                strsumAplicado = string.Format("{0:$ #,##0.00}", sumAplicado);

                tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 5, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });

                tableLayout.AddCell(new PdfPCell(new Phrase("Total", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });

                tableLayout.AddCell(new PdfPCell(new Phrase(sumaTotal, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });
                tableLayout.AddCell(new PdfPCell(new Phrase(strsumAplicado, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });

                tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 3, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });

                //--------------------------------
                tableLayout.AddCell(new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
                {
                    Colspan = 11, Border = 0, PaddingBottom = 5, HorizontalAlignment = Element.ALIGN_CENTER
                });
                //--------------------------------

                //ADD Letras
                tableLayout.AddCell(new PdfPCell(new Phrase("3. Relación de Letras Generadas", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 7, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 7, Border = 0, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 4, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });

                tableLayout.AddCell(new PdfPCell(new Phrase("NRO.CUOTA", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("ESTADO", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });

                tableLayout.AddCell(new PdfPCell(new Phrase("NUMERO", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });

                tableLayout.AddCell(new PdfPCell(new Phrase("FECHA", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("FEC. VEN.", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("MONEDA", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("IMPORTE", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("CANCELADO", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });

                tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 3, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });


                var query_Letras = from c in lstLetras
                                   orderby c.ID_Amarre, c.FechaEmision, c.FechaVencimiento
                    select new
                { c.NroCuota,
                  c.ID_Amarre,
                  c.FechaEmision,
                  c.FechaVencimiento,
                  c.ID_Moneda,
                  c.Signo,
                  c.TC,
                  c.TipoDoc,
                  c.ID_Estado,
                  c.Estado,
                  c.Cancelado,
                  c.Importe
                  //Importe = c.ID_Estado == 689 ? c.Cancelado : c.Importe
                };


                count     = 0;
                num       = 0;
                suma      = 0;
                tc        = 1;
                sumaTotal = "";
                decimal cancel    = 0;
                decimal sumcancel = 0;
                string  strcancel;
                string  strsumcancel;

                foreach (var query in query_Letras)
                {
                    count = count + 1;

                    AddCellToBody(tableLayout, query.NroCuota.ToString());
                    AddCellToBodyColspan(tableLayout, query.Estado.ToString(), 1);
                    AddCellToBodyColspan(tableLayout, query.ID_Amarre.ToString(), 1);
                    AddCellToBody(tableLayout, query.FechaEmision.ToShortDateString());
                    AddCellToBody(tableLayout, query.FechaVencimiento.ToShortDateString());
                    AddCellToBody(tableLayout, query.Signo.ToString());
                    tc = Convert.ToDecimal(query.TC);

                    Importe = "";
                    if (query.ID_Moneda == 0)
                    {
                        Importe   = string.Format("{0:$ #,##0.00}", query.Importe);
                        strcancel = string.Format("{0:$ #,##0.00}", query.Cancelado);
                        num       = Convert.ToDecimal(query.Importe);
                        cancel    = Convert.ToDecimal(query.Cancelado);
                    }
                    else
                    {
                        Importe   = string.Format("{0:S/ #,##0.00}", query.Importe);
                        strcancel = string.Format("{0:S/ #,##0.00}", query.Cancelado);
                        num       = Convert.ToDecimal(query.Importe);
                        cancel    = Convert.ToDecimal(query.Cancelado);
                        num       = (num / tc);
                        cancel    = (cancel / tc);
                    }

                    if (query.ID_Estado == 689)
                    {
                        suma = suma + 0;
                        tableLayout.AddCell(new PdfPCell(new Phrase(Importe.ToString(), new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.RED)))
                        {
                            HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                        });
                    }
                    else
                    {
                        tableLayout.AddCell(new PdfPCell(new Phrase(Importe.ToString(), new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.BLACK)))
                        {
                            HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                        });
                        suma = suma + num;
                    }

                    sumcancel = sumcancel + cancel;

                    tableLayout.AddCell(new PdfPCell(new Phrase(strcancel.ToString(), new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });


                    tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 3, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                }
                sumaTotal    = string.Format("{0:$ #,##0.00}", suma);
                strsumcancel = string.Format("{0:$ #,##0.00}", sumcancel);

                tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 5, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });

                tableLayout.AddCell(new PdfPCell(new Phrase("Total", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase(sumaTotal, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });
                tableLayout.AddCell(new PdfPCell(new Phrase(strsumcancel, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });

                tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 3, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });

                tableLayout.AddCell(new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
                {
                    Colspan = 11, Border = 0, PaddingBottom = 5, HorizontalAlignment = Element.ALIGN_CENTER
                });
            }

            return(tableLayout);
        }
Beispiel #26
0
        static void Obtener_TipoCambio()
        {
            int idEmpresa;

            DateTime fechaInicial;
            DateTime fechaFinal;
            int      contar      = 1;
            int      codUsuario  = 1;
            string   Empresa_RUC = "";

            AgendaWCFClient objAgendaWCF = new AgendaWCFClient();

            for (int x = 1; x <= 3; x++)
            {
                idEmpresa = x;
                if (x == 3)
                {
                    idEmpresa   = 6;
                    Empresa_RUC = "20505467214";
                }

                if (x == 1)
                {
                    Empresa_RUC = "20191503482";
                }
                if (x == 2)
                {
                    Empresa_RUC = "20509089923";
                }



                Console.WriteLine("Empresa:" + Empresa_RUC);

                int Dia = 1;
                fechaInicial = Convert.ToDateTime("2018/02/" + Dia.ToString());
                fechaFinal   = fechaInicial;

                //fechaInicial = Convert.ToDateTime( DateTime.Now.ToShortDateString());
                //fechaFinal = fechaInicial;

                for (int i = 1; i <= 12; i++)
                {
                    Console.WriteLine("----------------------------------------");
                    try
                    {
                        RPT00015Result objTipoCambio = objAgendaWCF.Agenda_TipoCambio(idEmpresa, codUsuario, fechaInicial, fechaFinal, 1);
                        RegistrarTipoRegistrarTipoCambio(Empresa_RUC, objTipoCambio.Fecha, objTipoCambio.Operativo);

                        Console.WriteLine(
                            //i.ToString()+ "  " +
                            "Fecha Inicial:" + fechaInicial.ToShortDateString()
                            + " Fecha Final:" + fechaFinal.ToShortDateString()
                            + " Tipo Cambio:" + objTipoCambio.Operativo.ToString()
                            + " Fecha Genesys:" + objTipoCambio.Fecha.ToShortDateString()
                            );
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(
                            "Error:" +
                            "Fecha Inicial:" + fechaInicial.ToShortDateString()
                            + " Fecha Final:" + fechaFinal.ToShortDateString()

                            );
                    }

                    //------------------------------------------------
                    fechaInicial = fechaInicial.AddDays(1);
                    fechaFinal   = fechaInicial;
                    contar       = contar + 1;
                }
            }
        }
Beispiel #27
0
        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.");
            }
        }
Beispiel #28
0
        private PdfPTable Add_Content_To_PDF(PdfPTable tableLayout, string fechaHasta, int idEmpresa)
        {
            EmpresaWCFClient objEmpresaWCF = new EmpresaWCFClient();
            AgendaWCFClient  objAgendaWCF  = new AgendaWCFClient();
            List <gsLetrasEmitidas_CabeceraResult>   lstCabecera;
            List <gsLetrasEmitidas_DocumentosResult> lstDocumentos;
            List <gsLetrasEmitidas_LetrasResult>     lstLetras;

            Empresa_BuscarDetalleResult objEmpresa;
            string urlImagen;

            lstCabecera   = FinanciamientoCabecera();
            lstDocumentos = FinancimientoDocumentos();
            lstLetras     = FinancimientoLetras();


            Empresa_BuscarDetalleResult[] lst = objEmpresaWCF.Empresa_BuscarDetalle(idEmpresa);
            objEmpresa = lst[0];
            urlImagen  = objEmpresa.logotipo.ToString();

            float[] values = new float[11];
            values[0]  = 140;
            values[1]  = 120;
            values[2]  = 105;
            values[3]  = 120;
            values[4]  = 110;
            values[5]  = 120;
            values[6]  = 105;
            values[7]  = 120;
            values[8]  = 110;
            values[9]  = 80;
            values[10] = 80;

            tableLayout.SetWidths(values);        //Set the pdf headers
            tableLayout.WidthPercentage = 100;    //Set the PDF File witdh percentage

            //Add Title to the PDF file at the top

            //iTextSharp.text.Image logo = iTextSharp.text.Image.GetInstance(Server.MapPath(urlImagen));
            iTextSharp.text.Image logo = iTextSharp.text.Image.GetInstance(Server.MapPath("~/Images/Logos/grupo.png"));

            logo.ScaleAbsolute(205, 90);
            PdfPCell imageCell = new PdfPCell(logo);

            imageCell.Colspan             = 2; // either 1 if you need to insert one cell
            imageCell.Border              = 0;
            imageCell.HorizontalAlignment = Element.ALIGN_LEFT;

            //tableLayout.AddCell(imageCell);
            tableLayout.AddCell(new PdfPCell(new Phrase("CARTA CANJE DE LETRA", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 11, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
            {
                Colspan = 10, Border = 0, PaddingBottom = 10, HorizontalAlignment = Element.ALIGN_CENTER
            });
            tableLayout.AddCell(new PdfPCell(new Phrase(DateTime.Now.ToString(), new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 5, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
            {
                Colspan = 1, Border = 0, PaddingBottom = 10, HorizontalAlignment = Element.ALIGN_CENTER
            });

            tableLayout.AddCell(new PdfPCell(new Phrase(objEmpresa.ruc + " " + objEmpresa.razonSocial, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 8, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
            {
                Colspan = 6, Border = 0, PaddingBottom = 1, HorizontalAlignment = Element.ALIGN_LEFT
            });
            tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 7, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
            {
                Colspan = 5, Border = 0, PaddingBottom = 1, HorizontalAlignment = Element.ALIGN_CENTER
            });

            tableLayout.AddCell(new PdfPCell(new Phrase(objEmpresa.direccion, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 8, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
            {
                Colspan = 6, Border = 0, PaddingBottom = 10, HorizontalAlignment = Element.ALIGN_LEFT
            });
            tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 7, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
            {
                Colspan = 5, Border = 0, PaddingBottom = 10, HorizontalAlignment = Element.ALIGN_CENTER
            });

            //Add Cliente
            int cont = 0;

            foreach (gsLetrasEmitidas_CabeceraResult FinanResumen in lstCabecera)
            {
                cont = cont + 1;
                // ADD Cliente

                tableLayout.AddCell(new PdfPCell(new Phrase("1. Razón Social", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 7, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 5, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 6, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });

                List <gsAgenda_BuscarClienteDetalleResult> LimiteAgenda = objAgendaWCF.Agenda_BuscarClienteDetalle(((Usuario_LoginResult)Session["Usuario"]).idEmpresa, ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario, FinanResumen.ID_Aceptante.ToString()).ToList();
                if (LimiteAgenda.Count > 0)
                {
                    gsAgenda_BuscarClienteDetalleResult AgendaResumen = LimiteAgenda[0];
                    tableLayout.AddCell(new PdfPCell(new Phrase(AgendaResumen.ruc + " " + AgendaResumen.Agendanombre, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 7, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 5, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                    tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 6, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                    tableLayout.AddCell(new PdfPCell(new Phrase(AgendaResumen.Direccion + " " + AgendaResumen.Distrito + " - " + AgendaResumen.Provincia + " - " + AgendaResumen.Departamento + " - " + AgendaResumen.Pais, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 7, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 5, BorderColorLeft = BaseColor.RED, BorderColorTop = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                    tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 6, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                }
                else
                {
                    tableLayout.AddCell(new PdfPCell(new Phrase(FinanResumen.ID_Aceptante + " " + FinanResumen.agendanombre, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 7, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 5, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                    tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 6, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                    tableLayout.AddCell(new PdfPCell(new Phrase("Registrar dirección fiscal. ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 7, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 5, BorderColorLeft = BaseColor.RED, BorderColorTop = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                    tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 6, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                }

                tableLayout.AddCell(new PdfPCell(new Phrase("   ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
                {
                    Colspan = 11, Border = 0, PaddingBottom = 5, HorizontalAlignment = Element.ALIGN_CENTER
                });

                //ADD Resumen cliente

                tableLayout.AddCell(new PdfPCell(new Phrase("2. Línea de crédito", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("Deuda vencida", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("Deuda total", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("Línea disponible", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 7, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });



                //tableLayout.AddCell(new PdfPCell(new Phrase(strLineaCredito, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 7, 1, iTextSharp.text.BaseColor.BLACK))) { Colspan = 1, HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE });
                //tableLayout.AddCell(new PdfPCell(new Phrase(strDeudaVencida, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 7, 1, iTextSharp.text.BaseColor.BLACK))) { Colspan = 1, HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE });
                //tableLayout.AddCell(new PdfPCell(new Phrase(strTotalCredito, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 7, 1, iTextSharp.text.BaseColor.BLACK))) { Colspan = 1, HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE });
                //tableLayout.AddCell(new PdfPCell(new Phrase(strCreditoDisponible, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 7, 1, iTextSharp.text.BaseColor.BLACK))) { Colspan = 1, HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE });
                //tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK))) { Colspan = 7, Border = 0, HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE });

                tableLayout.AddCell(new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
                {
                    Colspan = 11, Border = 0, PaddingBottom = 5, HorizontalAlignment = Element.ALIGN_CENTER
                });


                tableLayout.AddCell(new PdfPCell(new Phrase("3. NoVencido", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("Vencido 01a30", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("Vencido 31a60", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("Vencido 61a120", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("Vencido 121a360", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("Vencido 361aMas", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("Deuda total", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 7, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
                {
                    Colspan = 4, Border = 0, PaddingBottom = 10, HorizontalAlignment = Element.ALIGN_CENTER
                });

                //tableLayout.AddCell(new PdfPCell(new Phrase(strsumNoVencido, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 7, 1, iTextSharp.text.BaseColor.BLACK))) { Colspan = 1, HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE });
                //tableLayout.AddCell(new PdfPCell(new Phrase(strsumImportePendiente_01a30, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 7, 1, iTextSharp.text.BaseColor.BLACK))) { Colspan = 1, HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE });
                //tableLayout.AddCell(new PdfPCell(new Phrase(strsumImportePendiente_31a60, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 7, 1, iTextSharp.text.BaseColor.BLACK))) { Colspan = 1, HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE });
                //tableLayout.AddCell(new PdfPCell(new Phrase(strsumImportePendiente_61a120, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 7, 1, iTextSharp.text.BaseColor.BLACK))) { Colspan = 1, HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE });
                //tableLayout.AddCell(new PdfPCell(new Phrase(strsumImportePendiente_121a360, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 7, 1, iTextSharp.text.BaseColor.BLACK))) { Colspan = 1, HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE });
                //tableLayout.AddCell(new PdfPCell(new Phrase(strsumImportePendiente_361aMas, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 7, 1, iTextSharp.text.BaseColor.BLACK))) { Colspan = 1, HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE });
                //tableLayout.AddCell(new PdfPCell(new Phrase(strsumImportePendiente, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 7, 1, iTextSharp.text.BaseColor.BLACK))) { Colspan = 1, HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE });
                //tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 7, 1, iTextSharp.text.BaseColor.DARK_GRAY))) { Colspan = 4, Border = 0, PaddingBottom = 10, HorizontalAlignment = Element.ALIGN_CENTER });


                tableLayout.AddCell(new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
                {
                    Colspan = 11, Border = 0, PaddingBottom = 5, HorizontalAlignment = Element.ALIGN_CENTER
                });


                // ADD DETALLE
                tableLayout.AddCell(new PdfPCell(new Phrase("4. TipoDoc.", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                AddCellToHeader(tableLayout, "N° Documento");
                AddCellToHeader(tableLayout, "Fecha Emis.");
                AddCellToHeader(tableLayout, "Fecha Vcto.");
                AddCellToHeader(tableLayout, "DíasMora");
                AddCellToHeader(tableLayout, "Estado Doc.");
                AddCellToHeaderColspan(tableLayout, "Letra Banco", 2);
                AddCellToHeader(tableLayout, "N° Unico");
                AddCellToHeader(tableLayout, "Importe");
                AddCellToHeader(tableLayout, "Saldo Doc.");


                int    count      = 0;
                string TipoDoc    = "";
                string strTipoDoc = "";

                tableLayout.AddCell(new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
                {
                    Colspan = 11, Border = 0, PaddingBottom = 5, HorizontalAlignment = Element.ALIGN_CENTER
                });
                tableLayout.AddCell(new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
                {
                    Colspan = 11, Border = 0, PaddingBottom = 5, HorizontalAlignment = Element.ALIGN_CENTER
                });
            }

            return(tableLayout);
        }
Beispiel #29
0
        //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);
            }
            //}
        }