Exemplo n.º 1
0
        protected void btnMostrarTodos_Click(object sender, EventArgs e)
        {
            try
            {
                ValidaVariables();
                txtFilProv.Text   = "";
                txtFilPedido.Text = "";

                NegocioPF.Proveedor oProveedor = new NegocioPF.Proveedor(((Usuario)Session["oUsuario"]).Id);
                oProveedor.Cargar();

                NegocioPF.Servicios oServicios = new NegocioPF.Servicios();
                if (oProveedor.Nombre != "" && oProveedor.Nombre != null)
                {
                    oServicios.Cargar(((Usuario)Session["oUsuario"]).Id, "");
                }
                else
                {
                    oServicios.Cargar();
                }
                grdServicios.DataSource = oServicios.Datos;
                grdServicios.DataBind();
            }
            catch (Exception ex)
            {
                MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto(ex.Message));
            }
        }
Exemplo n.º 2
0
        //protected void grdFacturas_RowDataBound(object sender, GridViewRowEventArgs e)
        //{
        //    int index;
        //    try
        //    {
        //        ValidaVariables();

        //        if (e.Row.RowType == DataControlRowType.DataRow)
        //        {
        //            ImageButton btnConsultar = (ImageButton)e.Row.FindControl("btnVerPDF");
        //            btnConsultar.ToolTip = ((Idioma)Session["oIdioma"]).Texto("VerFactura");

        //            //Recupera la clave de la factura
        //            index = e.Row.RowIndex;
        //            NegocioPF.Factura oFactura = new NegocioPF.Factura(Convert.ToInt32(grdFacturas.DataKeys[e.Row.RowIndex].Values[0]),
        //                                                               Convert.ToString(grdFacturas.DataKeys[e.Row.RowIndex].Values[1]));
        //            oFactura.Cargar();

        //            GridView grdItems = e.Row.FindControl("grdItems") as GridView;
        //            grdItems.DataSource = oFactura.Materiales;
        //            grdItems.DataBind();

        //            //string customerId = gvCustomers.DataKeys[e.Row.RowIndex].Value.ToString();
        //            //GridView gvOrders = e.Row.FindControl("gvOrders") as GridView;
        //            //gvOrders.DataSource = GetData(string.Format("select top 3 * from Orders where CustomerId='{0}'", customerId));
        //            //gvOrders.DataBind();

        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto(ex.Message));
        //    }
        //}

        protected void btnBuscar_Click(object sender, EventArgs e)
        {
            try
            {
                ValidaVariables();

                NegocioPF.Pedidos oPedidos = new NegocioPF.Pedidos();

                NegocioPF.Proveedor oProveedor = new NegocioPF.Proveedor(((Usuario)Session["oUsuario"]).Id);
                oProveedor.Cargar();
                if (oProveedor.Nombre != "" && oProveedor.Nombre != null)
                {
                    oPedidos.Cargar(oProveedor.Id, txtOrden.Text, "Pendiente");
                }
                else
                {
                    oPedidos.Cargar(txtProveedor.Text, txtOrden.Text, "");
                }

                btnExportar.Visible = (oPedidos.Datos.Tables[0].Rows.Count > 0);
                ArmarTabla(ref oPedidos);
            }
            catch (Exception ex)
            {
                MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto(ex.Message));
            }
        }
Exemplo n.º 3
0
        protected void btnBuscar_Click(object sender, EventArgs e)
        {
            try
            {
                ValidaVariables();

                NegocioPF.Proveedor oProveedor = new NegocioPF.Proveedor(((Usuario)Session["oUsuario"]).Id);
                oProveedor.Cargar();
                NegocioPF.Entregas oEntregas = new NegocioPF.Entregas();
                if (oProveedor.Nombre != "" && oProveedor.Nombre != null)
                {
                    oEntregas.Cargar(((Usuario)Session["oUsuario"]).Id, txtFilPedido.Text);
                }
                else
                {
                    oEntregas.Cargar(txtFilProv.Text, txtFilPedido.Text);
                }
                grdEntregas.DataSource = oEntregas.Datos;
                grdEntregas.DataBind();
            }
            catch (Exception ex)
            {
                MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto(ex.Message));
            }
        }
Exemplo n.º 4
0
        protected void grdPedidos_PageIndexChanging1(object sender, GridViewPageEventArgs e)
        {
            try
            {
                ValidaVariables();
                grdPedidos.PageIndex = e.NewPageIndex;

                //Si el usuario es un usuario del proveedor, por defautl se muestra sus pedidos
                NegocioPF.Proveedor oProveedor = new NegocioPF.Proveedor(((Usuario)Session["oUsuario"]).Id);
                oProveedor.Cargar();
                NegocioPF.Pedidos oPedidos = new NegocioPF.Pedidos();
                if (oProveedor.Nombre != "" && oProveedor.Nombre != null)
                {
                    oPedidos.Cargar(((Usuario)Session["oUsuario"]).Id, txtFilPedido.Text, "Pendiente");
                }
                else
                {
                    oPedidos.Cargar(txtFilProv.Text, txtFilPedido.Text, "");
                }
                grdPedidos.DataSource = oPedidos.Datos;
                grdPedidos.DataBind();
            }
            catch (Exception ex)
            {
                MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto(ex.Message));
            }
        }
Exemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    ValidaVariables();
                    EstableceIdioma((Idioma)Session["oIdioma"]);

                    NegocioPF.Proveedores oProveedores = new NegocioPF.Proveedores();
                    oProveedores.Cargar();
                    foreach (DataRow r in oProveedores.Datos.Tables[0].Rows)
                    {
                        DropDownCheckBoxes1.Items.Add(new ListItem(r["nombre"].ToString(), r["id_proveedor"].ToString()));
                    }

                    //Si el usuario es un usuario del proveedor, selecciona el proveedor
                    NegocioPF.Proveedor oProveedor = new NegocioPF.Proveedor(((Usuario)Session["oUsuario"]).Id);
                    oProveedor.Cargar();
                    if (oProveedor.Nombre != "" && oProveedor.Nombre != null)
                    {
                        divFiltros.Visible = false;
                        btnGenerar_Click(null, null);
                    }
                    else
                    {
                        divReporte.Visible = false;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto(ex.Message));
                }
            }
        }
Exemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    ValidaVariables();
                    EstableceIdioma((Idioma)Session["oIdioma"]);
                    btnExportar.Visible = false;

                    //Si el usuario es un usuario del proveedor, por defautl se muestran todas sus facturas
                    NegocioPF.Proveedor oProveedor = new NegocioPF.Proveedor(((Usuario)Session["oUsuario"]).Id);
                    oProveedor.Cargar();
                    if (oProveedor.Nombre != "" && oProveedor.Nombre != null)
                    {
                        NegocioPF.Pedidos oPedidos = new NegocioPF.Pedidos();
                        oPedidos.Cargar(oProveedor.Id, "", "Pendiente");
                        ArmarTabla(ref oPedidos);
                        btnExportar.Visible  = (oPedidos.Datos.Tables[0].Rows.Count > 0);
                        lblProveedor.Visible = false;
                        txtProveedor.Visible = false;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto(ex.Message));
                }
            }

            AgregaScriptCliente();
        }
Exemplo n.º 7
0
        protected void grdEntregas_PageIndexChanging1(object sender, GridViewPageEventArgs e)
        {
            try
            {
                ValidaVariables();
                grdEntregas.PageIndex = e.NewPageIndex;

                NegocioPF.Proveedor oProveedor = new NegocioPF.Proveedor(((Usuario)Session["oUsuario"]).Id);
                oProveedor.Cargar();
                NegocioPF.Entregas oEntregas = new NegocioPF.Entregas();
                if (oProveedor.Nombre != "" && oProveedor.Nombre != null)
                {
                    oEntregas.Cargar(((Usuario)Session["oUsuario"]).Id, "");
                }
                else
                {
                    oEntregas.Cargar();
                }
                grdEntregas.DataSource = oEntregas.Datos;
                grdEntregas.DataBind();
            }
            catch (Exception ex)
            {
                MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto(ex.Message));
            }
        }
