Exemplo n.º 1
0
        public void BuscarCuadre(DateTime Fecha)
        {
            Abono  a         = new Abono();
            int    Id        = Convert.ToInt32(Session["UsuarioId"]); //ESTE USUARIO ES EL ADMINISTRATIVO
            string Campo     = "";
            string Tabla     = "";
            string Condicion = "";


            DataTable dt        = new DataTable();
            DataTable dtCliente = new DataTable();

            DateTime fecha     = Fecha;
            string   FechaHoy  = fecha.Year + "/" + fecha.Month + "/" + fecha.Day + " 00:0:00.000 ";
            string   ConvFecha = "Convert(VARCHAR(10),C.Fecha,103) as Fecha";

            Campo     = " C.CuadreId, Uc.Nombre,C.Total, C.UsuarioCoId," + ConvFecha;
            Tabla     = " from Cuadre as C inner join UsuarioCo as Uc on Uc.UsuarioCoId = C.UsuarioCoId inner join Usuario as U on U.UsuarioId = Uc.UsuarioId";
            Condicion = " where C.Fecha = '" + FechaHoy + "' and U.UsuarioId = " + Id;

            dt = Utilitario.Lista(Campo, Tabla, Condicion);

            if (dt.Rows.Count > 0)
            {
                GridPrestamo.DataSource = dt;
                GridPrestamo.DataBind();
            }
            else
            {
                Utilitario.ShowToastr(this, "No existen registro conforme a esta fecha", "Mensaje", "error");

                GridPrestamo.DataSource = null;
                GridPrestamo.DataBind();
            }
        }
