public IHttpActionResult agregarInformes(Informes informes)
        {
            try
            {
                var accion = SessionController.getInstance().Informes.Where(w => w.telefono == informes.telefono).FirstOrDefault();

                if (accion != null)
                {
                    return(Ok(false));
                }

                Informes datos = new Informes
                {
                    idInformes = Guid.NewGuid(),
                    nombre     = informes.nombre,
                    cp         = informes.cp,
                    telefono   = informes.telefono,
                    visto      = informes.visto,
                    activo     = informes.activo
                };

                SessionController.getInstance().Informes.Add(datos);

                SessionController.getInstance().SaveChanges();

                return(Ok(true));
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }
        public IHttpActionResult modificarInformes(Informes informes)
        {
            try
            {
                var accion = SessionController.getInstance().Informes.Where(w => w.idInformes == informes.idInformes).FirstOrDefault();

                if (accion == null)
                {
                    return(Ok(false));
                }

                accion.nombre   = informes.nombre;
                accion.cp       = informes.cp;
                accion.telefono = informes.telefono;
                accion.visto    = informes.visto;
                accion.activo   = informes.activo;

                SessionController.getInstance().SaveChanges();

                return(Ok(true));
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }
 // GET: Informes
 public ActionResult Index()
 {
     if (Session["usuario"] != null)
     {
         Informes inf = new Informes
         {
             InformeCliente           = ClienteList(),
             InformClientesGasto      = ClientesGastoList(),
             InformeClienteFiados     = ClientesFiadosList(),
             InformeProveedorProducto = ProveedorProductoList(),
             InformePeoresFiadores    = PeoresFiadoresList(),
             InformeBoletas30Dias     = Boletas30DiasList(),
             InformeStockProductos    = ProductosPorStock(1)
         };
         return(View(inf));
     }
     return(Redirect("~/Login/"));
 }
 public void AddToInformesSet(Informes informes)
 {
     base.AddObject("InformesSet", informes);
 }
 public static Informes CreateInformes(int ID, byte[] rowVersion, string informe1)
 {
     Informes informes = new Informes();
     informes.Id = ID;
     informes.RowVersion = rowVersion;
     informes.Informe1 = informe1;
     return informes;
 }
Esempio n. 6
0
        static void Main(string[] args)
        {
            Tanque T1 = new Tanque(TipoCañon.KwK_43, 10, TipoMotor.Maybach_HL_230_P30, 10, TipoAmetralladoras.MG_34, 10); // Tiger

            Tanque T2 = new Tanque(TipoCañon.M1_76_mm, 2, TipoMotor.R975_C4, 2, TipoAmetralladoras.Browning_M1919A4, 3);  // Sherman

            Tanque T3 = new Tanque(TipoCañon.F34_de_76_2_mm, 3, TipoMotor.Diesel_V2_34, 3, TipoAmetralladoras.DT, 6);     // T-34

            Avion A1 = new Avion(Cañones.Hispano_M2, 2, MotorRadial.Pratt_and_Whitney_R, 5, Ametralladoras.Browning_M2, 10);

            Avion A2 = new Avion(Cañones.MG_151_20, 10, MotorRadial.Gnome_Rhône_14M_5, 11, Ametralladoras.MG_17, 9);

            Avion A3 = new Avion(Cañones.Nudelman_Suranov_NS_23, 1, MotorRadial.Daimler_Benz_DB_603, 3, Ametralladoras.Berezin_UB, 5);

            Fabrica <Tanque, Avion> fabricarTanquesyAviones = new Fabrica <Tanque, Avion>(100);

            T1.IdentificarTanque();
            T2.IdentificarTanque();
            T3.IdentificarTanque();

            A1.IdentificarAvion();
            A2.IdentificarAvion();
            A3.IdentificarAvion();

            fabricarTanquesyAviones.AdministrarCapacidad();

            fabricarTanquesyAviones.ValidarIngresoTanques(T1);
            fabricarTanquesyAviones.ValidarIngresoTanques(T2);
            fabricarTanquesyAviones.ValidarIngresoTanques(T3);

            fabricarTanquesyAviones.ValidarIngresoAviones(A1);
            fabricarTanquesyAviones.ValidarIngresoAviones(A2);
            fabricarTanquesyAviones.ValidarIngresoAviones(A3);

            Console.WriteLine(fabricarTanquesyAviones.EmsambladoTanques(T1));
            Console.WriteLine(fabricarTanquesyAviones.EmsambladoTanques(T2));
            Console.WriteLine(fabricarTanquesyAviones.EmsambladoTanques(T3));

            Console.WriteLine(fabricarTanquesyAviones.EmsambladoAviones(A1));
            Console.WriteLine(fabricarTanquesyAviones.EmsambladoAviones(A2));
            Console.WriteLine(fabricarTanquesyAviones.EmsambladoAviones(A3));

            Console.WriteLine(fabricarTanquesyAviones.Mostrar());

            Informes <Tanque> informeTanques = new Informes <Tanque>();
            Informes <Avion>  informeAviones = new Informes <Avion>();

            informeTanques.GenerarInformeXML(T1);
            informeAviones.GenerarInformeXML(A1);

            Console.WriteLine("Se genero informe XML de materiales de Tanque Tiger y Avion BlackWidow");

            Console.WriteLine("Pruebo excepcionCapacidad, presione una tecla para continuar...");

            Console.ReadKey();

            try
            {
                Fabrica <Tanque, Avion> fabricaPrueba = new Fabrica <Tanque, Avion>(-1);
                fabricaPrueba.AdministrarCapacidad();
            }
            catch (ExcepcionCapacidad ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.WriteLine("Pruebo excepcion, presione una tecla para continuar...");
            Console.ReadKey();

            try
            {
                Tanque T4 = new Tanque(TipoCañon.KwK_43, 10, TipoMotor.R975_C4, 10, TipoAmetralladoras.MG_34, 10); // Tiger
                T4.IdentificarTanque();
            }
            catch (ExcepcionCompatibilidad ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.ReadKey();
        }
Esempio n. 7
0
 /// <summary>
 /// Asocia el dato del total de artículos a su correspondiente label.
 /// </summary>
 public void ImprimirTotalArticulos()
 {
     lblCifraTotalArticulos.Text = Informes.TotalArticulos(lista).ToString();
 }
Esempio n. 8
0
 /// <summary>
 /// Asocia el dato del total de páginas a su correspondiente label.
 /// </summary>
 public void ImprimirTotalPaginas()
 {
     lblCifraTotalPaginas.Text = Informes.TotalPaginas(lista).ToString();
 }
Esempio n. 9
0
 /// <summary>
 /// Asocia el dato del total de documentos a su correspondiente label.
 /// </summary>
 public void ImprimirTotalDocumentos()
 {
     lblCifraTotalDocumentos.Text = Informes.TotalDocumentos(lista).ToString();
 }
Esempio n. 10
0
        /// <summary>
        /// Handles the Click event of the bGenerar control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void bGenerar_Click(object sender, EventArgs e)
        {
            Page.Validate();
            if (Page.IsValid)
            {
                var where = "";
                try
                {
                    _count = 0;
                    if (!ddlReporte.SelectedValue.Equals("0"))
                    {
                        if (!string.IsNullOrEmpty(tbFechaInicial.Text) && !string.IsNullOrEmpty(tbFechaFinal.Text))
                        {
                            if (!Convert.ToDateTime(tbFechaInicial.Text).ToString("yyyyMMdd").Equals("00010101") && !Convert.ToDateTime(tbFechaFinal.Text).ToString("yyyyMMdd").Equals("00010101"))
                            {
                                if (Convert.ToDateTime(tbFechaInicial.Text) <= Convert.ToDateTime(tbFechaFinal.Text))
                                {
                                    _fecha         = Convert.ToDateTime(tbFechaInicial.Text).ToString("yyyyMMdd");
                                    _fechanom      = Convert.ToDateTime(tbFechaFinal.Text).ToString("yyyyMMdd");
                                    _fechacreacion = Localization.Now.ToString("yyyyMMddHHmmss");
                                    if (ddlTipoFecha.SelectedValue.Equals("1"))
                                    {
                                        // Fecha de Recepción
                                        where += " CONVERT(VARCHAR(MAX),g.fechaRecepcion,112) >= " + Convert.ToDateTime(tbFechaInicial.Text).ToString("yyyyMMdd") + " AND CONVERT(VARCHAR(MAX),g.fechaRecepcion,112) <=" + Convert.ToDateTime(tbFechaFinal.Text).ToString("yyyyMMdd") + " AND ";
                                    }
                                    else
                                    {
                                        // Fecha de Emisión
                                        where += " CONVERT(VARCHAR(MAX),g.FECHA,112) >= " + Convert.ToDateTime(tbFechaInicial.Text).ToString("yyyyMMdd") + " AND CONVERT(VARCHAR(MAX),g.FECHA,112) <=" + Convert.ToDateTime(tbFechaFinal.Text).ToString("yyyyMMdd") + " AND ";
                                    }
                                    if (ddlEstado.SelectedValue != "0")
                                    {
                                        where += " (g.tipo +g.estado) =  '" + ddlEstado.SelectedValue + "' AND ";
                                    }
                                    if (ddlEstadoValidacion.SelectedValue != "0")
                                    {
                                        where += " g.estadoValidacion = '" + ddlEstadoValidacion.SelectedValue + "' AND ";
                                    }
                                    if (ddlTipDoc.SelectedValue != "0")
                                    {
                                        where += " g.codDoc='" + ddlTipDoc.SelectedValue + "' AND ";
                                    }
                                    if (ddlEmisor.SelectedValue != "0")
                                    {
                                        where += " cem.RFCEMI='" + ddlEmisor.SelectedItem.Text + "' AND ";
                                    }
                                    if (ddlReceptor.SelectedValue != "0")
                                    {
                                        where += " cr.RFCREC='" + ddlReceptor.SelectedItem.Text + "' AND ";
                                    }
                                    where = where.Substring(0, where.Length - 5);
                                    if (!ddlReporte.SelectedValue.Equals("Contabilidad"))
                                    {
                                        _virtualDir = @"docs\" + (Session["IDENTEMI"] != null ? Session["IDENTEMI"].ToString() : "CORE") + _fechacreacion + "_" + ddlReporte.SelectedValue + ".xlsx";
                                    }
                                    else
                                    {
                                        _virtualDir = @"docs\" + "U" + new string((Session["IDENTEMI"] != null ? Session["IDENTEMI"].ToString() : "CORE").Take(3).ToArray()) + _fecha + ".txt";
                                    }
                                    _dir = AppDomain.CurrentDomain.BaseDirectory + @"recepcion\" + _virtualDir;
                                    Directory.CreateDirectory(Path.GetDirectoryName(_dir));
                                    var periodo  = tbFechaInicial.Text + " - " + tbFechaFinal.Text;
                                    var informes = new Informes(_dir, _dbr.CadenaConexion, periodo, Session["IDGIRO"].ToString(), true);
                                    if (ddlReporte.SelectedValue.Equals("General"))
                                    {
                                        _dbr.Conectar();
                                        _dbr.CrearComando(@"SELECT  count(g.idComprobante)
                                            FROM            Dat_GENERAL g INNER JOIN
                                                Cat_Emisor cem ON g.id_Emisor = cem.IDEEMI LEFT OUTER JOIN
                                                Cat_RECEPTOR cr ON g.id_Receptor = cr.IDEREC
                                            WHERE " + where);

                                        var dr = _dbr.EjecutarConsulta();
                                        if (dr.Read())
                                        {
                                            _count = Convert.ToInt32(dr[0]);
                                        }
                                        _dbr.Desconectar();
                                        if (_count > 0)
                                        {
                                            if (informes.General(where))
                                            {
                                                var js = "downloadFile('" + _virtualDir.Replace(@"\", "/") + "');";
                                                ScriptManager.RegisterStartupScript(this, GetType(), "downloadViaJS", js, true);
                                            }
                                            else
                                            {
                                                ScriptManager.RegisterStartupScript(this, GetType(), "alertBootBox", "alertBootBox('" + informes.Ex.Message + "', 4);", true);
                                            }
                                        }
                                        else
                                        {
                                            ScriptManager.RegisterStartupScript(this, GetType(), "alertBootBox", "alertBootBox('No hay registros de acuerdo a los criterios de busqueda', 4);", true);
                                        }
                                    }
                                    else if (ddlReporte.SelectedValue.Equals("Conceptos"))
                                    {
                                        _dbr.Conectar();
                                        _dbr.CrearComando(@"SELECT  COUNT(g.idComprobante)
                                              FROM   Dat_Detalles dd inner join
			                                       Dat_general g on g.idComprobante = dd.id_Comprobante INNER JOIN
                                                   Cat_Emisor cem ON g.id_Emisor = cem.IDEEMI LEFT OUTER JOIN
			                                       Cat_RECEPTOR cr ON cr.IDEREC = g.id_Receptor
                                             WHERE " + where);
                                        var dr = _dbr.EjecutarConsulta();
                                        if (dr.Read())
                                        {
                                            _count = Convert.ToInt32(dr[0]);
                                        }
                                        _dbr.Desconectar();
                                        if (_count > 0)
                                        {
                                            if (informes.Conceptos(where))
                                            {
                                                var js = "downloadFile('" + _virtualDir.Replace(@"\", "/") + "');";
                                                ScriptManager.RegisterStartupScript(this, GetType(), "downloadViaJS", js, true);
                                            }
                                            else
                                            {
                                                ScriptManager.RegisterStartupScript(this, GetType(), "alertBootBox", "alertBootBox('" + informes.Ex.Message + "', 4);", true);
                                            }
                                        }
                                        else
                                        {
                                            ScriptManager.RegisterStartupScript(this, GetType(), "alertBootBox", "alertBootBox('No hay registros de acuerdo a los criterios de busqueda', 4);", true);
                                        }
                                    }
                                }
                                else
                                {
                                    ScriptManager.RegisterStartupScript(this, GetType(), "alertBootBox", "alertBootBox('Selecciona fecha inicial y fecha final', 4);", true);
                                }
                            }
                            else
                            {
                                ScriptManager.RegisterStartupScript(this, GetType(), "alertBootBox", "alertBootBox('Tienes que seleccionar ambas fechas', 4);", true);
                            }
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, GetType(), "alertBootBox", "alertBootBox('Tienes que seleccionar ambas fechas', 4);", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "alertBootBox", "alertBootBox('Tienes que seleccionar un tipo de Reporte', 4);", true);
                    }
                }
                catch (Exception ea)
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "alertBootBox", "alertBootBox('" + ea.Message + "', 4);", true);
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "alertBootBox", "alertBootBox('Verifique que los datos sean correctos', 4);", true);
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Handles the Click event of the bGenerar control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void bGenerar_Click(object sender, EventArgs e)
        {
            Page.Validate();
            if (Page.IsValid)
            {
                var where = "";
                try
                {
                    _count = 0;
                    if (!ddlReporte.SelectedValue.Equals("0"))
                    {
                        if (!string.IsNullOrEmpty(tbFechaInicial.Text) && !string.IsNullOrEmpty(tbFechaFinal.Text))
                        {
                            if (!Convert.ToDateTime(tbFechaInicial.Text).ToString("yyyyMMdd").Equals("00010101") && !Convert.ToDateTime(tbFechaFinal.Text).ToString("yyyyMMdd").Equals("00010101"))
                            {
                                if (Convert.ToDateTime(tbFechaInicial.Text) <= Convert.ToDateTime(tbFechaFinal.Text))
                                {
                                    _fecha         = Convert.ToDateTime(tbFechaInicial.Text).ToString("yyyyMMdd");
                                    _fechanom      = Convert.ToDateTime(tbFechaFinal.Text).ToString("yyyyMMdd");
                                    _fechacreacion = Localization.Now.ToString("yyyyMMddHHmmss");
                                    where         += " CONVERT(VARCHAR(MAX),g.FECHA,112) >= " + Convert.ToDateTime(tbFechaInicial.Text).ToString("yyyyMMdd") + " AND CONVERT(VARCHAR(MAX),g.FECHA,112) <=" + Convert.ToDateTime(tbFechaFinal.Text).ToString("yyyyMMdd") + " AND ";

                                    if (ddlPtoEmi.SelectedValue != "0")
                                    {
                                        where += " g.serie='" + ddlPtoEmi.SelectedItem.Text + "' AND ";
                                    }
                                    if (ddlEstado.SelectedValue != "0")
                                    {
                                        where += " (g.tipo +g.estado) =  '" + ddlEstado.SelectedValue + "' AND ";
                                    }
                                    if (ddlTipDoc.SelectedValue != "0")
                                    {
                                        where += " g.codDoc='" + ddlTipDoc.SelectedValue + "' AND ";
                                    }
                                    if (ddlEmisor.SelectedValue != "0" && ddlEmisor.SelectedValue != "Todos")
                                    {
                                        where += " cem.RFCEMI='" + ddlEmisor.SelectedItem.Text + "' AND ";
                                    }
                                    if (ddlReceptor.SelectedValue != "0" && ddlReceptor.SelectedValue != "Todos")
                                    {
                                        where += " cr.RFCREC='" + ddlReceptor.SelectedItem.Text + "' AND ";
                                    }
                                    where = where.Substring(0, where.Length - 5);
                                    if (!ddlReporte.SelectedValue.Equals("Contabilidad"))
                                    {
                                        _virtualDir = @"docs\" + (Session["IDENTEMI"] != null ? Session["IDENTEMI"].ToString() : "CORE") + _fechacreacion + "_" + ddlReporte.SelectedValue + ".xlsx";
                                    }
                                    else
                                    {
                                        if (Session["IDENTEMI"].ToString() == "HRP880129QX5")
                                        {
                                            _virtualDir = @"docs\Conta\";
                                            //   _virtualDirConta = @"docs\" + "U" + new string((Session["IDENTEMI"] != null ? Session["IDENTEMI"].ToString() : "CORE").Take(3).ToArray()) + _fechacreacion + "_" + ddlReporte.SelectedValue + ".zip";
                                            _sesion = new string((Session["IDENTEMI"] != null ? Session["IDENTEMI"].ToString() : "CORE").Take(3).ToArray());
                                        }
                                        else
                                        {
                                            _virtualDir = @"docs\Conta\" + "U" + new string((Session["IDENTEMI"] != null ? Session["IDENTEMI"].ToString() : "CORE").Take(3).ToArray()) + _fecha + ".txt";
                                        }
                                    }
                                    _dir = AppDomain.CurrentDomain.BaseDirectory + @"reportes\" + _virtualDir;
                                    Directory.CreateDirectory(Path.GetDirectoryName(_dir));
                                    var periodo  = tbFechaInicial.Text + " - " + tbFechaFinal.Text;
                                    var informes = new Informes(_dir, _db.CadenaConexion, periodo, Session["IDGIRO"].ToString());
                                    if (ddlReporte.SelectedValue.Equals("General"))
                                    {
                                        _db.Conectar();
                                        _db.CrearComando(@"SELECT  count(g.idComprobante)
                                            FROM            Dat_GENERAL g INNER JOIN
                                                Cat_Emisor cem ON g.id_Emisor = cem.IDEEMI LEFT OUTER JOIN
                                                Cat_RECEPTOR cr ON g.id_Receptor = cr.IDEREC
                                            WHERE " + where);

                                        var dr = _db.EjecutarConsulta();
                                        if (dr.Read())
                                        {
                                            _count = Convert.ToInt32(dr[0]);
                                        }
                                        _db.Desconectar();
                                        if (_count > 0)
                                        {
                                            if (informes.General(where, Session["IDENTEMI"].ToString()))
                                            {
                                                var js = "downloadFile('" + _virtualDir.Replace(@"\", "/") + "');";
                                                ScriptManager.RegisterStartupScript(this, GetType(), "downloadViaJS", js, true);
                                            }
                                            else
                                            {
                                                ScriptManager.RegisterStartupScript(this, GetType(), "alertBootBox", "alertBootBox('" + informes.Ex.Message + "', 4);", true);
                                            }
                                        }
                                        else
                                        {
                                            ScriptManager.RegisterStartupScript(this, GetType(), "alertBootBox", "alertBootBox('No hay registros de acuerdo a los criterios de busqueda', 4);", true);
                                        }
                                    }
                                    else if (ddlReporte.SelectedValue.Equals("Email"))
                                    {
                                        _db.Conectar();
                                        _db.CrearComando(@"SELECT  COUNT(g.idComprobante)
                                              FROM   Cat_emailEnvio mail inner join
			                                       Dat_general g on g.idComprobante = mail.id_general INNER JOIN
                                                   Cat_Emisor cem ON g.id_Emisor = cem.IDEEMI LEFT OUTER JOIN
			                                       Cat_RECEPTOR cr ON cr.IDEREC = g.id_Receptor
                                             WHERE " + where);
                                        var dr = _db.EjecutarConsulta();
                                        if (dr.Read())
                                        {
                                            _count = Convert.ToInt32(dr[0]);
                                        }
                                        _db.Desconectar();
                                        if (_count > 0)
                                        {
                                            if (informes.Mail(where, Session["IDENTEMI"].ToString()))
                                            {
                                                var js = "downloadFile('" + _virtualDir.Replace(@"\", "/") + "');";
                                                ScriptManager.RegisterStartupScript(this, GetType(), "downloadViaJS", js, true);
                                            }
                                            else
                                            {
                                                ScriptManager.RegisterStartupScript(this, GetType(), "alertBootBox", "alertBootBox('" + informes.Ex.Message + "', 4);", true);
                                            }
                                        }
                                        else
                                        {
                                            ScriptManager.RegisterStartupScript(this, GetType(), "alertBootBox", "alertBootBox('No hay registros de acuerdo a los criterios de busqueda', 4);", true);
                                        }
                                    }
                                    else if (ddlReporte.SelectedValue.Equals("Conceptos"))
                                    {
                                        _db.Conectar();
                                        _db.CrearComando(@"SELECT  COUNT(g.idComprobante)
                                              FROM   Dat_Detalles dd inner join
			                                       Dat_general g on g.idComprobante = dd.id_Comprobante INNER JOIN
                                                   Cat_Emisor cem ON g.id_Emisor = cem.IDEEMI LEFT OUTER JOIN
			                                       Cat_RECEPTOR cr ON cr.IDEREC = g.id_Receptor
                                             WHERE " + where);
                                        var dr = _db.EjecutarConsulta();
                                        if (dr.Read())
                                        {
                                            _count = Convert.ToInt32(dr[0]);
                                        }
                                        _db.Desconectar();
                                        if (_count > 0)
                                        {
                                            if (informes.Conceptos(where, Session["IDENTEMI"].ToString()))
                                            {
                                                var js = "downloadFile('" + _virtualDir.Replace(@"\", "/") + "');";
                                                ScriptManager.RegisterStartupScript(this, GetType(), "downloadViaJS", js, true);
                                            }
                                            else
                                            {
                                                ScriptManager.RegisterStartupScript(this, GetType(), "alertBootBox", "alertBootBox('" + informes.Ex.Message + "', 4);", true);
                                            }
                                        }
                                        else
                                        {
                                            ScriptManager.RegisterStartupScript(this, GetType(), "alertBootBox", "alertBootBox('No hay registros de acuerdo a los criterios de busqueda', 4);", true);
                                        }
                                    }
                                    else if (ddlReporte.SelectedValue.Equals("Contabilidad"))
                                    {
                                        if (Session["IDENTEMI"].ToString() == "HRP880129QX5")
                                        {
                                            //obtener rango

                                            var whereC = "";
                                            if (ddlPtoEmi.SelectedValue != "0")
                                            {
                                                whereC += " g.serie='" + ddlPtoEmi.SelectedItem.Text + "' AND ";
                                            }
                                            if (ddlEstado.SelectedValue != "0")
                                            {
                                                whereC += " (g.tipo +g.estado) =  '" + ddlEstado.SelectedValue + "' AND ";
                                            }
                                            if (ddlTipDoc.SelectedValue != "0")
                                            {
                                                whereC += " g.codDoc='" + ddlTipDoc.SelectedValue + "' AND ";
                                            }
                                            if (ddlEmisor.SelectedValue != "0")
                                            {
                                                whereC += " cem.RFCEMI='" + ddlEmisor.SelectedItem.Text + "' AND ";
                                            }
                                            if (ddlReceptor.SelectedValue != "0")
                                            {
                                                whereC += " cr.RFCREC='" + ddlReceptor.SelectedItem.Text + "' AND ";
                                            }

                                            var yearS    = Convert.ToDateTime(tbFechaInicial.Text).ToString("yyyy");
                                            var yearE    = Convert.ToDateTime(tbFechaInicial.Text).ToString("yyyy");
                                            var monthS   = Convert.ToDateTime(tbFechaInicial.Text).ToString("MM");
                                            var monthE   = Convert.ToDateTime(tbFechaInicial.Text).ToString("MM");
                                            int dayStart = Convert.ToInt32(Convert.ToDateTime(tbFechaInicial.Text).ToString("dd"));
                                            int dayEnd   = Convert.ToInt32(Convert.ToDateTime(tbFechaFinal.Text).ToString("dd"));
                                            var j        = dayStart - 1;
                                            for (var i = dayStart; i <= dayEnd; i++)
                                            {
                                                where = "";
                                                j    += 1;
                                                var dateS = yearS + "/" + monthS + "/" + j;
                                                var dateE = yearE + "/" + monthE + "/" + i;
                                                where = " CONVERT(VARCHAR(MAX),g.FECHA,112) >= " + Convert.ToDateTime(dateS).ToString("yyyyMMdd") + " AND CONVERT(VARCHAR(MAX),g.FECHA,112) <=" + Convert.ToDateTime(dateE).ToString("yyyyMMdd") + " AND " + whereC;
                                                where = where.Substring(0, where.Length - 5);
                                                //fin repCon
                                                _db.Conectar();
                                                _db.CrearComando(@"SELECT  COUNT(g.idComprobante)
                                              FROM   Dat_Detalles inner join
			                                       Dat_general g on g.idComprobante = Dat_Detalles.id_Comprobante INNER JOIN
                                                   Cat_Emisor cem ON g.id_Emisor = cem.IDEEMI LEFT OUTER JOIN
			                                       Cat_RECEPTOR cr ON cr.IDEREC = g.id_Receptor
                                             WHERE " + where);
                                                var dr = _db.EjecutarConsulta();
                                                if (dr.Read())
                                                {
                                                    _count = Convert.ToInt32(dr[0]);
                                                }
                                                _db.Desconectar();


                                                if (_count > 0)
                                                {
                                                    if (informes.ContabilidadC(where, _sesion))
                                                    {
                                                    }
                                                    else
                                                    {
                                                        ScriptManager.RegisterStartupScript(this, GetType(), "alertBootBox", "alertBootBox('" + informes.Ex.Message + "', 4);", true);
                                                    }
                                                }
                                                else
                                                {
                                                }
                                            }//for reporte por dias
                                            Zip_Download(_dir);
                                        }
                                        else
                                        {
                                            _db.Conectar();
                                            _db.CrearComando(@"SELECT  COUNT(g.idComprobante)
                                              FROM   Dat_Detalles inner join
			                                       Dat_general g on g.idComprobante = Dat_Detalles.id_Comprobante INNER JOIN
                                                   Cat_Emisor cem ON g.id_Emisor = cem.IDEEMI LEFT OUTER JOIN
			                                       Cat_RECEPTOR cr ON cr.IDEREC = g.id_Receptor
                                             WHERE " + where);
                                            var dr = _db.EjecutarConsulta();
                                            if (dr.Read())
                                            {
                                                _count = Convert.ToInt32(dr[0]);
                                            }
                                            _db.Desconectar();


                                            if (_count > 0)
                                            {
                                                if (informes.Contabilidad(where, "", Session["IDENTEMI"].ToString()))
                                                {
                                                    var js = "downloadFile('" + _virtualDir.Replace(@"\", "/") + "');";
                                                    ScriptManager.RegisterStartupScript(this, GetType(), "downloadViaJS", js, true);
                                                }
                                                else
                                                {
                                                    ScriptManager.RegisterStartupScript(this, GetType(), "alertBootBox", "alertBootBox('" + informes.Ex.Message + "', 4);", true);
                                                }
                                            }
                                            else
                                            {
                                                ScriptManager.RegisterStartupScript(this, GetType(), "alertBootBox", "alertBootBox('No hay registros de acuerdo a los criterios de busqueda', 4);", true);
                                            }
                                        }
                                    }
                                    else if (ddlReporte.SelectedValue.Equals("Tickets"))
                                    {
                                        var date      = Convert.ToDateTime(tbFechaInicial.Text);
                                        var year      = date.ToString("yyyy");
                                        var month     = date.ToString("MM");
                                        var serie     = "";
                                        var rfcEmisor = "";
                                        var count     = -1;
                                        if (!ddlPtoEmi.SelectedValue.Equals("0"))
                                        {
                                            serie = ddlPtoEmi.SelectedItem.Text;
                                        }
                                        if (!ddlEmisor.SelectedValue.Equals("0"))
                                        {
                                            rfcEmisor = ddlEmisor.SelectedItem.Text;
                                        }
                                        var Reptikets = new FacturaGlobalWeb.FacturaGlobalWeb();
                                        var RutBase   = AppDomain.CurrentDomain.BaseDirectory;
                                        Reptikets.TicketsAsync(where, Session["CfdiVersion"].ToString(), month, year, serie, rfcEmisor, _dir, RutBase, Session["IDENTEMI"].ToString());
                                        (Master as SiteMaster).MostrarAlerta(this, "El reporte se esta generando", 4);
                                        gvRepTickets.DataBind();
                                        //if (informes.Tickets(where, Session["CfdiVersion"].ToString(), month, year, serie, rfcEmisor, out count))
                                        //{
                                        //    if (count <= 0)
                                        //    {
                                        //        ScriptManager.RegisterStartupScript(this, GetType(), "alertBootBox", "alertBootBox('No hay registros de acuerdo a los criterios de busqueda', 4);", true);
                                        //        return;
                                        //    }
                                        //    var js = "downloadFile('" + _virtualDir.Replace(@"\", "/") + "');";
                                        //    ScriptManager.RegisterStartupScript(this, GetType(), "downloadViaJS", js, true);
                                        //    Response.Redirect("~/download.aspx?file=" + "reportes/" + _virtualDir.Replace(@"\", "/"));
                                        //}
                                        //else
                                        //{
                                        //    ScriptManager.RegisterStartupScript(this, GetType(), "alertBootBox", "alertBootBox('" + informes.Ex.Message + "', 4);", true);
                                        //}
                                    }
                                }
                                else
                                {
                                    ScriptManager.RegisterStartupScript(this, GetType(), "alertBootBox", "alertBootBox('Selecciona fecha inicial y fecha final', 4);", true);
                                }
                            }
                            else
                            {
                                ScriptManager.RegisterStartupScript(this, GetType(), "alertBootBox", "alertBootBox('Tienes que seleccionar ambas fechas', 4);", true);
                            }
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, GetType(), "alertBootBox", "alertBootBox('Tienes que seleccionar ambas fechas', 4);", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "alertBootBox", "alertBootBox('Tienes que seleccionar un tipo de Reporte', 4);", true);
                    }
                }
                catch (Exception ea)
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "alertBootBox", "alertBootBox('" + ea.Message + "', 4);", true);
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "alertBootBox", "alertBootBox('Verifique que los datos sean correctos', 4);", true);
            }
        }
partial         void InformesSet_Inserted(Informes entity)
        {
            var myHub = GlobalHost.ConnectionManager.GetHubContext<Chat>();

            var result = myHub.Clients.All.CustomersInserted("AAA","NNNNNN");
        }