Exemplo n.º 8
0
        private void EnviaCorreoPassword(NegocioPF.Usuario oUsuario)
        {
            try
            {
                NegocioPF.Proveedor oProveedor = new NegocioPF.Proveedor(oUsuario.Proveedor);
                oProveedor.Cargar();

                if (oProveedor.eMail != "" || oUsuario.Email != "")
                {
                    string sHtml = "<html>";
                    sHtml += "<table style='font-family:arial;color:navy;font-size:12px; text-align:justify' border='0' width=\"800\">";
                    sHtml += "<tr><td><p>" + ((Idioma)Session["oIdioma"]).Texto("MsgSaludo") + "</p></td></tr>";
                    sHtml += "<tr><td colspan=\"4\"><p>" + ((Idioma)Session["oIdioma"]).Texto("MsgPasswordUsuario") + " " + oUsuario.Password + "</p></td></tr>";
                    sHtml += "<tr><td></td></tr>";
                    sHtml += "<tr><td>" + ((Idioma)Session["oIdioma"]).Texto("Saludos") + "</td></tr>";
                    sHtml += "<tr><td></td></tr>";
                    sHtml += "<tr><td><img src=cid:FirmaPF></td></tr>";
                    sHtml += "</table>";
                    sHtml += "</Html>";

                    EmailTemplate oEmail = new EmailTemplate("");

                    if (oProveedor.eMail != "")
                    {
                        oEmail.To.Add(oProveedor.eMail);
                    }
                    else
                    {
                        oEmail.To.Add(oUsuario.Email);
                    }

                    oEmail.From    = new MailAddress(@System.Configuration.ConfigurationSettings.AppSettings["EmailFrom"], "PortalFacturas", System.Text.Encoding.UTF8);
                    oEmail.Subject = ((Idioma)Session["oIdioma"]).Texto("RecuperaPassword");

                    //Agrega Logo
                    AlternateView altView = AlternateView.CreateAlternateViewFromString(sHtml, null, MediaTypeNames.Text.Html);

                    string         imageSource = (Server.MapPath("") + "\\Images\\FirmaPF.jpg");
                    LinkedResource PictureRes  = new LinkedResource(imageSource, MediaTypeNames.Image.Jpeg);
                    PictureRes.ContentId = "FirmaPF";
                    altView.LinkedResources.Add(PictureRes);

                    oEmail.AlternateViews.Add(altView);

                    try
                    {
                        oEmail.Send();
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("MsgErrorEnvioCorreo");
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 9
0
        protected void btnGenerar_Click(object sender, EventArgs e)
        {
            string sProveedor = "";

            try
            {
                //Ocultar los botones
                ReportViewer1.ShowPageNavigationControls       = false;
                ReportViewer1.ShowBackButton                   = false;
                ReportViewer1.ShowFindControls                 = false;
                ReportViewer1.ShowPrintButton                  = true;
                ReportViewer1.ShowExportControls               = true;
                ReportViewer1.LocalReport.EnableExternalImages = true;
                //ReportViewer1.LocalReport.ExecuteReportInCurrentAppDomain(AppDomain.CurrentDomain.Evidence);

                ReportViewer1.Reset();
                ReportViewer1.LocalReport.Dispose();
                ReportViewer1.LocalReport.DataSources.Clear();
                ReportViewer1.LocalReport.ReportPath = "Reports\\RepFacXFolio_" + ((Usuario)Session["oUsuario"]).Idioma + ".rdlc";
                ReportViewer1.ProcessingMode         = Microsoft.Reporting.WebForms.ProcessingMode.Local;

                //Si el usuario es un usuario del proveedor, agrega el proveedor a los filtros
                NegocioPF.Proveedor oProveedor = new NegocioPF.Proveedor(((Usuario)Session["oUsuario"]).Id);
                oProveedor.Cargar();
                if (oProveedor.Nombre != "" && oProveedor.Nombre != null)
                {
                    sProveedor = "'" + oProveedor.Id + "'";
                }

                DateTime fecFacIni = new DateTime(1900, 1, 1);
                DateTime fecFacFin = new DateTime(1900, 1, 1);
                DateTime fecIni    = new DateTime(1900, 1, 1);
                DateTime fecFin    = new DateTime(1900, 1, 1);

                NegocioPF.Facturas oFacturas = new NegocioPF.Facturas();
                oFacturas.Cargar(sProveedor, "", "", "", fecFacIni, fecFacFin, fecIni, fecFin, 0, 0, "", txtOrden.Text, "");

                string subtitulo = ((Idioma)Session["oIdioma"]).Texto("OrdenDeCompra") + ":" + txtOrden.Text;

                ReportParameter[] reportParameter = new ReportParameter[2];
                reportParameter[0] = new ReportParameter("Titulo", ((Idioma)Session["oIdioma"]).Texto("FacXODC"));
                reportParameter[1] = new ReportParameter("Subtitulo", subtitulo);
                ReportViewer1.LocalReport.SetParameters(reportParameter);
                ReportViewer1.LocalReport.Refresh();

                ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DsFactReg_DsFactReg", oFacturas.Datos.Tables[0]));
                ReportViewer1.Visible = true;
                ReportViewer1.LocalReport.Refresh();
                divReporte.Visible = true;
                lblTitulo.Visible  = false;
                divFiltros.Visible = false;
            }
            catch (Exception ex)
            {
                MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto(ex.Message));
            }
        }
Exemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    ValidaVariables();
                    EstableceIdioma((Idioma)Session["oIdioma"]);

                    //Si el usuario es un usuario del proveedor, por defautl se muestran todas sus facturas
                    NegocioPF.Proveedor oProveedor = new NegocioPF.Proveedor(((Usuario)Session["oUsuario"]).Id);
                    oProveedor.Cargar();
                    if (oProveedor.Nombre != "" && oProveedor.Nombre != null)
                    {
                        DateTime fecNull = new DateTime(1900, 1, 1);

                        NegocioPF.Facturas oFacturas = new NegocioPF.Facturas();
                        //oFacturas.ValidarStatus(oProveedor.RFC);
                        oFacturas.Cargar("'" + oProveedor.Id + "'", "", "", "", fecNull, fecNull, fecNull, fecNull, 0, 0, "", "", "");
                        grdFacturas.DataSource = oFacturas.Datos;
                        grdFacturas.DataBind();
                    }


                    NegocioPF.Sociedades oSociedades = new NegocioPF.Sociedades();
                    oSociedades.Cargar();
                    cboFilSociedad.DataSource     = oSociedades.Datos;
                    cboFilSociedad.DataTextField  = "Nombre";
                    cboFilSociedad.DataValueField = "id_sociedad";
                    cboFilSociedad.DataBind();
                    cboFilSociedad.Items.Insert(0, new ListItem(((Idioma)Session["oIdioma"]).Texto("Seleccionar") + " ...", "0"));

                    Perfil   oPerfil  = new Perfil();
                    Permisos permisos = oPerfil.CargarPermisos(((Usuario)Session["oUsuario"]).Id, "ConsultaFacturas.aspx");
                    btnImportar.Visible = (permisos.Importar);

                    btnBuscar.Visible = true;

                    txtFecFacIni.Attributes.Add("onmouseover", "scwShow(this,event);");
                    txtFecFacFin.Attributes.Add("onmouseover", "scwShow(this,event);");
                    txtFecRegIni.Attributes.Add("onmouseover", "scwShow(this,event);");
                    txtFecRegFin.Attributes.Add("onmouseover", "scwShow(this,event);");

                    divFiltros.Visible  = true;
                    divImportar.Visible = false;
                }
                catch (Exception ex)
                {
                    MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto(ex.Message));
                }
            }

            AgregaScriptCliente();
        }
