Пример #1
0
        MessageInstance <Dominio.Mensagens.TelaPasswords> IEGALI_PASSWORDS.GetEgaliPasswordsByIdEgaliPasswordsHistory(int ID)
        {
            var msg = new MessageInstance <Dominio.Mensagens.TelaPasswords>();

            try
            {
                using (var context = new HostelEntities())
                {
                    msg.Instance = (from ep in context.EGALI_PASSWORDS
                                    join eph in context.EGALI_PASSWORDS_HISTORY on ep.ID equals eph.ID_EGALI_PASSWORDS
                                    where eph.ID == ID
                                    select new Dominio.Mensagens.TelaPasswords()
                    {
                        ID = ep.ID,
                        ID_EGALI_PASSWORDS = eph.ID_EGALI_PASSWORDS,
                        Item = ep.Item,
                        Login = ep.Login,
                        Password = eph.Password
                    }).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                msg.Exception = ex;
            }
            return(msg);
        }
Пример #2
0
        MessageInstance <Dominio.Mensagens.TelaTotalTransaction> ITOTAL_TRANSACTIONS.GetTotalTransactionByID(int ID)
        {
            var msg = new MessageInstance <Dominio.Mensagens.TelaTotalTransaction>();

            try
            {
                using (var context = new HostelEntities())
                {
                    msg.Instance = (from t in context.Total_Transactions
                                    join c in context.Calcs on t.ID_Calc equals c.ID into cLeft
                                    join lt in context.Total_Transactions on t.ID_Last_Transaction equals lt.ID into ltLeft
                                    from subC in cLeft.DefaultIfEmpty()
                                    from subLT in ltLeft.DefaultIfEmpty()
                                    where t.ID == ID
                                    select new TelaTotalTransaction
                    {
                        ID = ID,
                        TotalTransactions = t.TotalTransactions.Value,
                        TotalFinal = t.TotalFinal.Value,
                        DifferenceFinalCalc = t.DifferenceFinalCalc.HasValue ? t.DifferenceFinalCalc.Value : 0,
                        DT_Reg = t.DT_Reg.Value,
                        LogLogin = t.LogLogin,
                        IDLastTotalCalc = (subC != null && subC.ID > 0 ? subC.ID : 0),
                        TotalCalc = (subC != null && subC.Total > 0 ? subC.Total : 0),
                        IDLastTotalCashier = (subLT != null && subLT.ID > 0 ? subLT.ID : 0),
                        LastTotalCashier = (subLT != null && subLT.TotalFinal.HasValue ? subLT.TotalFinal.Value : t.Last_Cashier_Total.HasValue ? t.Last_Cashier_Total.Value : 0)
                    }).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                msg.Exception = ex;
            }
            return(msg);
        }
Пример #3
0
        MessageInstance <Dominio.Entidades.Calc> ITRANSACTIONS.GetTotalToCalc()
        {
            var msg = new MessageInstance <Dominio.Entidades.Calc>();

            try
            {
                using (var contexto = new HostelEntities())
                {
                    List <int> idsCalcType = (from a in contexto.Calc_Type
                                              select a.ID).ToList();

                    double total = 0;
                    for (int i = 0; i < idsCalcType.Count; i++)
                    {
                        total += (from a in contexto.Money_Count
                                  orderby a.DT_Reg descending
                                  where a.ID_Calc_Type == idsCalcType[i]
                                  select a.ID_Calc_Type).FirstOrDefault();
                    }
                }
            }
            catch (Exception ex)
            {
                msg.Exception = ex;
            }
            return(msg);
        }
Пример #4
0
        MessageInstance <Dominio.Entidades.Total_Transactions> ITOTAL_TRANSACTIONS.GetLastTotal_Card()
        {
            var msg = new MessageInstance <Dominio.Entidades.Total_Transactions>();

            try
            {
                using (var contexto = new HostelEntities())
                {
                    DateTime dtDayMonthYearReference = DateTime.UtcNow;
                    if (dtDayMonthYearReference.Hour >= 0 && dtDayMonthYearReference.Hour <= 5)
                    {
                        dtDayMonthYearReference = dtDayMonthYearReference.AddDays(-1);
                    }

                    var query = (from a in contexto.Total_Transactions
                                 where a.ID_Report_Type == (int)TabReport_Type.Card &&
                                 dtDayMonthYearReference.Date == a.DayMonthYearReference
                                 orderby a.ID descending
                                 select a).FirstOrDefault();

                    msg.Instance = query;
                }
            }
            catch (Exception ex)
            {
                msg.Exception = ex;
            }
            return(msg);
        }
Пример #5
0
        MessageCollection <GridEgaliPasswords> IEGALI_PASSWORDS.GetEgaliPasswordsByFilter(EgaliPasswords filtroPesquisa)
        {
            var msg = new MessageCollection <Dominio.Mensagens.GridEgaliPasswords>();

            try
            {
                using (var context = new HostelEntities())
                {
                    int idEgaliPasswords = (from eph in context.EGALI_PASSWORDS_HISTORY where eph.ID == filtroPesquisa.ID select eph.ID_EGALI_PASSWORDS).FirstOrDefault();


                    var query = (from ep in context.EGALI_PASSWORDS
                                 join eph in context.EGALI_PASSWORDS_HISTORY on ep.ID equals eph.ID_EGALI_PASSWORDS
                                 where eph.ID_EGALI_PASSWORDS == idEgaliPasswords
                                 select new Dominio.Mensagens.GridEgaliPasswords()
                    {
                        ID = ep.ID,
                        DT_Reg = eph.DT_Reg,
                        LogLogin = eph.LogLogin,
                        Item = ep.Item,
                        Login = ep.Login,
                        Password = eph.Password
                    });

                    query         = query.OrderByDescending(q => q.DT_Reg);
                    msg.Code      = query.Count();
                    msg.Instances = query.ToList();
                }
            }
            catch (Exception ex)
            {
                msg.Exception = ex;
            }
            return(msg);
        }
Пример #6
0
        MessageCollection <GridStock> ISTOCK.GetAllStockControlByFilter(Dominio.Mensagens.Filtro.Stock filtroPesquisa)
        {
            var msg = new MessageCollection <Dominio.Mensagens.GridStock>();

            try
            {
                using (var context = new HostelEntities())
                {
                    var insert = (from s in context.Stocks
                                  join at in context.Action_Type on s.ID_ACTION_TYPE equals at.ID
                                  join pt in context.Product_Type on s.ID_PRODUCT_TYPE equals pt.ID
                                  where s.ID_ACTION_TYPE == 1
                                  orderby s.ID_PRODUCT_TYPE
                                  group s by new { s.ID, s.ID_PRODUCT_TYPE, s.AMOUNT } into g
                                  select new
                    {
                        ID_STOCK = g.Key.ID,
                        ID_PRODUCT_TYPE = g.Key.ID_PRODUCT_TYPE,
                        Amount = g.Sum(s => s.AMOUNT)
                    }).ToList();

                    var sold = (from s in context.Stocks
                                join at in context.Action_Type on s.ID_ACTION_TYPE equals at.ID
                                join pt in context.Product_Type on s.ID_PRODUCT_TYPE equals pt.ID
                                where s.ID_ACTION_TYPE == 2
                                orderby s.ID_PRODUCT_TYPE
                                group s by new { s.ID, s.ID_PRODUCT_TYPE, s.AMOUNT } into g
                                select new
                    {
                        ID_STOCK = g.Key.ID,
                        ID_PRODUCT_TYPE = g.Key.ID_PRODUCT_TYPE,
                        Amount = g.Sum(s => s.AMOUNT)
                    }).ToList();


                    var query = new List <Dominio.Mensagens.GridStock>();
                    foreach (var item in insert)
                    {
                        var msgGridStock = new Dominio.Mensagens.GridStock();
                        msgGridStock.Description = item.ID_PRODUCT_TYPE.ToString();
                        msgGridStock.Amount      = item.Amount - sold.Where(w => w.ID_PRODUCT_TYPE == item.ID_PRODUCT_TYPE).Sum(s => s.Amount);
                        query.Add(msgGridStock);
                    }

                    //Filtros de Pesquisa
                    //if (!string.IsNullOrEmpty(filtroPesquisa.user))
                    //    query = query.Where(q => q.LogLogin.Trim().ToUpper().Contains(filtroPesquisa.user.Trim().ToUpper()));
                    msg.Instances = query.Skip(filtroPesquisa.iDisplayStart).Take(filtroPesquisa.iDisplayLength).ToList();
                    msg.Code      = query.Count();
                }
            }
            catch (Exception ex)
            {
                msg.Exception = ex;
            }
            return(msg);
        }
Пример #7
0
        MessageCollection <GridMoney_Count> IMONEY_COUNT.GetMoney_CountByID_Calc(int ID_Calc)
        {
            var msg = new MessageCollection <Dominio.Mensagens.GridMoney_Count>();

            try
            {
                using (var context = new HostelEntities())
                {
                    ////Não pode ser feito o .ToList nesse momento, a query SQL esta esta sendo montada de acordo com os filtros
                    var queryCalc = (from mc in context.Calcs
                                     where mc.ID == ID_Calc
                                     select mc).FirstOrDefault();

                    List <int> ids = new List <int>();
                    ids.Add(queryCalc.ID_Money_Count.HasValue ? queryCalc.ID_Money_Count.Value : 0);
                    ids.Add(queryCalc.ID_Money_Count2.HasValue ? queryCalc.ID_Money_Count2.Value : 0);
                    ids.Add(queryCalc.ID_Money_Count3.HasValue ? queryCalc.ID_Money_Count3.Value : 0);

                    msg.Instances = (from c in context.Money_Count
                                     where ids.Contains(c.ID)
                                     orderby c.ID_Calc_Type
                                     select new Dominio.Mensagens.GridMoney_Count()
                    {
                        IDMoney_Count = c.ID,
                        IDCalc_Type = c.ID_Calc_Type,
                        Qnt_1_Cent = c.Qnt_1_Cent,
                        Qnt_2_Cents = c.Qnt_2_Cents,
                        Qnt_5_Cents = c.Qnt_5_Cents,
                        Qnt_10_Cents = c.Qnt_10_Cents,
                        Qnt_20_Cents = c.Qnt_20_Cents,
                        Qnt_50_Cents = c.Qnt_50_Cents,
                        Qnt_1_Euro = c.Qnt_1_Euro,
                        Qnt_2_Euros = c.Qnt_2_Euros,
                        Qnt_5_Euros = c.Qnt_5_Euros,
                        Qnt_10_Euros = c.Qnt_10_Euros,
                        Qnt_20_Euros = c.Qnt_20_Euros,
                        Qnt_50_Euros = c.Qnt_50_Euros,
                        Qnt_100_Euros = c.Qnt_100_Euros,
                        Qnt_200_Euros = c.Qnt_200_Euros,
                        Qnt_500_Euros = c.Qnt_500_Euros,
                        TotalMoney_Count = c.Total,
                        DT_Reg = c.DT_Reg,
                    }).ToList();
                }
            }
            catch (Exception ex)
            {
                msg.Exception = ex;
            }
            return(msg);
        }
Пример #8
0
        MessageCollection <GridEgaliPasswords> IEGALI_PASSWORDS.GetAllEgaliPasswordsByFilter(EgaliPasswords filtroPesquisa)
        {
            var msg = new MessageCollection <Dominio.Mensagens.GridEgaliPasswords>();

            try
            {
                using (var context = new HostelEntities())
                {
                    var subquery = from eph in context.EGALI_PASSWORDS_HISTORY
                                   group eph by eph.ID_EGALI_PASSWORDS into g
                                   select new
                    {
                        ID_EGALI_PASSWORDS = g.Key,
                        DT_Reg             = g.Max(a => a.DT_Reg)
                    };

                    var query = from ep in context.EGALI_PASSWORDS
                                join eph in context.EGALI_PASSWORDS_HISTORY on ep.ID equals eph.ID_EGALI_PASSWORDS
                                join s in subquery on eph.DT_Reg equals s.DT_Reg
                                where !ep.DT_Delete.HasValue
                                select new Dominio.Mensagens.GridEgaliPasswords()
                    {
                        ID       = eph.ID,
                        DT_Reg   = eph.DT_Reg,
                        LogLogin = eph.LogLogin,
                        Item     = ep.Item,
                        Login    = ep.Login,
                        Password = eph.Password
                    };

                    if (!string.IsNullOrEmpty(filtroPesquisa.item))
                    {
                        query = query.Where(q => q.Item.Contains(filtroPesquisa.item));
                    }
                    if (!string.IsNullOrEmpty(filtroPesquisa.login))
                    {
                        query = query.Where(q => q.Login.Contains(filtroPesquisa.login));
                    }

                    query         = query.OrderByDescending(q => q.DT_Reg);
                    msg.Code      = query.Count();
                    msg.Instances = query.ToList();
                }
            }
            catch (Exception ex)
            {
                msg.Exception = ex;
            }
            return(msg);
        }
Пример #9
0
        MessageInstance <Dominio.Entidades.User> IUSER.GetUserById(int ID)
        {
            var msg = new MessageInstance <Dominio.Entidades.User>();

            try
            {
                using (var contexto = new HostelEntities())
                {
                    msg.Instance = (from u in contexto.Users
                                    where u.ID == ID
                                    select u).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                msg.Exception = ex;
            }
            return(msg);
        }
Пример #10
0
        MessageInstance <Dominio.Mensagens.TelaCalc> IMONEY_COUNT.GetMoney_CountDetailsByID(int ID)
        {
            var msg = new MessageInstance <Dominio.Mensagens.TelaCalc>();

            try
            {
                using (var context = new HostelEntities())
                {
                    msg.Instance = (from mc in context.Money_Count
                                    join c in context.Calcs on mc.ID equals c.ID_Money_Count
                                    where mc.ID == ID
                                    select new TelaCalc()
                    {
                        IDCalc_Type = mc.ID_Calc_Type,
                        LogLogin = c.LogLogin,
                        TotalCalc = c.Total,
                        IDMoney_Count = mc.ID,
                        Qnt_1_Cent = mc.Qnt_1_Cent,
                        Qnt_2_Cents = mc.Qnt_2_Cents,
                        Qnt_5_Cents = mc.Qnt_5_Cents,
                        Qnt_10_Cents = mc.Qnt_10_Cents,
                        Qnt_20_Cents = mc.Qnt_20_Cents,
                        Qnt_50_Cents = mc.Qnt_50_Cents,
                        Qnt_1_Euro = mc.Qnt_1_Euro,
                        Qnt_2_Euros = mc.Qnt_2_Euros,
                        Qnt_5_Euros = mc.Qnt_5_Euros,
                        Qnt_10_Euros = mc.Qnt_10_Euros,
                        Qnt_20_Euros = mc.Qnt_20_Euros,
                        Qnt_50_Euros = mc.Qnt_50_Euros,
                        Qnt_100_Euros = mc.Qnt_100_Euros,
                        Qnt_200_Euros = mc.Qnt_200_Euros,
                        Qnt_500_Euros = mc.Qnt_500_Euros,
                        TotalMoney_Count = mc.Total,
                        DT_Reg = c.DT_reg,
                    }).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                msg.Exception = ex;
            }
            return(msg);
        }
Пример #11
0
        MessageInstance <Dominio.Entidades.LIST> ILISTS.GetTotalLastCalc()
        {
            var msg = new MessageInstance <Dominio.Entidades.LIST>();

            try
            {
                using (var contexto = new HostelEntities())
                {
                    msg.Instance = (from c in contexto.LISTs
                                    orderby c.ID descending
                                    select c).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                msg.Exception = ex;
            }
            return(msg);
        }
Пример #12
0
        MessageInstance <Dominio.Entidades.Stock> ISTOCK.GetStockById(int id)
        {
            var msg = new MessageInstance <Dominio.Entidades.Stock>();

            try
            {
                using (var contexto = new HostelEntities())
                {
                    msg.Instance = (from a in contexto.Stocks
                                    where a.ID == id
                                    select a).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                msg.Exception = ex;
            }
            return(msg);
        }
Пример #13
0
        MessageInstance <Dominio.Entidades.Money_Count> ITRANSACTIONS.GetMoney_CountById(int id)
        {
            var msg = new MessageInstance <Dominio.Entidades.Money_Count>();

            try
            {
                using (var contexto = new HostelEntities())
                {
                    msg.Instance = (from a in contexto.Money_Count
                                    where a.ID == id
                                    select a).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                msg.Exception = ex;
            }
            return(msg);
        }
Пример #14
0
        MessageInstance <Dominio.Entidades.Total_Transactions> ITOTAL_TRANSACTIONS.GetLastTotal_Vagner()
        {
            var msg = new MessageInstance <Dominio.Entidades.Total_Transactions>();

            try
            {
                using (var contexto = new HostelEntities())
                {
                    msg.Instance = (from a in contexto.Total_Transactions
                                    where a.ID_Report_Type == (int)TabReport_Type.Bank
                                    orderby a.ID descending
                                    select a).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                msg.Exception = ex;
            }
            return(msg);
        }
Пример #15
0
        MessageInstance <Dominio.Entidades.User> IUSER.GetUserByUsernamePassword(string username, string password)
        {
            var msg = new MessageInstance <Dominio.Entidades.User>();

            try
            {
                using (var contexto = new HostelEntities())
                {
                    msg.Instance = (from u in contexto.Users
                                    where u.Username == username &&
                                    u.Password == password
                                    select u).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                msg.Exception = ex;
            }
            return(msg);
        }
Пример #16
0
        MessageInstance <Dominio.Entidades.Money_Count> IMONEY_COUNT.GetLastMoney_CountByIdCalcType(int idCalcType)
        {
            var msg = new MessageInstance <Dominio.Entidades.Money_Count>();

            try
            {
                using (var contexto = new HostelEntities())
                {
                    msg.Instance = (from a in contexto.Money_Count
                                    orderby a.DT_Reg descending
                                    where a.ID_Calc_Type == idCalcType
                                    select a).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                msg.Exception = ex;
            }
            return(msg);
        }
Пример #17
0
        MessageInstance <Dominio.Entidades.Money_Count> IMONEY_COUNT.GetMoney_CountEnvelopeByIDCalc(int ID_Calc, int idCalcType)
        {
            var msg = new MessageInstance <Dominio.Entidades.Money_Count>();

            try
            {
                using (var context = new HostelEntities())
                {
                    msg.Instance = (from mc in context.Money_Count
                                    join c in context.Calcs on mc.ID equals c.ID_Money_Count
                                    where c.ID == ID_Calc &&
                                    mc.ID_Calc_Type == idCalcType
                                    select mc).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                msg.Exception = ex;
            }
            return(msg);
        }
Пример #18
0
        MessageCollection <GridTransactions> ITRANSACTIONS.GetAllTransactionsByID_Total_Transactions(Dominio.Mensagens.Filtro.Transactions filtroPesquisa)
        {
            var msg = new MessageCollection <Dominio.Mensagens.GridTransactions>();

            try
            {
                using (var context = new HostelEntities())
                {
                    ////Não pode ser feito o .ToList nesse momento, a query SQL esta esta sendo montada de acordo com os filtros
                    var query = (from c in context.Transactions
                                 join transType in context.Transaction_Type on c.ID_Transaction_Type equals transType.ID
                                 join pt in context.Payment_Type on c.ID_Payment_Type equals pt.ID
                                 join tt in context.Total_Transactions on c.ID_Total_Transactions equals tt.ID
                                 join ct in context.Card_Type on c.ID_Card_Type equals ct.ID into ptLeft
                                 from subCT in ptLeft.DefaultIfEmpty()
                                 where c.ID_Total_Transactions == filtroPesquisa.ID_TOTAL_TRANSACTION
                                 select new Dominio.Mensagens.GridTransactions()
                    {
                        ID = c.ID,
                        Date = c.DT_Reg.ToString(),
                        User = c.LogLogin,
                        Reservation_Number = c.Reservation_Number,
                        Guest_Name = c.GuestName,
                        Transaction_Type = transType.Description,
                        Card_Type = (subCT != null && !string.IsNullOrEmpty(subCT.Description) ? subCT.Description : string.Empty),
                        Payment_Type = pt.Description,
                        Description = c.Description,
                        Total = c.Total,
                        ID_TOTAL_TRANSACTIONS = tt.ID
                    });



                    ////Filtros de Pesquisa
                    //if (filtroPesquisa.ID_TOTAL_TRANSACTION> 0)
                    //query = query.Where(q => q.ID_TOTAL_TRANSACTIONS == 23);

                    //if (filtroPesquisa.ID_Calc_Type > 0)
                    //    query = query.Where(q => q.Calc_Type == (from c in context.Calc_Type where c.ID == filtroPesquisa.ID_Calc_Type select c.Description).FirstOrDefault().ToString());

                    //if (!string.IsNullOrEmpty(filtroPesquisa.dtInicio))
                    //{
                    //    DateTime dtFim = DateTime.Now;
                    //    if (!string.IsNullOrEmpty(filtroPesquisa.dtFim))
                    //        dtFim = Convert.ToDateTime(filtroPesquisa.dtFim);

                    //    query = query.Where(q => (Convert.ToDateTime(q.DT_reg) >= Convert.ToDateTime(filtroPesquisa.dtInicio) && Convert.ToDateTime(q.DT_reg) <= dtFim));
                    //}

                    //ordenação
                    if (filtroPesquisa.sSortDir_0 == "asc")
                    {
                        if (filtroPesquisa.iSortCol_0 == 1)
                        {
                            query = query.OrderByDescending(q => q.Date);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 2)
                        {
                            query = query.OrderByDescending(q => q.User);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 3)
                        {
                            query = query.OrderByDescending(q => q.ID);
                        }
                        else
                        {
                            query = query.OrderByDescending(q => q.Date);
                        }
                    }
                    else if (filtroPesquisa.sSortDir_0 == "desc")
                    {
                        if (filtroPesquisa.iSortCol_0 == 1)
                        {
                            query = query.OrderBy(q => q.Date);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 2)
                        {
                            query = query.OrderBy(q => q.User);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 3)
                        {
                            query = query.OrderBy(q => q.ID);
                        }
                        else
                        {
                            query = query.OrderBy(q => q.Date);
                        }
                    }
                    else
                    {
                        query = query.OrderByDescending(q => q.Date);
                    }

                    query = query.Take(100);

                    ////Extract only current page
                    msg.Instances = query.Skip(filtroPesquisa.iDisplayStart).Take(filtroPesquisa.iDisplayLength).ToList();


                    ////Campo improvisado para gerar o total de paginacao

                    msg.Code = query.Count();//Total de registro com filtros aplicados
                    //Total de registro no banco sem filtro aplicado Deve ser feito uma pesquisa direto na Tabela outra Query Deverrá ser informado em outro campo no grid CONtroller eu coloquei fixo 110 pra teste
                }
            }
            catch (Exception ex)
            {
                msg.Exception = ex;
            }
            return(msg);
        }
Пример #19
0
        MessageCollection <GridTotalTransactionIndex> ITOTAL_TRANSACTIONS.GetAllTotalTransactionsByBank(TotalTransactions filtroPesquisa)
        {
            var msg = new MessageCollection <Dominio.Mensagens.GridTotalTransactionIndex>();

            try
            {
                using (var context = new HostelEntities())
                {
                    var query = (from tt in context.Total_Transactions
                                 join c in context.Calcs on tt.ID_Calc equals c.ID into cLeft
                                 join rt in context.Report_Type on tt.ID_Report_Type equals rt.ID
                                 from subC in cLeft.DefaultIfEmpty()
                                 orderby tt.DT_Reg descending
                                 where filtroPesquisa.ID_REPORT_TYPE == tt.ID_Report_Type
                                 select new Dominio.Mensagens.GridTotalTransactionIndex()
                    {
                        ID = tt.ID,
                        DT_Reg = tt.DT_Reg.Value,
                        LogLogin = tt.LogLogin,
                        TotalTransactions = tt.TotalTransactions.Value,
                        IDLastTotalCalc = (subC != null && subC.ID > 0 ? subC.ID : 0),
                        TotalCalc = (subC != null && subC.Total > 0 ? subC.Total : 0),
                        LastTotalCashier = (tt.Last_Cashier_Total.HasValue ? tt.Last_Cashier_Total.Value : 0),
                        TotalFinal = tt.TotalFinal.Value,
                        DifferenceFinalCalc = tt.DifferenceFinalCalc.HasValue ? tt.DifferenceFinalCalc.Value : 0,
                        ID_Report_Type = tt.ID_Report_Type.HasValue ? tt.ID_Report_Type.Value : 0,
                        Desc_Report_Type = rt.Description
                    });


                    ////Filtros de Pesquisa
                    if (filtroPesquisa.Report_Type > 0)
                    {
                        query = query.Where(q => (q.ID_Report_Type == filtroPesquisa.Report_Type));
                    }

                    if (!string.IsNullOrEmpty(filtroPesquisa.txtNome))
                    {
                        query = query.Where(q => q.LogLogin.Contains(filtroPesquisa.txtNome));
                    }

                    if (!string.IsNullOrEmpty(filtroPesquisa.dtInicio))
                    {
                        DateTime dtFim = DateTime.UtcNow;
                        if (!string.IsNullOrEmpty(filtroPesquisa.dtFim))
                        {
                            dtFim = Convert.ToDateTime(filtroPesquisa.dtFim);
                        }

                        DateTime dtInicio = Convert.ToDateTime(filtroPesquisa.dtInicio);

                        query = query.Where(q => q.DT_Reg >= dtInicio && q.DT_Reg <= dtFim);
                    }

                    //ordenação
                    if (filtroPesquisa.sSortDir_0 == "asc")
                    {
                        if (filtroPesquisa.iSortCol_0 == 1)
                        {
                            query = query.OrderBy(q => q.DT_Reg);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 2)
                        {
                            query = query.OrderBy(q => q.LogLogin);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 3)
                        {
                            query = query.OrderBy(q => q.TotalTransactions);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 4)
                        {
                            query = query.OrderBy(q => q.LastTotalCashier);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 5)
                        {
                            query = query.OrderBy(q => q.TotalFinal);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 6)
                        {
                            query = query.OrderBy(q => q.DifferenceFinalCalc);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 7)
                        {
                            query = query.OrderBy(q => q.Desc_Report_Type);
                        }
                        else
                        {
                            query = query.OrderBy(q => q.DT_Reg);
                        }
                    }
                    else if (filtroPesquisa.sSortDir_0 == "desc")
                    {
                        if (filtroPesquisa.iSortCol_0 == 1)
                        {
                            query = query.OrderByDescending(q => q.DT_Reg);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 2)
                        {
                            query = query.OrderByDescending(q => q.LogLogin);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 3)
                        {
                            query = query.OrderByDescending(q => q.TotalTransactions);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 4)
                        {
                            query = query.OrderByDescending(q => q.LastTotalCashier);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 5)
                        {
                            query = query.OrderByDescending(q => q.TotalFinal);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 6)
                        {
                            query = query.OrderByDescending(q => q.DifferenceFinalCalc);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 7)
                        {
                            query = query.OrderByDescending(q => q.Desc_Report_Type);
                        }
                        else
                        {
                            query = query.OrderByDescending(q => q.DT_Reg);
                        }
                    }
                    else
                    {
                        query = query.OrderByDescending(q => q.DT_Reg);
                    }

                    query         = query.Take(100);
                    msg.Instances = query.Skip(filtroPesquisa.iDisplayStart).Take(filtroPesquisa.iDisplayLength).ToList();
                    msg.Code      = query.Count();//Total de registro com filtros aplicados
                }
            }
            catch (Exception ex)
            {
                msg.Exception = ex;
            }
            return(msg);
        }
Пример #20
0
        MessageCollection <GridStock> ISTOCK.GetAllStockByFilter(Dominio.Mensagens.Filtro.Stock filtroPesquisa)
        {
            var msg = new MessageCollection <Dominio.Mensagens.GridStock>();

            try
            {
                using (var context = new HostelEntities())
                {
                    ////Não pode ser feito o .ToList nesse momento, a query SQL esta esta sendo montada de acordo com os filtros
                    var query = (from s in context.Stocks
                                 join at in context.Action_Type on s.ID_ACTION_TYPE equals at.ID
                                 join pt in context.Product_Type on s.ID_PRODUCT_TYPE equals pt.ID
                                 select new Dominio.Mensagens.GridStock()
                    {
                        ID = s.ID,
                        DT_Reg = s.DT_Entrada,
                        Action_Type = at.DESCRIPTION,
                        Description = pt.Description,
                        LogLogin = s.LOGLOGIN,
                        Amount = s.AMOUNT
                    });

                    //Filtros de Pesquisa
                    //if (!string.IsNullOrEmpty(filtroPesquisa.user))
                    //    query = query.Where(q => q.LogLogin.Trim().ToUpper().Contains(filtroPesquisa.user.Trim().ToUpper()));

                    //if (filtroPesquisa.ID_Calc_Type > 0)
                    //    query = query.Where(q => q.ID_Calc_Type == filtroPesquisa.ID_Calc_Type);

                    if (!string.IsNullOrEmpty(filtroPesquisa.dtInicio))
                    {
                        DateTime dtFim = DateTime.UtcNow;
                        if (!string.IsNullOrEmpty(filtroPesquisa.dtFim))
                        {
                            dtFim = Convert.ToDateTime(filtroPesquisa.dtFim);
                        }

                        DateTime dtInicio = Convert.ToDateTime(filtroPesquisa.dtInicio);

                        query = query.Where(q => q.DT_Reg >= dtInicio && q.DT_Reg <= dtFim);
                    }

                    //ordenação
                    if (filtroPesquisa.sSortDir_0 == "asc")
                    {
                        if (filtroPesquisa.iSortCol_0 == 1)
                        {
                            query = query.OrderBy(q => q.DT_Reg);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 2)
                        {
                            query = query.OrderBy(q => q.LogLogin);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 3)
                        {
                            query = query.OrderBy(q => q.Action_Type);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 4)
                        {
                            query = query.OrderBy(q => q.Description);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 5)
                        {
                            query = query.OrderBy(q => q.Amount);
                        }
                        else
                        {
                            query = query.OrderBy(q => q.DT_Reg);
                        }
                    }
                    else if (filtroPesquisa.sSortDir_0 == "desc")
                    {
                        if (filtroPesquisa.iSortCol_0 == 1)
                        {
                            query = query.OrderByDescending(q => q.DT_Reg);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 2)
                        {
                            query = query.OrderByDescending(q => q.LogLogin);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 3)
                        {
                            query = query.OrderByDescending(q => q.Action_Type);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 4)
                        {
                            query = query.OrderByDescending(q => q.Description);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 5)
                        {
                            query = query.OrderByDescending(q => q.Amount);
                        }
                        else
                        {
                            query = query.OrderByDescending(q => q.DT_Reg);
                        }
                    }
                    else
                    {
                        query = query.OrderByDescending(q => q.DT_Reg);
                    }

                    query = query.Take(100);

                    ////Extract only current page
                    msg.Instances = query.Skip(filtroPesquisa.iDisplayStart).Take(filtroPesquisa.iDisplayLength).ToList();

                    ////Campo improvisado para gerar o total de paginacao

                    msg.Code = query.Count();//Total de registro com filtros aplicados
                    //Total de registro no banco sem filtro aplicado Deve ser feito uma pesquisa direto na Tabela outra Query Deverrá ser informado em outro campo no grid CONtroller eu coloquei fixo 110 pra teste
                }
            }
            catch (Exception ex)
            {
                msg.Exception = ex;
            }
            return(msg);
        }
Пример #21
0
        MessageCollection <GridCalc> IMONEY_COUNT.GetAllMoney_CountByFilter(Dominio.Mensagens.Filtro.Calc filtroPesquisa)
        {
            var msg = new MessageCollection <Dominio.Mensagens.GridCalc>();

            try
            {
                using (var context = new HostelEntities())
                {
                    ////Não pode ser feito o .ToList nesse momento, a query SQL esta esta sendo montada de acordo com os filtros
                    var query = (from c in context.Money_Count
                                 join ct in context.Calc_Type on c.ID_Calc_Type equals ct.ID
                                 select new Dominio.Mensagens.GridCalc()
                    {
                        ID = c.ID,
                        DT_reg = c.DT_Reg,
                        ID_Calc_Type = c.ID_Calc_Type,
                        Calc_Type = ct.Description.ToString(),
                        LogLogin = c.LogLogin,
                        Total = c.Total.ToString()
                    });

                    //Filtros de Pesquisa
                    if (!string.IsNullOrEmpty(filtroPesquisa.user))
                    {
                        query = query.Where(q => q.LogLogin.Trim().ToUpper().Contains(filtroPesquisa.user.Trim().ToUpper()));
                    }

                    if (filtroPesquisa.ID_Calc_Type > 0)
                    {
                        query = query.Where(q => q.ID_Calc_Type == filtroPesquisa.ID_Calc_Type);
                    }

                    if (!string.IsNullOrEmpty(filtroPesquisa.dtInicio))
                    {
                        DateTime dtFim = DateTime.UtcNow;
                        if (!string.IsNullOrEmpty(filtroPesquisa.dtFim))
                        {
                            dtFim = Convert.ToDateTime(filtroPesquisa.dtFim);
                        }

                        DateTime dtInicio = Convert.ToDateTime(filtroPesquisa.dtInicio);

                        query = query.Where(q => q.DT_reg >= dtInicio && q.DT_reg <= dtFim);
                    }

                    //ordenação
                    if (filtroPesquisa.sSortDir_0 == "asc")
                    {
                        if (filtroPesquisa.iSortCol_0 == 1)
                        {
                            query = query.OrderByDescending(q => q.DT_reg);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 2)
                        {
                            query = query.OrderByDescending(q => q.Calc_Type);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 3)
                        {
                            query = query.OrderByDescending(q => q.LogLogin);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 4)
                        {
                            query = query.OrderByDescending(q => q.Total);
                        }
                        else
                        {
                            query = query.OrderByDescending(q => q.DT_reg);
                        }
                    }
                    else if (filtroPesquisa.sSortDir_0 == "desc")
                    {
                        if (filtroPesquisa.iSortCol_0 == 1)
                        {
                            query = query.OrderBy(q => q.DT_reg);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 2)
                        {
                            query = query.OrderBy(q => q.Calc_Type);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 3)
                        {
                            query = query.OrderBy(q => q.LogLogin);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 4)
                        {
                            query = query.OrderBy(q => q.Total);
                        }
                        else
                        {
                            query = query.OrderBy(q => q.DT_reg);
                        }
                    }
                    else
                    {
                        query = query.OrderByDescending(q => q.DT_reg);
                    }

                    query = query.Take(100);

                    ////Extract only current page
                    msg.Instances = query.Skip(filtroPesquisa.iDisplayStart).Take(filtroPesquisa.iDisplayLength).ToList();

                    msg.Code = query.Count();//Total de registro com filtros aplicados
                    //Total de registro no banco sem filtro aplicado Deve ser feito uma pesquisa direto na Tabela outra Query Deverrá ser informado em outro campo no grid CONtroller eu coloquei fixo 110 pra teste
                }
            }
            catch (Exception ex)
            {
                msg.Exception = ex;
            }
            return(msg);
        }
Пример #22
0
        MessageCollection <GridTotalTransactionIndex> ITOTAL_TRANSACTIONS.GetReportEndOfTheDayTotalTransactions(Dominio.Mensagens.Filtro.TotalTransactions filtroPesquisa)
        {
            var msg = new MessageCollection <Dominio.Mensagens.GridTotalTransactionIndex>();

            try
            {
                using (var context = new HostelEntities())
                {
                    var query = (from tt in context.Total_Transactions
                                 join c in context.Calcs on tt.ID_Calc equals c.ID into cLeft
                                 join lt in context.Total_Transactions on tt.ID_Last_Transaction equals lt.ID into ltLeft
                                 from subC in cLeft.DefaultIfEmpty()
                                 from subLT in ltLeft.DefaultIfEmpty()
                                 where tt.DayMonthYearReference != null &&
                                 (tt.ID_Report_Type == filtroPesquisa.ID_REPORT_TYPE || filtroPesquisa.ID_REPORT_TYPE == 0) &&
                                 (tt.ID_SHIFT_TYPE == filtroPesquisa.ID_SHIFT_TYPE || filtroPesquisa.ID_SHIFT_TYPE == 0)

                                 select new Dominio.Mensagens.GridTotalTransactionIndex()
                    {
                        ID = tt.ID,
                        DT_Reg = tt.DT_Reg.Value,
                        LogLogin = tt.LogLogin,
                        TotalTransactions = tt.TotalTransactions.Value,
                        IDLastTotalCalc = (subC != null && subC.ID > 0 ? subC.ID : 0),
                        TotalCalc = (subC != null && subC.Total > 0 ? subC.Total : 0),
                        IDLastTotalCashier = (subLT != null && subLT.ID > 0 ? subLT.ID : 0),
                        LastTotalCashier = (subLT != null && subLT.TotalFinal.HasValue ? subLT.TotalFinal.Value : 0),
                        TotalFinal = tt.TotalFinal.Value,
                        DifferenceFinalCalc = tt.DifferenceFinalCalc.HasValue ? tt.DifferenceFinalCalc.Value : 0,
                        ID_Report_Type = tt.ID_Report_Type.HasValue ? tt.ID_Report_Type.Value : 0,
                        ID_SHIFT_TYPE = tt.ID_SHIFT_TYPE.HasValue ? tt.ID_SHIFT_TYPE.Value : 0,
                        DAY_MONTH_YEAR_REFERENCE = tt.DayMonthYearReference.Value
                    });

                    query.OrderByDescending(q => q.DAY_MONTH_YEAR_REFERENCE);

                    ////Filtros de Pesquisa
                    if (!string.IsNullOrEmpty(filtroPesquisa.Username))
                    {
                        query = query.Where(q => q.LogLogin.Contains(filtroPesquisa.Username));
                    }

                    if (!string.IsNullOrEmpty(filtroPesquisa.dtInicio))
                    {
                        DateTime dtFim = DateTime.UtcNow;
                        if (!string.IsNullOrEmpty(filtroPesquisa.dtFim))
                        {
                            dtFim = Convert.ToDateTime(filtroPesquisa.dtFim);
                        }

                        DateTime dtInicio = Convert.ToDateTime(filtroPesquisa.dtInicio);

                        query = query.Where(q => q.DAY_MONTH_YEAR_REFERENCE >= dtInicio.Date && q.DAY_MONTH_YEAR_REFERENCE <= dtFim.Date);
                    }

                    msg.Instances = query.ToList();
                    msg.Code      = query.Count();
                }
            }
            catch (Exception ex)
            {
                msg.Exception = ex;
            }
            return(msg);
        }
Пример #23
0
        MessageCollection <GridAtosPessoalConsulta> ICALC.GetAllCalcByFilter(Dominio.Mensagens.Filtro.Calc filtroPesquisa)
        {
            var msg = new MessageCollection <Dominio.Mensagens.GridAtosPessoalConsulta>();

            try
            {
                using (var context = new HostelEntities())
                {
                    var    enumTabTipoSolicitacao = UtilsLibrary.GetListEnum(typeof(TabTipoSolicitacao));
                    string ssa = enumTabTipoSolicitacao.Where(w => w.Value == "6").Select(s => s.StringTabTipoSolicitacao).FirstOrDefault();
                    ////Não pode ser feito o .ToList nesse momento, a query SQL esta esta sendo montada de acordo com os filtros
                    var query = (from c in context.Calcs
                                 //join ct in context.Calc_Type on c.ID_Calc_Type equals ct.ID
                                 //join mc in context.Money_Count on c.ID_Money_Count equals mc.ID

                                 //join s in context.V_SFI_Servidor on a.identificadorSFI_Servidor equals s.identificador
                                 //join soli in context.V_SV_Solicitacao on a.identificador_Solicitacao equals soli.identificador
                                 //join apo in context.AP_APOSENTADORIA on a.identificador equals apo.identificador

                                 //join soli in context.V_SV_Solicitacao on a.identificador_Solicitacao equals soli.identificador into soliLeft
                                 //join apo in context.AP_APOSENTADORIA on a.identificador equals apo.identificador into apoLeft
                                 //from subSoli in soliLeft.DefaultIfEmpty()
                                 //from subApo in apoLeft.DefaultIfEmpty()
                                 //where a.identificador_Solicitacao != null
                                 select new Dominio.Mensagens.GridCalc()
                    {
                        ID = c.ID,
                        DT_reg = c.DT_reg,
                        //Calc_Type = ct.Description.ToString(),
                        LogLogin = c.LogLogin,
                        Total = c.Total.ToString()
                                //identificador = a.identificador,
                                // nome = s.nomeServidor,
                                // dtCadastro = (subApo != null && subApo.dataEnvioAposentadoria.HasValue && !string.IsNullOrEmpty(subApo.dataEnvioAposentadoria.Value.ToString()) ? subApo.dataEnvioAposentadoria.Value.ToString() : string.Empty),
                                // Estado = a.numeroProcesso.HasValue ? "Ato Enviado" : "Ato Não Enviado",
                                // numeroProcesso = a.numeroProcesso.ToString(),
                                // TipoAtoPessoal = (subSoli == null ? a.identificadorTAB_TipoAtoPessoal.Value.ToString() : subSoli.identificadorSV_TabTipoSolicitacao.Value.ToString()),
                                // CPF = s.numeroCpf.ToString(),
                                // unidadeGestora = a.identificadorUnidadeGestora
                    });

                    //Filtros de Pesquisa
                    //if (!string.IsNullOrEmpty(filtroPesquisa.nome))
                    //    query = query.Where(q => q.nome.Trim().ToUpper().Contains(filtroPesquisa.nome.Trim().ToUpper()));

                    //if (!string.IsNullOrEmpty(filtroPesquisa.numeroProcesso))
                    //    query = query.Where(q => q.numeroProcesso == filtroPesquisa.numeroProcesso);

                    //if (filtroPesquisa.Estado == 0)
                    //    query = query.Where(q => string.IsNullOrEmpty(q.numeroProcesso));
                    //else //(filtroPesquisa.Estado == 0)
                    //    query = query.Where(q => !string.IsNullOrEmpty(q.numeroProcesso));

                    //if (filtroPesquisa.TipoAtoPessoal > 0)
                    //    query = query.Where(q => q.TipoAtoPessoal == filtroPesquisa.TipoAtoPessoal.ToString());

                    //if (!string.IsNullOrEmpty(filtroPesquisa.CPF))
                    //    query = query.Where(q => q.CPF == filtroPesquisa.CPF);

                    //if (!string.IsNullOrEmpty(filtroPesquisa.dtInicio))
                    //{
                    //    DateTime dtFim = DateTime.Now;
                    //    if (string.IsNullOrEmpty(filtroPesquisa.dtFim))
                    //        dtFim = Convert.ToDateTime(filtroPesquisa.dtFim);

                    //    query = query.Where(q => (Convert.ToDateTime(q.dtCadastro) >= Convert.ToDateTime(filtroPesquisa.dtInicio) && Convert.ToDateTime(q.dtCadastro) <= dtFim));
                    //}

                    //if (filtroPesquisa.unidade > 0)
                    //    query = query.Where(q => q.unidadeGestora == filtroPesquisa.unidade);

                    //ordenação
                    if (filtroPesquisa.sSortDir_0 == "asc")
                    {
                        if (filtroPesquisa.iSortCol_0 == 1)
                        {
                            query = query.OrderBy(q => q.ID);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 2)
                        {
                            query = query.OrderBy(q => q.DT_reg);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 3)
                        {
                            query = query.OrderBy(q => q.Calc_Type);
                        }
                        else
                        {
                            query = query.OrderBy(q => q.ID);
                        }
                    }
                    else if (filtroPesquisa.sSortDir_0 == "desc")
                    {
                        if (filtroPesquisa.iSortCol_0 == 1)
                        {
                            query = query.OrderByDescending(q => q.ID);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 2)
                        {
                            query = query.OrderByDescending(q => q.Calc_Type);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 3)
                        {
                            query = query.OrderByDescending(q => q.DT_reg);
                        }
                        else
                        {
                            query = query.OrderByDescending(q => q.Total);
                        }
                    }
                    else
                    {
                        query = query.OrderBy(q => q.ID);
                    }

                    query = query.Take(100);

                    ////Extract only current page
                    //msg.Instances = query.Skip(filtroPesquisa.iDisplayStart).Take(filtroPesquisa.iDisplayLength).ToList();


                    ////Campo improvisado para gerar o total de paginacao

                    msg.Code = query.Count();//Total de registro com filtros aplicados
                    //Total de registro no banco sem filtro aplicado Deve ser feito uma pesquisa direto na Tabela outra Query Deverrá ser informado em outro campo no grid CONtroller eu coloquei fixo 110 pra teste
                }
            }
            catch (Exception ex)
            {
                msg.Exception = ex;
            }
            return(msg);
        }
Пример #24
0
        MessageCollection <GridLists> ILISTS.GetAllListsByFilter(Dominio.Mensagens.Filtro.Lists filtroPesquisa)
        {
            var msg = new MessageCollection <Dominio.Mensagens.GridLists>();

            try
            {
                using (var context = new HostelEntities())
                {
                    var query = (from l in context.LISTs
                                 join d in context.DOCUMENTs on l.ID_DOCUMENT equals d.ID
                                 where filtroPesquisa.ID_LIST_TYPE == l.ID_LIST_TYPE || filtroPesquisa.ID_LIST_TYPE == 0
                                 select new Dominio.Mensagens.GridLists()
                    {
                        ID = l.ID,
                        ID_LIST_TYPE = l.ID_LIST_TYPE,
                        CHECK_IN = l.CHECK_IN,
                        CHECK_OUT = l.CHECK_OUT,
                        DT_START_BLOCK = l.DT_START_BLOCK,
                        DT_START_BOOK = l.DT_START_BOOK,
                        NOTES = l.NOTES,
                        FIRST_NAME_GUEST = l.FIRST_NAME_GUEST,
                        LAST_NAME_GUEST = l.LAST_NAME_GUEST,
                        LOGLOGIN = l.LOGLOGIN,
                        ID_DOCUMENT = l.ID_DOCUMENT,
                        FILE_NAME = d.FILE_NAME,
                        FILE_SIZE = d.FILE_SIZE,
                        FILE_TYPE = d.FILE_TYPE,
                        FILE_CONTENT = d.FILE_CONTENT,
                        DT_INSERT = d.DT_INSERT,
                        DT_DELETE = d.DT_DELETE
                    });

                    if (!string.IsNullOrEmpty(filtroPesquisa.firstName))
                    {
                        query = query.Where(q => q.FIRST_NAME_GUEST.Trim().ToUpper().Contains(filtroPesquisa.firstName.Trim().ToUpper()));
                    }

                    if (!string.IsNullOrEmpty(filtroPesquisa.lastName))
                    {
                        query = query.Where(q => q.LAST_NAME_GUEST.Trim().ToUpper().Contains(filtroPesquisa.lastName.Trim().ToUpper()));
                    }

                    if (!string.IsNullOrEmpty(filtroPesquisa.lastFirstName.ToString()) && filtroPesquisa.lastFirstName.Count() > 0)
                    {
                        List <GridLists> aux = new List <GridLists>();
                        foreach (var item in filtroPesquisa.lastFirstName)
                        {
                            string lastName  = item.Trim().ToUpper().Split(',')[0];
                            string firstName = item.Trim().ToUpper().Split(',')[1];
                            var    sub       = query.Where(q => q.LAST_NAME_GUEST.Trim().ToUpper().Contains(lastName) || q.LAST_NAME_GUEST.Trim().ToUpper().Contains(firstName));
                            if (sub != null && sub.Count() > 0)
                            {
                                foreach (var itemSub in sub)
                                {
                                    aux.Add(itemSub);
                                }
                            }
                        }
                        query = aux.AsQueryable();
                    }

                    //if (!string.IsNullOrEmpty(filtroPesquisa.numeroProcesso))
                    //    query = query.Where(q => q.numeroProcesso == filtroPesquisa.numeroProcesso);

                    //if (filtroPesquisa.Estado == 0)
                    //    query = query.Where(q => string.IsNullOrEmpty(q.numeroProcesso));
                    //else //(filtroPesquisa.Estado == 0)
                    //    query = query.Where(q => !string.IsNullOrEmpty(q.numeroProcesso));

                    //if (filtroPesquisa.TipoAtoPessoal > 0)
                    //    query = query.Where(q => q.TipoAtoPessoal == filtroPesquisa.TipoAtoPessoal.ToString());

                    //if (!string.IsNullOrEmpty(filtroPesquisa.CPF))
                    //    query = query.Where(q => q.CPF == filtroPesquisa.CPF);

                    //if (!string.IsNullOrEmpty(filtroPesquisa.dtInicio))
                    //{
                    //    DateTime dtFim = DateTime.Now;
                    //    if (string.IsNullOrEmpty(filtroPesquisa.dtFim))
                    //        dtFim = Convert.ToDateTime(filtroPesquisa.dtFim);

                    //    query = query.Where(q => (Convert.ToDateTime(q.dtCadastro) >= Convert.ToDateTime(filtroPesquisa.dtInicio) && Convert.ToDateTime(q.dtCadastro) <= dtFim));
                    //}

                    //if (filtroPesquisa.unidade > 0)
                    //    query = query.Where(q => q.unidadeGestora == filtroPesquisa.unidade);

                    //ordenação
                    if (filtroPesquisa.sSortDir_0 == "asc")
                    {
                        if (filtroPesquisa.iSortCol_0 == 1)
                        {
                            query = query.OrderByDescending(q => q.ID);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 2)
                        {
                            query = query.OrderByDescending(q => q.LOGLOGIN);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 3)
                        {
                            query = query.OrderByDescending(q => q.FullName);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 3)
                        {
                            //TO-DO: se for tipo blacklist ou tipo verify
                            query = query.OrderByDescending(q => q.CHECK_IN);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 3)
                        {
                            query = query.OrderByDescending(q => q.CHECK_OUT);
                        }
                        else
                        {
                            query = query.OrderByDescending(q => q.ID);
                        }
                    }
                    else if (filtroPesquisa.sSortDir_0 == "desc")
                    {
                        if (filtroPesquisa.iSortCol_0 == 1)
                        {
                            query = query.OrderBy(q => q.ID);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 2)
                        {
                            query = query.OrderBy(q => q.LOGLOGIN);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 3)
                        {
                            query = query.OrderBy(q => q.FullName);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 3)
                        {
                            query = query.OrderBy(q => q.CHECK_IN);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 3)
                        {
                            query = query.OrderBy(q => q.CHECK_OUT);
                        }
                        else
                        {
                            query = query.OrderBy(q => q.ID);
                        }
                    }
                    else
                    {
                        query = query.OrderBy(q => q.ID);
                    }

                    msg.Instances = query.Skip(filtroPesquisa.iDisplayStart).Take(filtroPesquisa.iDisplayLength).ToList();
                    msg.Code      = query.Count();
                }
            }
            catch (Exception ex)
            {
                msg.Exception = ex;
            }
            return(msg);
        }
Пример #25
0
        MessageCollection <GridTotalTransactionIndex> ITOTAL_TRANSACTIONS.GetAllTotalTransactions(Dominio.Mensagens.Filtro.TotalTransactions filtroPesquisa)
        {
            var msg = new MessageCollection <Dominio.Mensagens.GridTotalTransactionIndex>();

            try
            {
                using (var context = new HostelEntities())
                {
                    var query = (from tt in context.Total_Transactions
                                 join c in context.Calcs on tt.ID_Calc equals c.ID into cLeft
                                 join lt in context.Total_Transactions on tt.ID_Last_Transaction equals lt.ID into ltLeft
                                 from subC in cLeft.DefaultIfEmpty()
                                 from subLT in ltLeft.DefaultIfEmpty()
                                 where tt.ID_Report_Type != filtroPesquisa.ID_REPORT_TYPE
                                 select new Dominio.Mensagens.GridTotalTransactionIndex()
                    {
                        ID = tt.ID,
                        DT_Reg = tt.DT_Reg.Value,
                        LogLogin = tt.LogLogin,
                        TotalTransactions = tt.TotalTransactions.Value,
                        IDLastTotalCalc = (subC != null && subC.ID > 0 ? subC.ID : 0),
                        TotalCalc = (subC != null && subC.Total > 0 ? subC.Total : 0),
                        IDLastTotalCashier = (subLT != null && subLT.ID > 0 ? subLT.ID : 0),
                        LastTotalCashier = (subLT != null && subLT.TotalFinal.HasValue ? subLT.TotalFinal.Value : 0),
                        TotalFinal = tt.TotalFinal.Value,
                        DifferenceFinalCalc = tt.DifferenceFinalCalc.HasValue ? tt.DifferenceFinalCalc.Value : 0,
                        ID_Report_Type = tt.ID_Report_Type.HasValue ? tt.ID_Report_Type.Value : 0,
                        ID_SHIFT_TYPE = tt.ID_SHIFT_TYPE.HasValue ? tt.ID_SHIFT_TYPE.Value : 0,
                        DAY_MONTH_YEAR_REFERENCE = tt.DayMonthYearReference.HasValue ? tt.DayMonthYearReference.Value : (DateTime?)null
                    });

                    ////Filtros de Pesquisa
                    if (filtroPesquisa.Report_Type > 0)
                    {
                        query = query.Where(q => (q.ID_Report_Type == filtroPesquisa.Report_Type));
                    }

                    if (!string.IsNullOrEmpty(filtroPesquisa.txtNome))
                    {
                        query = query.Where(q => q.LogLogin.Contains(filtroPesquisa.txtNome));
                    }

                    if (!string.IsNullOrEmpty(filtroPesquisa.dtInicio))
                    {
                        DateTime dtFim = DateTime.UtcNow;
                        if (!string.IsNullOrEmpty(filtroPesquisa.dtFim))
                        {
                            dtFim = Convert.ToDateTime(filtroPesquisa.dtFim);
                        }

                        DateTime dtInicio = Convert.ToDateTime(filtroPesquisa.dtInicio);

                        query = query.Where(q => q.DT_Reg >= dtInicio && q.DT_Reg <= dtFim);
                    }

                    //ordenação
                    if (filtroPesquisa.sSortDir_0 == "asc")
                    {
                        if (filtroPesquisa.iSortCol_0 == 1)
                        {
                            query = query.OrderBy(q => q.DT_Reg);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 2)
                        {
                            query = query.OrderBy(q => q.LogLogin);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 3)
                        {
                            query = query.OrderBy(q => q.TotalTransactions);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 4)
                        {
                            query = query.OrderBy(q => q.LastTotalCashier);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 5)
                        {
                            query = query.OrderBy(q => q.TotalFinal);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 6)
                        {
                            query = query.OrderBy(q => q.DifferenceFinalCalc);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 7)
                        {
                            query = query.OrderBy(q => q.Desc_Report_Type);
                        }
                        else
                        {
                            query = query.OrderBy(q => q.DT_Reg);
                        }
                    }
                    else if (filtroPesquisa.sSortDir_0 == "desc")
                    {
                        if (filtroPesquisa.iSortCol_0 == 1)
                        {
                            query = query.OrderByDescending(q => q.DT_Reg);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 2)
                        {
                            query = query.OrderByDescending(q => q.LogLogin);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 3)
                        {
                            query = query.OrderByDescending(q => q.TotalTransactions);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 4)
                        {
                            query = query.OrderByDescending(q => q.LastTotalCashier);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 5)
                        {
                            query = query.OrderByDescending(q => q.TotalFinal);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 6)
                        {
                            query = query.OrderByDescending(q => q.DifferenceFinalCalc);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 7)
                        {
                            query = query.OrderByDescending(q => q.Desc_Report_Type);
                        }
                        else
                        {
                            query = query.OrderByDescending(q => q.DT_Reg);
                        }
                    }
                    else
                    {
                        query = query.OrderByDescending(q => q.DT_Reg);
                    }

                    query = query.Take(100);

                    ////Extract only current page
                    msg.Instances = query.Skip(filtroPesquisa.iDisplayStart).Take(filtroPesquisa.iDisplayLength).ToList();
                    //msg.Instances = query.ToList();


                    ////Campo improvisado para gerar o total de paginacao

                    msg.Code = query.Count();//Total de registro com filtros aplicados
                    //Total de registro no banco sem filtro aplicado Deve ser feito uma pesquisa direto na Tabela outra Query Deverrá ser informado em outro campo no grid CONtroller eu coloquei fixo 110 pra teste
                }
            }
            catch (Exception ex)
            {
                msg.Exception = ex;
            }
            return(msg);
        }