Exemplo n.º 2
0
        public void Consulta()
        {
            DataTable dt  = new DataTable();
            DataTable dt2 = new DataTable();

            DateTime Fe = DateTime.Now;
            int      id = 0;

            if (Convert.ToInt32(Session["UsuarioId"]) > 0)
            {
                id = Convert.ToInt32(Session["UsuarioId"]);
            }
            else
            {
                id = Utilitario.ObtenerIdUsuarioAdm(Convert.ToInt32(Session["UsuarioCoId"]));
            }


            string Campo     = " TOP 5 P.PrestamoId,C.Nombre,P.Total ";
            string Tabla     = " from Prestamo as P inner join Cliente as C on C.ClienteId = P.ClienteId inner join UsuarioCo as Uc on Uc.UsuarioCoId = P.UsuarioCoId inner join Usuario as U on U.UsuarioId = Uc.UsuarioId";
            string Condicion = " where U.UsuarioId = " + id + " Order by (P.FechaInicio) ";

            string Campo2     = " Sum(P.Total) as Total ";
            string Condicion2 = " where U.UsuarioId = " + id;
            string Condicion3 = " where P.FechaInicio = '" + Fe.Year + "/" + Fe.Month + "/" + Fe.Day + " 00:0:00.000' AND U.UsuarioId = " + id;

            try
            {
                dt = Utilitario.Lista(Campo, Tabla, Condicion);

                if (dt.Rows.Count > 0)
                {
                    GridPrestamo.DataSource = dt;
                    GridPrestamo.DataBind();
                }
                else
                {
                    divInfo.Visible = true;
                }

                ObtenerDatos(Campo2, "Total", Tabla, Condicion2, dt, tbxTotalPrestado);
                ObtenerDatos(Campo, "Total", Tabla, Condicion3, dt, tbxPrestadoDiario);

                string Tabla2     = " from Abono as A inner join Cliente as C on C.ClienteId = A.ClienteId inner join UsuarioCo as Uc on Uc.UsuarioCoId = A.UsuarioCoId inner join Usuario as U on U.UsuarioId = Uc.UsuarioId";
                string Condicion4 = " where A.Fecha = '" + Fe.Year + "/" + Fe.Month + "/" + Fe.Day + " 00:0:00.000' AND U.UsuarioId = " + id;
                string Campo3     = " Sum(A.Cantidad) as Cantidad ";

                ObtenerDatos(Campo3, "Cantidad", Tabla2, Condicion4, dt, tbxCobradoHoy);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 3
0
        public DataTable BuscarPrestamo()
        {
            //HAY QUE PONER EL PROGRAMA A QUE DE VARIOS DIAS DE PRORROGA ANTES DE ACUMULAR MORA

            string replace = "replace(replace(replace(P.Estado,2,'Abono'),3,'Mora'),1,'OK') as 'Estado' ";

            btnDescargar.Visible    = false;
            GridPrestamo.DataSource = null;
            GridPrestamo.DataBind();

            string    campo      = "P.PrestamoId,C.Nombre,C.ClienteId ,P.CantidadCuota,P.Total,U.Latitude,U.Descripcion as Lugar ,U.Descripcion,U.Longitude, " + replace;
            string    tabla      = " from Prestamo AS P inner join UsuarioCo as Uc on Uc.UsuarioCoId = P.UsuarioCoId inner join Usuario as Ua on Ua.UsuarioId = Uc.UsuarioId inner join Cliente as C on C.ClienteId = P.ClienteId inner join Ubicacion as U on U.ClienteId = C.ClienteId";
            DataTable dtAuxiliar = new DataTable();

            //AQUI PONER TANTO COMO EL ADMINISTRATIVO Y EL COLABORADOR PUEDA CONSULTAR
            int UsuarioId = 0;

            if (Convert.ToInt32(Session["UsuarioId"]) > 0)
            {
                UsuarioId = Convert.ToInt32(Session["UsuarioId"]);
            }
            else
            {
                UsuarioId = Utilitario.ObtenerIdUsuarioAdm(Convert.ToInt32(Session["UsuarioCoId"]));
            }


            string condicion = "";

            if (dropCliente.SelectedValue == "0")
            {
                condicion = " where Ua.UsuarioId = " + UsuarioId + " and P.Estado =2 OR P.Estado =3 ";
            }
            else if (dropCliente.SelectedValue == "1")
            {
                condicion = " where P.Estado = 2 and Ua.UsuarioId = " + UsuarioId;
            }
            else if (dropCliente.SelectedValue == "2")
            {
                condicion = " where P.Estado = 3 and Ua.UsuarioId = " + UsuarioId;
            }
            else if (dropCliente.SelectedValue == "3")
            {
                condicion = " where C.Nombre like '" + tbxBuscar.Text + "%' and Ua.UsuarioId  = " + UsuarioId;
            }
            else if (dropCliente.SelectedValue == "4")
            {
                condicion = " where C.Cedula = " + tbxBuscar.Text + " and Ua.UsuarioId  = " + UsuarioId;
            }
            else if (dropCliente.SelectedValue == "5")
            {
                condicion = " where C.Telefono =" + tbxBuscar.Text + " and Ua.UsuarioId = " + UsuarioId;
            }
            else if (dropCliente.SelectedValue == "6")
            {
                condicion = " where P.PrestamoId =" + tbxBuscar.Text + "and Ua.UsuarioId  = " + UsuarioId;
            }

            DataTable dt = new DataTable();

            dt = Utilitario.Lista(campo, tabla, condicion);

            if (dt.Rows.Count > 0)
            {
                GridPrestamo.DataSource = dt;
                GridPrestamo.DataBind();
                btnDescargar.Visible = true;
            }
            else
            {
                btnDescargar.Visible    = false;
                GridPrestamo.DataSource = null;
                GridPrestamo.DataBind();
                Utilitario.ShowToastr(this, "NO TIENE COBROS PENDIENTES", "Mensaje", "error");
            }

            return(dt);
        }
Exemplo n.º 4
0
        public void Buscar()
        {
            string ConvFechaTermino = "";
            string ConvFechaInicio  = "";
            string replace          = "";
            string campo            = "";
            string tabla            = "";



            ConvFechaTermino = "Convert(VARCHAR(10),P.FechaTermino,103) as FechaTermino";
            ConvFechaInicio  = "Convert(VARCHAR(10),P.FechaInicio,103) as FechaInicio";
            replace          = "replace(replace(replace(replace(P.Estado,2,'Abono'),3,'Mora'),4,'Saldado'),1,'Pasivo')as 'Estado' ";
            campo            = " P.PrestamoId,C.Nombre," + ConvFechaInicio + "," + ConvFechaTermino + ",P.Taza,P.Total,P.Interes," + replace + ",P.CantidadCuota,Uc.Nombre as NombreUsuario ";
            tabla            = " from Prestamo as P inner join Cliente as C on C.ClienteId = P.ClienteId inner join UsuarioCo as Uc on Uc.UsuarioCoId = P.UsuarioCoId inner join Usuario as U on U.UsuarioId = Uc.UsuarioId";


            string condicion = "";


            if (dropCliente.SelectedValue == "0")
            {
                DateTime fecha    = DateTime.Now;
                string   FechaHoy = fecha.Year + "/" + fecha.Month + "/" + fecha.Day + " 00:0:00.000 ";

                condicion = " where P.FechaInicio ='" + FechaHoy + "' and U.UsuarioId =" + Session["UsuarioId"];
            }
            else if (dropCliente.SelectedValue == "1")
            {
                condicion = " where C.Nombre like '" + tbxBuscar.Text + "%' and U.UsuarioId =" + Session["UsuarioId"];
            }
            else if (dropCliente.SelectedValue == "2")
            {
                condicion = " where C.Cedula =" + tbxBuscar.Text + " and U.UsuarioId = " + Session["UsuarioId"];
            }
            else if (dropCliente.SelectedValue == "3")
            {
                condicion = " where C.Telefono =" + tbxBuscar.Text + " and U.UsuarioId = " + Session["UsuarioId"];;
            }
            else if (dropCliente.SelectedValue == "4")
            {
                condicion = " where P.ClienteId =" + tbxBuscar.Text + " and U.UsuarioId = " + Session["UsuarioId"];;
            }
            else if (dropCliente.SelectedValue == "5")
            {
                condicion      = " where U.UsuarioId = " + Session["UsuarioId"];
                tbxBuscar.Text = string.Empty;
            }

            DataTable dt = new DataTable();

            dt = Utilitario.Lista(campo, tabla, condicion);

            if (dt.Rows.Count > 0)
            {
                GridPrestamo.DataSource = dt;
                GridPrestamo.DataBind();
            }
            else
            {
                Utilitario.ShowToastr(this, "NO SE ENCONTRARON RESULTADO", "Mensaje", "error");
            }
        }