Exemplo n.º 11
0
        protected void btnEditar_Command(object sender, CommandEventArgs e)
        {
            try
            {
                ValidaVariables();

                //obtiene indice de la linea actualizar
                int index = Convert.ToInt32(e.CommandArgument) - (grdProveedores.PageIndex * grdProveedores.PageSize);

                //Carga los datos del usuario
                NegocioPF.Proveedor oProveedor = new NegocioPF.Proveedor(grdProveedores.DataKeys[index].Value.ToString());
                oProveedor.Cargar();

                //Muestra los datos en los controles
                txtNumProv.Text = oProveedor.Id;
                txtRFC.Text     = oProveedor.RFC;
                txtNombre.Text  = oProveedor.Nombre;
                //txtCuenta.Text = oProveedor.Cuenta;
                txtCorreo.Text = oProveedor.eMail;
                rbtIntermediario.SelectedIndex = (oProveedor.Intermediario ? 0 : 1);
                cboStatus.SelectedValue        = oProveedor.Status;
                foreach (ListItem i in lstSociedades.Items)
                {
                    i.Selected = false;
                    foreach (string sociedad in oProveedor.Sociedades)
                    {
                        if (sociedad == i.Value)
                        {
                            i.Selected = true;
                        }
                    }
                }


                txtNumProv.Enabled = false;
                btnGuardar.Visible = (e.CommandName == "Editar" ? true : false);
                divFiltros.Visible = false;
                divDetalle.Visible = true;
            }
            catch (Exception ex)
            {
                MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto(ex.Message));
            }
        }
Exemplo n.º 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    ValidaVariables();
                    EstableceIdioma((Idioma)Session["oIdioma"]);

                    //Si el usuario es un usuario del proveedor, por defautl se muestra sus pedidos
                    NegocioPF.Proveedor oProveedor = new NegocioPF.Proveedor(((Usuario)Session["oUsuario"]).Id);
                    oProveedor.Cargar();
                    NegocioPF.Pedidos oPedidos = new NegocioPF.Pedidos();
                    if (oProveedor.Nombre != "" && oProveedor.Nombre != null)
                    {
                        oPedidos.Cargar(((Usuario)Session["oUsuario"]).Id, "", "Pendiente");
                        txtFilProv.Visible = false;
                        lblFilProv.Visible = false;
                    }
                    else
                    {
                        oPedidos.Cargar();
                    }

                    grdPedidos.DataSource = oPedidos.Datos;
                    grdPedidos.DataBind();

                    Perfil   oPerfil  = new Perfil();
                    Permisos permisos = oPerfil.CargarPermisos(((Usuario)Session["oUsuario"]).Id, "Pedidos.aspx");
                    btnImportar.Visible = (permisos.Importar);

                    divFiltros.Visible  = true;
                    divImportar.Visible = false;
                }
                catch (Exception ex)
                {
                    MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto(ex.Message));
                }
            }

            AgregaScriptCliente();
        }
Exemplo n.º 13
0
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                ValidaVariables();

                NegocioPF.Proveedor oProveedor = new NegocioPF.Proveedor(txtNumProv.Text,
                                                                         txtRFC.Text,
                                                                         txtNombre.Text,
                                                                         "", //txtCuenta.Text,
                                                                         txtCorreo.Text,
                                                                         (rbtIntermediario.SelectedIndex == 0 ? true : false),
                                                                         cboStatus.SelectedValue);

                //Recupera las sociedades
                foreach (ListItem i in lstSociedades.Items)
                {
                    if (i.Selected)
                    {
                        oProveedor.Sociedades.Add(i.Value);
                    }
                }

                oProveedor.Guardar(((Usuario)Session["oUsuario"]).Id);


                NegocioPF.Proveedores oProveedores = new NegocioPF.Proveedores();
                oProveedores.Cargar(txtFilProv.Text, txtFilRFC.Text, txtFilNombre.Text);
                grdProveedores.DataSource = oProveedores.Datos;
                grdProveedores.DataBind();

                divFiltros.Visible = true;
                divDetalle.Visible = false;

                MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto("MsgProveedorGuardado"));
            }
            catch (Exception ex)
            {
                MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto(ex.Message));
            }
        }
Exemplo n.º 14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    //ValidaVariables();
                    //EstableceIdioma((Idioma)Session["oIdioma"]);

                    //NegocioPF.Proveedores oProveedores = new NegocioPF.Proveedores();
                    //oProveedores.Cargar();
                    //CheckBoxList1.DataSource = oProveedores.Datos;
                    //CheckBoxList1.DataTextField = "Nombre";
                    //CheckBoxList1.DataValueField = "id_proveedor";
                    //CheckBoxList1.DataBind();
                    //CheckBoxList1.Items.Insert(0, new ListItem(((Idioma)Session["oIdioma"]).Texto("Seleccionar") + " ...", "0"));

                    //Si el usuario es un usuario del proveedor, selecciona el proveedor
                    NegocioPF.Proveedor oProveedor = new NegocioPF.Proveedor(((Usuario)Session["oUsuario"]).Id);
                    oProveedor.Cargar();
                    //if (oProveedor.Nombre != "" && oProveedor.Nombre != null)
                    //{
                    //    divFiltros.Visible = false;
                    //    btnGenerar_Click(null, null);
                    //}
                    //else
                    //{
                    //    divReporte.Visible = false;
                    //}
                }
                catch (Exception ex)
                {
                    //MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto(ex.Message));
                }
            }
        }
Exemplo n.º 15
0
        protected void btnBuscar_Click(object sender, EventArgs e)
        {
            string proveedor;

            try
            {
                ValidaVariables();

                NegocioPF.Facturas oFacturas = new NegocioPF.Facturas();

                NegocioPF.Proveedor oProveedor = new NegocioPF.Proveedor(((Usuario)Session["oUsuario"]).Id);
                oProveedor.Cargar();
                if (oProveedor.Nombre != "" && oProveedor.Nombre != null)
                {
                    proveedor = oProveedor.Id;
                }
                else
                {
                    proveedor = txtProveedor.Text;
                }

                DateTime fecFacIni = new DateTime(1900, 1, 1);
                if (txtFecFacIni.Text != "")
                {
                    fecFacIni = ConvierteTextToFecha(txtFecFacIni.Text);
                }

                DateTime fecFacFin = new DateTime(1900, 1, 1);
                if (txtFecFacIni.Text != "")
                {
                    fecFacFin = ConvierteTextToFecha(txtFecFacIni.Text);
                }

                DateTime fecRegIni = new DateTime(1900, 1, 1);
                if (txtFecRegIni.Text != "")
                {
                    fecRegIni = ConvierteTextToFecha(txtFecRegIni.Text);
                }

                DateTime fecRegFin = new DateTime(1900, 1, 1);
                if (txtFecRegFin.Text != "")
                {
                    fecRegFin = ConvierteTextToFecha(txtFecRegFin.Text);
                }

                string sociedad = "";
                if (cboFilSociedad.SelectedValue != "0")
                {
                    sociedad = "'" + cboFilSociedad.SelectedValue + "'";
                }

                int folInicial = 0;
                if (txtFolIni.Text != "")
                {
                    folInicial = Convert.ToInt32(txtFolIni.Text);
                }

                int folFinal = 0;
                if (txtFolFin.Text != "")
                {
                    folFinal = Convert.ToInt32(txtFolFin.Text);
                }

                //oFacturas.ValidarStatus(txtEmisor.Text);

                oFacturas.Cargar("'" + proveedor.Trim() + "'", txtEmisor.Text, txtNombre.Text, txtFactura.Text,
                                 fecFacIni, fecFacFin, fecRegIni, fecRegFin, folInicial, folFinal, sociedad, txtOrden.Text, txtEntrega.Text);

                grdFacturas.DataSource = oFacturas.Datos;
                grdFacturas.DataBind();
                divImportar.Visible = false;
            }
            catch (Exception ex)
            {
                MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto(ex.Message));
            }
        }
Exemplo n.º 16
0
        protected void btnGenerar_Click(object sender, EventArgs e)
        {
            //string sProveedor = "";
            string sProveedores = "";
            string sNomProv     = "";
            int    iNumProv     = 0;

            try
            {
                //Ocultar los botones
                ReportViewer1.ShowPageNavigationControls       = false;
                ReportViewer1.ShowBackButton                   = false;
                ReportViewer1.ShowFindControls                 = false;
                ReportViewer1.ShowPrintButton                  = true;
                ReportViewer1.ShowExportControls               = true;
                ReportViewer1.LocalReport.EnableExternalImages = true;
                //ReportViewer1.LocalReport.ExecuteReportInCurrentAppDomain(AppDomain.CurrentDomain.Evidence);

                ReportViewer1.Reset();
                ReportViewer1.LocalReport.Dispose();
                ReportViewer1.LocalReport.DataSources.Clear();
                ReportViewer1.LocalReport.ReportPath = "Reports\\RepFacXFolio_" + ((Usuario)Session["oUsuario"]).Idioma + ".rdlc";
                ReportViewer1.ProcessingMode         = Microsoft.Reporting.WebForms.ProcessingMode.Local;

                NegocioPF.Proveedor oProveedor = new NegocioPF.Proveedor(((Usuario)Session["oUsuario"]).Id);
                oProveedor.Cargar();
                iNumProv = 0;
                if (oProveedor.Nombre != "" && oProveedor.Nombre != null)
                {
                    sProveedores = "'" + oProveedor.Id + "'";
                    sNomProv     = oProveedor.Nombre;
                }
                else
                {
                    //Recupera los proveedores seleccionados
                    int cont = 0;
                    foreach (ListItem item in DropDownCheckBoxes1.Items)
                    {
                        if (item.Selected)
                        {
                            sProveedores += "'" + item.Value + "',";

                            if (cont <= 3)
                            {
                                sNomProv += item.Text + ",";
                            }
                            else
                            {
                                sNomProv = ((Idioma)Session["oIdioma"]).Texto("Varios") + ",";
                            }

                            cont++;
                        }
                    }

                    if (sProveedores.Length > 0)
                    {
                        sProveedores = sProveedores.Substring(0, sProveedores.Length - 1);
                        sNomProv     = sNomProv.Substring(0, sNomProv.Length - 1);
                    }

                    //Si se seleccionan a todos los proveedores
                    if (DropDownCheckBoxes1.Items.Count == cont)
                    {
                        sProveedores = "";
                        sNomProv     = ((Idioma)Session["oIdioma"]).Texto("Todos");
                    }
                }

                DateTime fecFact = new DateTime(1900, 1, 1);
                DateTime fecIni  = new DateTime(1900, 1, 1);
                DateTime fecFin  = new DateTime(1900, 1, 1);

                NegocioPF.Facturas oFacturas = new NegocioPF.Facturas();
                oFacturas.Cargar(sProveedores, "", "", "", fecFact, fecFact, fecIni, fecFin, 0, 0, "", "", "");

                string subtitulo = ((Idioma)Session["oIdioma"]).Texto("Proveedor") + ":" + (iNumProv > 5 ? ((Idioma)Session["oIdioma"]).Texto("Varios") : sNomProv);

                ReportParameter[] reportParameter = new ReportParameter[2];
                reportParameter[0] = new ReportParameter("Titulo", ((Idioma)Session["oIdioma"]).Texto("RepFacXProveedor"));
                reportParameter[1] = new ReportParameter("Subtitulo", subtitulo);
                ReportViewer1.LocalReport.SetParameters(reportParameter);
                ReportViewer1.LocalReport.Refresh();

                ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DsFactReg_DsFactReg", oFacturas.Datos.Tables[0]));
                ReportViewer1.Visible = true;
                ReportViewer1.LocalReport.Refresh();

                divReporte.Visible = true;
                lblTitulo.Visible  = false;
                divFiltros.Visible = false;
            }
            catch (Exception ex)
            {
                MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto(ex.Message));
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string usuario = "";

            if (Request.Cookies["UsuarioPF"] != null)
            {
                if (Request.Cookies["UsuarioPF"].Value != null)
                {
                    usuario = Request.Cookies["UsuarioPF"].Value;
                }
            }

            //System.Security.Principal.IPrincipal User = HttpContext.Current.User;

            Funciones oMenu = new Funciones();

            oMenu.CargarMenu(usuario); //User.Identity.Name.Substring(User.Identity.Name.IndexOf("\\") + 1));

            NegocioPF.Usuario oUsuario = new NegocioPF.Usuario();
            try
            {
                oUsuario = (Usuario)Session["oUsuario"];
            }
            catch { /*Maneja el error*/ }
            if (oUsuario == null || oUsuario.Id == "")
            {
                oUsuario = new Usuario(usuario); //User.Identity.Name.Substring(User.Identity.Name.IndexOf("\\") + 1));
                oUsuario.Cargar();
                Session["oUsuario"] = oUsuario;
            }

            Idioma oIdioma = new Idioma("");

            try
            {
                oIdioma = (Idioma)Session["oIdioma"];
            }
            catch { /*Maneja el error*/ }
            if (oIdioma == null || oIdioma.Textos.Name == "")
            {
                oIdioma            = new Idioma(oUsuario.Idioma);
                Session["oIdioma"] = oIdioma;
            }

            //Establece la imagen de logo del portal
            imgLogo.Attributes["src"] = "~/images/" + oUsuario.Idioma + "/" + "LogoPF.png";

            //Carga al proveedor
            NegocioPF.Proveedor oProveedor = new NegocioPF.Proveedor(((Usuario)Session["oUsuario"]).Id);
            oProveedor.Cargar();

            lista.Controls.Clear();
            foreach (DataRow r in oMenu.Datos.Tables[0].Rows)
            {
                if (Convert.ToInt32(r["id_parent"]) == 0)
                {
                    HtmlGenericControl li = new HtmlGenericControl("li");
                    li.Attributes.Add("class", "has-sub");
                    lista.Controls.Add(li);

                    HtmlGenericControl anchor = new HtmlGenericControl("a");
                    anchor.Attributes.Add("href", "#");
                    //anchor.InnerText = oIdioma.Texto(r["Descripcion"].ToString());
                    anchor.InnerHtml = "<spam>" + oIdioma.Texto(r["Descripcion"].ToString()) + "</spam>";

                    li.Controls.Add(anchor);

                    AddChildItems(oMenu.Datos.Tables[0], li, Convert.ToInt32(r["id_funcion"]), ref oIdioma);
                }
            }

            HtmlGenericControl li2;
            HtmlGenericControl anchor1;

            //Si es un proveedor, agrega la opción del Contacto
            if (oProveedor.Nombre != "" && oProveedor.Nombre != null)
            {
                li2 = new HtmlGenericControl("li");
                li2.Attributes.Add("class", "dropdown");
                lista.Controls.Add(li2);

                anchor1 = new HtmlGenericControl("a");
                anchor1.Attributes.Add("href", "#");
                //anchor1.Attributes.Add("href", "Contacto.aspx");
                anchor1.Attributes.Add("onclick", "OpenPopupCenter('Contacto1.aspx','Contacto',390,300,0);");
                anchor1.InnerHtml = "<spam>" + oIdioma.Texto("Contactanos") + "</spam>";
                li2.Controls.Add(anchor1);
            }

            //Agrega la opción del Manual, dependiendo de si es usuario o proveedor
            li2 = new HtmlGenericControl("li");
            li2.Attributes.Add("class", "dropdown2");
            lista.Controls.Add(li2);

            anchor1 = new HtmlGenericControl("a");
            anchor1.Attributes.Add("href", "#");

            if (oProveedor.Nombre != "" && oProveedor.Nombre != null)
            {
                Session["archivo"] = "Manuales/ManualProv.pdf";
            }
            else
            {
                Session["archivo"] = "Manuales/ManualUsuario.pdf";
            }

            anchor1.Attributes.Add("onclick", "OpenPopupCenter('VisorPDF.aspx','Manual',670,700,0);");
            anchor1.InnerHtml = "<spam>" + oIdioma.Texto("ManualUsuario") + "</spam>";
            li2.Controls.Add(anchor1);

            //anchor.Attributes.Add("href", (Convert.ToInt32(r["hijos"]) == 0 ? r["url"].ToString() : "#"));

            NegocioPF.Configuracion oConfig = new NegocioPF.Configuracion();
            oConfig.Cargar();
            marMensaje.InnerText = oConfig.Mensaje;
        }
Exemplo n.º 18
0
        private void EnviaRelFacRegXCorreo(ref NegocioPF.Facturas oFacturas, int folio)
        {
            try
            {
                NegocioPF.Proveedor oProveedor = new NegocioPF.Proveedor();
                oProveedor.Cargar(txtEmisor.Text.Substring(0, txtEmisor.Text.IndexOf(" ")));

                string sHtml = "<html>";
                sHtml += "<table style='font-family:arial;color:black;font-size:12px; text-align:justify' border='0' width=\"800\">";
                sHtml += "<tr><td><p>" + ((Idioma)Session["oIdioma"]).Texto("MsgSaludo") + "</p></td></tr>";
                sHtml += "<tr><td></td></tr>";
                sHtml += "<tr><td><p>" + ((Idioma)Session["oIdioma"]).Texto("MsgRelFacReg") + " " + folio.ToString() + ":</p></td></tr>";
                sHtml += "<tr><td></td></tr>";

                if (oFacturas.Datos.Tables[0].Rows.Count > 0)
                {
                    sHtml += "<tr><td><table style='font-family:arial;color:black;font-size:12px; text-align:justify' border='1' cellspacing='0' cellpadding='2' width=\"800\">";
                    sHtml += "<tr>";
                    sHtml += "<td style='background:#F8EFFB; text-align:center; width=80px'> " + grdFacturas.Columns[0].HeaderText + "</td>";
                    sHtml += "<td style='background:#F8EFFB; text-align:center; width=150px'>" + grdFacturas.Columns[1].HeaderText + "</td>";
                    sHtml += "<td style='background:#F8EFFB; text-align:center; width=100px'>" + grdFacturas.Columns[2].HeaderText + "</td>";
                    sHtml += "<td style='background:#F8EFFB; text-align:center; width=100px'>" + grdFacturas.Columns[3].HeaderText + "</td>";
                    sHtml += "<td style='background:#F8EFFB; text-align:center; width=50px'>" + grdFacturas.Columns[4].HeaderText + "</td>";
                    sHtml += "<td style='background:#F8EFFB; text-align:center; width=80px'>" + grdFacturas.Columns[5].HeaderText + "</td>";
                    //sHtml += "<td style='background:#F8EFFB; text-align:center; width=100px'>" + grdFacturas.Columns[6].HeaderText + "</td>";
                    //sHtml += "<td style='background:#F8EFFB; text-align:center; width=100px'>" + grdFacturas.Columns[7].HeaderText + "</td>";
                    sHtml += "</tr>";

                    foreach (GridViewRow r in grdFacturas.Rows)
                    {
                        sHtml += "<tr>";
                        sHtml += "<td style='width=80px;'>" + r.Cells[0].Text + "</td>";
                        sHtml += "<td style='width=150px;'>" + r.Cells[1].Text + "</td>";
                        sHtml += "<td style='width=100px;'>" + r.Cells[2].Text + "</td>";
                        sHtml += "<td style='width=100px;'>" + r.Cells[3].Text + "</td>";
                        sHtml += "<td style='width=50px;'>" + r.Cells[4].Text + "</td>";
                        sHtml += "<td style='width=80px;'>" + r.Cells[5].Text + "</td>";
                        //sHtml += "<td style='width=100px;'>" + r.Cells[6].Text + "</td>";
                        //sHtml += "<td style='width=100px;'>" + r.Cells[7].Text + "</td>";
                        sHtml += "</tr>";
                    }
                    sHtml += "</table></td></tr>";
                }
                sHtml += "<tr><td></td></tr>";
                sHtml += "<tr><td>" + ((Idioma)Session["oIdioma"]).Texto("Saludos") + "</td></tr>";
                sHtml += "<tr><td></td></tr>";
                sHtml += "<tr><td><img src=cid:FirmaPF></td></tr>";
                sHtml += "</table>";
                sHtml += "</Html>";

                EmailTemplate oEmail = new EmailTemplate("");

                oEmail.To.Add(oProveedor.eMail);

                oEmail.From    = new MailAddress(@System.Configuration.ConfigurationSettings.AppSettings["EmailFrom"], "PortalFacturas", System.Text.Encoding.UTF8);
                oEmail.Subject = ((Idioma)Session["oIdioma"]).Texto("FacturasRegistradas") + " " + ((Idioma)Session["oIdioma"]).Texto("ConElFolio").ToLower() + " " + folio.ToString();

                //Agrega Logo
                AlternateView altView = AlternateView.CreateAlternateViewFromString(sHtml, null, MediaTypeNames.Text.Html);

                string         imageSource = (Server.MapPath("") + "\\Images\\FirmaPF.jpg");
                LinkedResource PictureRes  = new LinkedResource(imageSource, MediaTypeNames.Image.Jpeg);
                PictureRes.ContentId = "FirmaPF";
                altView.LinkedResources.Add(PictureRes);

                oEmail.AlternateViews.Add(altView);

                try
                {
                    oEmail.Send();
                }
                catch (Exception ex)
                {
                    throw new Exception("MsgFacRegEnvCorreo");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 19
0
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            NegocioPF.Usuario oUsuario;

            try
            {
                ValidaVariables();

                //Valida si existe otro usuario con el mismo User
                oUsuario    = new NegocioPF.Usuario(txtUsuario.Text);
                oUsuario.Id = txtUsuario.Text;

                oUsuario.Cargar();

                if (oUsuario.Nombre != "" && oUsuario.Nombre != null && Session["accion"].ToString() == "Nuevo")
                {
                    throw new Exception("MsgUsuarioExistente");
                }

                oUsuario.Nombre    = txtNombre.Text;
                oUsuario.Perfil    = Convert.ToInt32(cboPerfiles.SelectedValue);
                oUsuario.Email     = txtCorreo.Text;
                oUsuario.Proveedor = txtProveedor.Text;
                oUsuario.Idioma    = "";
                oUsuario.Status    = cboStatus.SelectedValue;

                //Verifica si el user es el Id de un proveedor
                NegocioPF.Proveedor oProveedor = new NegocioPF.Proveedor(txtUsuario.Text);
                oProveedor.Cargar();
                if (oProveedor.Nombre != "" && oProveedor.Nombre != null)
                {
                    oUsuario.Email = oProveedor.eMail;
                }

                //Si es un user para un proveedor, valida el perfil asignado
                if (oProveedor.Nombre != "" && oProveedor.Nombre != null)
                {
                    NegocioPF.Configuracion oConfig = new NegocioPF.Configuracion();
                    oConfig.Cargar();
                    if (oConfig.PerfilProveedor != Convert.ToInt32(cboPerfiles.SelectedValue))
                    {
                        throw new Exception("MsgPerfProvIncorrecto");
                    }
                }

                //Valida si existe el proveedor
                if (txtProveedor.Text != "")
                {
                    oProveedor = new NegocioPF.Proveedor(txtProveedor.Text);
                    oProveedor.Cargar();
                    if (oProveedor.Nombre == "" || oProveedor.Nombre == null)
                    {
                        throw new Exception("MsgProvInexistente");
                    }
                }

                //Si es un usuario nuevo, genera el password
                if (Session["accion"].ToString() == "Nuevo")
                {
                    oUsuario.Password = NegocioPF.Usuarios.GeneratePassword();
                }

                //oUsuario = new NegocioPF.Usuario(txtUsuario.Text,
                //                                    txtNombre.Text,
                //                                    Convert.ToInt32(cboPerfiles.SelectedValue),
                //                                    correo,
                //                                    password,
                //                                    txtProveedor.Text,
                //                                    "",
                //                                    cboStatus.SelectedValue);

                oUsuario.Guardar(((Usuario)Session["oUsuario"]).Id);

                NegocioPF.Usuarios oUsuarios = new NegocioPF.Usuarios();
                oUsuarios.Cargar(txtFilNumero.Text, txtFilNombre.Text, cboFilPerfil.SelectedValue, cboFilStatus.SelectedValue);
                grdUsuarios.DataSource = oUsuarios.Datos;
                grdUsuarios.DataBind();

                divDetalle.Visible = false;
                divFiltros.Visible = true;

                if (Session["accion"].ToString() == "Nuevo" && oUsuario.Email != "")
                {
                    EnviaCorreoUsuario(txtUsuario.Text);
                    MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto("MsgCtaCreada"));
                }
                else
                {
                    MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto("MsgUsuarioGuardado"));
                }
            }
            catch (Exception ex)
            {
                if (ex.Message.Length > 3)
                {
                    if (ex.Message.Substring(0, 3) == "Msg")
                    {
                        MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto(ex.Message));
                    }
                    else
                    {
                        MessageBox(sender, e, ex.Message);
                    }
                }
            }
        }
Exemplo n.º 20
0
        protected void btnAceptarRegistro_Click(object sender, EventArgs e)
        {
            try
            {
                NegocioPF.Usuario oUsuario = new NegocioPF.Usuario(txtProveedor.Text);
                oUsuario.Cargar();

                NegocioPF.Proveedor oProveedor = new NegocioPF.Proveedor(txtProveedor.Text);
                oProveedor.Cargar();

                NegocioPF.Configuracion oConfig = new NegocioPF.Configuracion();
                oConfig.Cargar();

                if (oUsuario.Nombre != "")
                {
                    throw new Exception("UsuarioProvExistente");
                }
                else
                {
                    if (oProveedor.Nombre == "")
                    {
                        throw new Exception("NumProvInexistente");
                    }
                    else
                    {
                        if (oProveedor.RFC != txtRFCProv.Text)
                        {
                            throw new Exception("RFCIncorrecto");
                        }
                        else
                        {
                            oUsuario           = new Usuario();
                            oUsuario.Id        = txtProveedor.Text;
                            oUsuario.Nombre    = oProveedor.Nombre;
                            oUsuario.Perfil    = oConfig.PerfilProveedor;
                            oUsuario.Proveedor = txtProveedor.Text;
                            oUsuario.Status    = "ACTIVO";
                            oUsuario.Password  = NegocioPF.Usuarios.GeneratePassword();
                            oUsuario.Guardar(txtProveedor.Text);

                            //Enviar el correo a la cuenta del proveedor
                            if (oProveedor.eMail != "" && oProveedor.eMail != null)
                            {
                                EnviaCorreoNuevaCuenta(oUsuario);
                                MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto("MsgCtaCreada"));
                            }
                            else
                            {
                                throw new Exception("MsgUsuarioPwdInicial");
                            }
                        }
                    }
                }
                lblTitulo.Text        = ((Idioma)Session["oIdioma"]).Texto("Bienvenido");
                divLogin.Visible      = true;
                divCambioPasw.Visible = false;
                divNuevaCta.Visible   = false;
            }
            catch (Exception ex)
            {
                MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto(ex.Message));
            }
        }
Exemplo n.º 21
0
        protected void btnAceptarImportar_Click(object sender, EventArgs e)
        {
            int    registros = 0;
            string sPathArchivo;

            try
            {
                ValidaVariables();

                if ((File1.PostedFile == null) || (File1.PostedFile.ContentLength == 0))
                {
                    throw new Exception("MsgSelArchHdr");
                }

                //Copia el archivo
                string fn = System.IO.Path.GetFileName(File1.PostedFile.FileName);

                sPathArchivo = Server.MapPath("") + "\\Data\\Servicios." + fn.Substring(fn.Length - 3, 3);

                try
                {
                    File1.PostedFile.SaveAs(sPathArchivo);
                }
                catch (Exception ex)
                {
                    MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto("MsgErrorCopiarArchivo"));
                }

                try
                {
                    NegocioPF.Servicios oServicios = new NegocioPF.Servicios();

                    registros = oServicios.ImportarTXT(((Usuario)Session["oUsuario"]).Id, sPathArchivo,
                                                       System.IO.Path.GetFileName(File1.PostedFile.FileName));

                    NegocioPF.Proveedor oProveedor = new NegocioPF.Proveedor(((Usuario)Session["oUsuario"]).Id);
                    oProveedor.Cargar();

                    oServicios = new NegocioPF.Servicios();
                    if (oProveedor.Nombre != "" && oProveedor.Nombre != null)
                    {
                        oServicios.Cargar(((Usuario)Session["oUsuario"]).Id, "");
                    }
                    else
                    {
                        oServicios.Cargar();
                    }
                    grdServicios.DataSource = oServicios.Datos;
                    grdServicios.DataBind();
                    divImportar.Visible = false;

                    MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto("MsgRegActInsertados") + registros.ToString());
                }
                catch (Exception ex)
                {
                    MessageBox(sender, e, "Error:" + ((Idioma)Session["oIdioma"]).Texto(ex.Message));
                }
            }
            catch (Exception ex)
            {
                MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto(ex.Message));
            }
        }
Exemplo n.º 22
0
        protected void btnExportar_Click(object sender, EventArgs e)
        {
            int ren = 0;

            try
            {
                ValidaVariables();

                NegocioPF.Pedidos oPedidos = new NegocioPF.Pedidos();

                NegocioPF.Proveedor oProveedor = new NegocioPF.Proveedor(((Usuario)Session["oUsuario"]).Id);
                oProveedor.Cargar();
                if (oProveedor.Nombre != "" && oProveedor.Nombre != null)
                {
                    oPedidos.Cargar(oProveedor.Id, txtOrden.Text, "Pendiente");
                }
                else
                {
                    oPedidos.Cargar(txtProveedor.Text, txtOrden.Text, "");
                }

                ArmarArchivo(ref oPedidos);


                ////string filename = Server.MapPath("") + "\\Facturas\\Pedidos.xls";
                //FileInfo newFile = new FileInfo(Server.MapPath("") + @"\sample1.xlsx");
                //if (newFile.Exists)
                //{
                //    newFile.Delete();  // ensures we create a new workbook
                //    newFile = new FileInfo(Server.MapPath("") + @"\sample1.xlsx");
                //}
                //using (ExcelPackage package = new ExcelPackage(newFile))
                //{
                //    // add a new worksheet to the empty workbook
                //    ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("Pedidos");

                //    //Add the headers
                //    worksheet.Cells[1, 1].Value = "ID";
                //    worksheet.Cells[1, 2].Value = "Product";
                //    worksheet.Cells[1, 3].Value = "Quantity";
                //    worksheet.Cells[1, 4].Value = "Price";
                //    worksheet.Cells[1, 5].Value = "Value";

                //    //Add some items...
                //    worksheet.Cells["A2"].Value = 12001;
                //    worksheet.Cells["B2"].Value = "Nails";
                //    worksheet.Cells["C2"].Value = 37;
                //    worksheet.Cells["D2"].Value = 3.99;

                //    worksheet.Cells["A3"].Value = 12002;
                //    worksheet.Cells["B3"].Value = "Hammer";
                //    worksheet.Cells["C3"].Value = 5;
                //    worksheet.Cells["D3"].Value = 12.10;

                //    worksheet.Cells["A4"].Value = 12003;
                //    worksheet.Cells["B4"].Value = "Saw";
                //    worksheet.Cells["C4"].Value = 12;
                //    worksheet.Cells["D4"].Value = 15.37;

                //    //Add a formula for the value-column
                //    worksheet.Cells["E2:E4"].Formula = "C2*D2";

                //    //Ok now format the values;
                //    using (var range = worksheet.Cells[1, 1, 1, 5])
                //    {
                //        range.Style.Font.Bold = true;
                //        range.Style.Fill.PatternType = ExcelFillStyle.Solid;
                //        range.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.DarkBlue);
                //        range.Style.Font.Color.SetColor(System.Drawing.Color.White);
                //    }

                //    worksheet.Cells["A5:E5"].Style.Border.Top.Style = ExcelBorderStyle.Thin;
                //    worksheet.Cells["A5:E5"].Style.Font.Bold = true;

                //    worksheet.Cells[5, 3, 5, 5].Formula = string.Format("SUBTOTAL(9,{0})", new ExcelAddress(2, 3, 4, 3).Address);
                //    worksheet.Cells["C2:C5"].Style.Numberformat.Format = "#,##0";
                //    worksheet.Cells["D2:E5"].Style.Numberformat.Format = "#,##0.00";

                //    //Create an autofilter for the range
                //    worksheet.Cells["A1:E4"].AutoFilter = true;

                //    worksheet.Cells["A2:A4"].Style.Numberformat.Format = "@";   //Format as text

                //    //There is actually no need to calculate, Excel will do it for you, but in some cases it might be useful.
                //    //For example if you link to this workbook from another workbook or you will open the workbook in a program that hasn't a calculation engine or
                //    //you want to use the result of a formula in your program.
                //    worksheet.Calculate();

                //    worksheet.Cells.AutoFitColumns(0);  //Autofit columns for all cells

                //    // lets set the header text
                //    worksheet.HeaderFooter.OddHeader.CenteredText = "&24&U&\"Arial,Regular Bold\" Inventory";
                //    // add the page number to the footer plus the total number of pages
                //    worksheet.HeaderFooter.OddFooter.RightAlignedText =
                //        string.Format("Page {0} of {1}", ExcelHeaderFooter.PageNumber, ExcelHeaderFooter.NumberOfPages);
                //    // add the sheet name to the footer
                //    worksheet.HeaderFooter.OddFooter.CenteredText = ExcelHeaderFooter.SheetName;
                //    // add the file path to the footer
                //    worksheet.HeaderFooter.OddFooter.LeftAlignedText = ExcelHeaderFooter.FilePath + ExcelHeaderFooter.FileName;

                //    worksheet.PrinterSettings.RepeatRows = worksheet.Cells["1:2"];
                //    worksheet.PrinterSettings.RepeatColumns = worksheet.Cells["A:G"];

                //    // Change the sheet view to show it in page layout mode
                //    worksheet.View.PageLayoutView = true;

                //    // set some document properties
                //    package.Workbook.Properties.Title = "Invertory";
                //    package.Workbook.Properties.Author = "Jan Källman";
                //    package.Workbook.Properties.Comments = "This sample demonstrates how to create an Excel 2007 workbook using EPPlus";

                //    // set some extended property values
                //    package.Workbook.Properties.Company = "AdventureWorks Inc.";

                //    // set some custom property values
                //    package.Workbook.Properties.SetCustomPropertyValue("Checked by", "Jan Källman");
                //    package.Workbook.Properties.SetCustomPropertyValue("AssemblyName", "EPPlus");
                //    // save our new workbook and we are done!
                //    package.Save();

                //}

                //return newFile.FullName;
            }
            catch (Exception ex)
            {
                MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto(ex.Message));
            }
        }
Exemplo n.º 23
0
        protected void btnGenerar_Click(object sender, EventArgs e)
        {
            string sProveedor  = "";
            string sSociedades = "";
            string sNomSoc     = "";

            try
            {
                //Ocultar los botones
                ReportViewer1.ShowPageNavigationControls       = false;
                ReportViewer1.ShowBackButton                   = false;
                ReportViewer1.ShowFindControls                 = false;
                ReportViewer1.ShowPrintButton                  = true;
                ReportViewer1.ShowExportControls               = true;
                ReportViewer1.LocalReport.EnableExternalImages = true;
                //ReportViewer1.LocalReport.ExecuteReportInCurrentAppDomain(AppDomain.CurrentDomain.Evidence);

                ReportViewer1.Reset();
                ReportViewer1.LocalReport.Dispose();
                ReportViewer1.LocalReport.DataSources.Clear();
                ReportViewer1.LocalReport.ReportPath = "Reports\\RepFacXFolio_" + ((Usuario)Session["oUsuario"]).Idioma + ".rdlc";
                ReportViewer1.ProcessingMode         = Microsoft.Reporting.WebForms.ProcessingMode.Local;

                //Si el usuario es un usuario del proveedor, agrega el proveedor a los filtros
                NegocioPF.Proveedor oProveedor = new NegocioPF.Proveedor(((Usuario)Session["oUsuario"]).Id);
                oProveedor.Cargar();
                if (oProveedor.Nombre != "" && oProveedor.Nombre != null)
                {
                    sProveedor = "'" + oProveedor.Id + "'";
                }

                //Recupera las sociedades seleccionadas
                foreach (ListItem item in cboSociedades.Items)
                {
                    if (item.Selected)
                    {
                        sSociedades += "'" + item.Value + "',";
                        sNomSoc     += item.Text + ",";
                    }
                }
                if (sSociedades.Length > 0)
                {
                    sSociedades = sSociedades.Substring(0, sSociedades.Length - 1);
                    sNomSoc     = sNomSoc.Substring(0, sNomSoc.Length - 1);
                }

                DateTime fecFact = new DateTime(1900, 1, 1);
                DateTime fecIni  = new DateTime(1900, 1, 1);
                DateTime fecFin  = new DateTime(1900, 1, 1);

                NegocioPF.Facturas oFacturas = new NegocioPF.Facturas();
                oFacturas.Cargar(sProveedor, "", "", "", fecFact, fecFact, fecIni, fecFin, 0, 0, sSociedades, "", "");

                string subtitulo = ((Idioma)Session["oIdioma"]).Texto("Sociedades") + ":" + sNomSoc;

                ReportParameter[] reportParameter = new ReportParameter[2];
                reportParameter[0] = new ReportParameter("Titulo", ((Idioma)Session["oIdioma"]).Texto("RepFacXSociedad"));
                reportParameter[1] = new ReportParameter("Subtitulo", subtitulo);
                ReportViewer1.LocalReport.SetParameters(reportParameter);
                ReportViewer1.LocalReport.Refresh();

                ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DsFactReg_DsFactReg", oFacturas.Datos.Tables[0]));
                ReportViewer1.Visible = true;
                ReportViewer1.LocalReport.Refresh();

                divReporte.Visible = true;
                lblTitulo.Visible  = false;
                divFiltros.Visible = false;
            }
            catch (Exception ex)
            {
                MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto(ex.Message));
            }
        }
Exemplo n.º 24
0
        private void ArmarTabla(ref NegocioPF.Pedidos oPedidos)
        {
            TableRow  row;
            TableCell cell;
            string    proveedor = "";

            try
            {
                NegocioPF.Proveedor oProveedor = new NegocioPF.Proveedor(((Usuario)Session["oUsuario"]).Id);
                oProveedor.Cargar();
                if (oProveedor.Nombre != "" && oProveedor.Nombre != null)
                {
                    proveedor = oProveedor.Id;
                }

                foreach (DataRow r in oPedidos.Datos.Tables[0].Rows)
                {
                    NegocioPF.Pedido oPedido = new NegocioPF.Pedido(r["id_sociedad"].ToString(), r["id_pedido"].ToString());
                    oPedido.Cargar(proveedor);

                    //Crea los encabezados
                    tabPedidos.CssClass = "table";

                    // Llena la tabla con los resultados
                    row             = new TableRow();
                    cell            = new TableCell();
                    cell.Text       = ((Idioma)Session["oIdioma"]).Texto("Pedido");
                    cell.CssClass   = "cellTitulo";
                    cell.ColumnSpan = 12;
                    row.Cells.Add(cell);
                    tabPedidos.Rows.Add(row);

                    //Encabezados del Pedido
                    row = new TableRow();
                    row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("NoPedido")));
                    row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("Sociedad")));
                    row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("OrgCompras")));
                    row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("GpoCompras")));
                    row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("ClaseDocto")));
                    row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("Proveedor")));
                    cell            = NewCell(((Idioma)Session["oIdioma"]).Texto("NomProveedor"));
                    cell.ColumnSpan = 3;
                    row.Cells.Add(cell);
                    row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("Estatus")));
                    row.Cells.Add(NewCell(""));
                    row.Cells.Add(NewCell(""));
                    tabPedidos.Rows.Add(row);

                    //Valores del pedido
                    row = new TableRow();
                    row.Cells.Add(NewCell(Convert.ToString(r["id_pedido"])));
                    row.Cells.Add(NewCell(Convert.ToString(r["id_sociedad"])));
                    row.Cells.Add(NewCell(Convert.ToString(r["id_orgcomp"])));
                    row.Cells.Add(NewCell(Convert.ToString(r["id_gpocomp"])));
                    row.Cells.Add(NewCell(Convert.ToString(r["id_clasedoc"])));
                    row.Cells.Add(NewCell(Convert.ToString(r["id_proveedor"])));
                    cell            = NewCell(Convert.ToString(r["nombre"]));
                    cell.ColumnSpan = 3;
                    row.Cells.Add(cell);
                    row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto(Convert.ToString(oPedido.Status))));
                    row.Cells.Add(NewCell(""));
                    row.Cells.Add(NewCell(""));
                    tabPedidos.Rows.Add(row);

                    //Encabezados de Entregas
                    if (oPedido.Entregas.Tables[0].Rows.Count > 0)
                    {
                        row             = new TableRow();
                        cell            = new TableCell();
                        cell.Text       = ((Idioma)Session["oIdioma"]).Texto("Entregas");
                        cell.CssClass   = "cellSubtitulo";
                        cell.ColumnSpan = 12;
                        row.Cells.Add(cell);
                        tabPedidos.Rows.Add(row);

                        row = new TableRow();
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("NoPedido")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("Posicion")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("Entrega")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("PosEntrega")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("Cantidad")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("ImporteML")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("Importe")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("Moneda")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("Material")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("Descripcion")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("NotaEntrega")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("Estatus")));
                        tabPedidos.Rows.Add(row);

                        //Valores de las entregas
                        foreach (DataRow e in oPedido.Entregas.Tables[0].Rows)
                        {
                            row = new TableRow();
                            row.Cells.Add(NewCell(Convert.ToString(e["id_pedido"])));
                            row.Cells.Add(NewCell(Convert.ToString(e["id_pos_ped"])));
                            row.Cells.Add(NewCell(Convert.ToString(e["id_entrega"])));
                            row.Cells.Add(NewCell(Convert.ToString(e["id_posicion"])));
                            row.Cells.Add(NewCell(Convert.ToString(e["cantidad"])));
                            cell = NewCell(String.Format("{0:n2}", Convert.ToDouble(e["importeML"])));
                            cell.HorizontalAlign = HorizontalAlign.Right;
                            row.Cells.Add(cell);
                            cell = NewCell(String.Format("{0:n2}", Convert.ToDouble(e["importe"])));
                            cell.HorizontalAlign = HorizontalAlign.Right;
                            row.Cells.Add(cell);
                            row.Cells.Add(NewCell(Convert.ToString(e["moneda"])));
                            row.Cells.Add(NewCell(Convert.ToString(e["id_material"])));
                            row.Cells.Add(NewCell(Convert.ToString(e["descripcion"])));
                            row.Cells.Add(NewCell(Convert.ToString(e["nota_entrega"])));
                            row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto(Convert.ToString(e["status"]))));
                            tabPedidos.Rows.Add(row);
                        }
                    }

                    if (oPedido.Costos.Tables[0].Rows.Count > 0)
                    {
                        row             = new TableRow();
                        cell            = new TableCell();
                        cell.Text       = ((Idioma)Session["oIdioma"]).Texto("CostosInd");
                        cell.CssClass   = "cellSubtitulo";
                        cell.ColumnSpan = 12;
                        row.Cells.Add(cell);
                        tabPedidos.Rows.Add(row);

                        //Encabezados de Costos indirectos
                        row = new TableRow();
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("NoPedido")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("Posicion")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("DocRefer")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("Posicion")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("Cantidad")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("ImporteML")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("Importe")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("Moneda")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("Proveedor")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("TipoCond")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("NotaEntrega")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("Estatus")));
                        tabPedidos.Rows.Add(row);

                        //Valores de las entregas
                        foreach (DataRow c in oPedido.Costos.Tables[0].Rows)
                        {
                            row = new TableRow();
                            row.Cells.Add(NewCell(Convert.ToString(c["id_pedido"])));
                            row.Cells.Add(NewCell(Convert.ToString(c["id_pos_ped"])));
                            row.Cells.Add(NewCell(Convert.ToString(c["id_entrega"])));
                            row.Cells.Add(NewCell(Convert.ToString(c["id_posicion"])));
                            row.Cells.Add(NewCell(Convert.ToString(c["cantidad"])));
                            cell = NewCell(String.Format("{0:n2}", Convert.ToDouble(c["importeML"])));
                            cell.HorizontalAlign = HorizontalAlign.Right;
                            row.Cells.Add(cell);
                            cell = NewCell(String.Format("{0:n2}", Convert.ToDouble(c["importe"])));
                            cell.HorizontalAlign = HorizontalAlign.Right;
                            row.Cells.Add(cell);
                            row.Cells.Add(NewCell(Convert.ToString(c["moneda"])));
                            row.Cells.Add(NewCell(Convert.ToString(c["id_proveedor"])));
                            row.Cells.Add(NewCell(Convert.ToString(c["id_tipoCond"])));
                            row.Cells.Add(NewCell(Convert.ToString(c["ref_docto"])));
                            row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto(Convert.ToString(c["status"]))));
                            tabPedidos.Rows.Add(row);
                        }
                    }

                    //Encabezados de Servicios
                    if (oPedido.Servicios.Tables[0].Rows.Count > 0)
                    {
                        row             = new TableRow();
                        cell            = new TableCell();
                        cell.Text       = ((Idioma)Session["oIdioma"]).Texto("Servicios");
                        cell.CssClass   = "cellSubtitulo";
                        cell.ColumnSpan = 12;
                        row.Cells.Add(cell);
                        tabPedidos.Rows.Add(row);

                        row = new TableRow();
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("NoPedido")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("Posicion")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("Documento")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("Posicion")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("Cantidad")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("ImporteML")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("Importe")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("Moneda")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("Material")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("Descripcion")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("Referencia")));
                        row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto("Estatus")));
                        tabPedidos.Rows.Add(row);

                        //Valores de las entregas
                        foreach (DataRow e in oPedido.Servicios.Tables[0].Rows)
                        {
                            row = new TableRow();
                            row.Cells.Add(NewCell(Convert.ToString(e["id_pedido"])));
                            row.Cells.Add(NewCell(Convert.ToString(e["id_pos_ped"])));
                            row.Cells.Add(NewCell(Convert.ToString(e["id_documento"])));
                            row.Cells.Add(NewCell(Convert.ToString(e["id_posicion"])));
                            row.Cells.Add(NewCell(Convert.ToString(e["cantidad"])));
                            cell = NewCell(String.Format("{0:n2}", Convert.ToDouble(e["importeML"])));
                            cell.HorizontalAlign = HorizontalAlign.Right;
                            row.Cells.Add(cell);
                            cell = NewCell(String.Format("{0:n2}", Convert.ToDouble(e["importe"])));
                            cell.HorizontalAlign = HorizontalAlign.Right;
                            row.Cells.Add(cell);
                            row.Cells.Add(NewCell(Convert.ToString(e["moneda"])));
                            row.Cells.Add(NewCell(Convert.ToString(e["material"])));
                            row.Cells.Add(NewCell(Convert.ToString(e["descripcion"])));
                            row.Cells.Add(NewCell(Convert.ToString(e["ref_docto"])));
                            row.Cells.Add(NewCell(((Idioma)Session["oIdioma"]).Texto(Convert.ToString(e["status"]))));
                            tabPedidos.Rows.Add(row);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox(null, null, ((Idioma)Session["oIdioma"]).Texto(ex.Message));
            }
        }