Ejemplo n.º 1
0
        public static int GetMaxByFolhaHoraNo(string FolhaHoraNo)
        {
            try
            {
                using (var ctx = new SuchDBContext())
                {
                    int max = 0;

                    List <LinhasFolhaHoras> result = DBLinhasFolhaHoras.GetAll().Where(x => x.NoFolhaHoras == FolhaHoraNo).ToList();
                    result.ForEach(x =>
                    {
                        if (x.NoLinha > max)
                        {
                            max = x.NoLinha;
                        }
                    });

                    max = max + 1;

                    return(max);
                }
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
Ejemplo n.º 2
0
        public static decimal GetCustoTotalAjudaCustoByFolhaHoraNo(string FolhaHoraNo)
        {
            decimal CustoTotalAjudaCusto = 0;

            try
            {
                using (var ctx = new SuchDBContext())
                {
                    List <LinhasFolhaHoras> result = DBLinhasFolhaHoras.GetAll().Where(x => x.NoFolhaHoras == FolhaHoraNo && x.TipoCusto == 2).ToList();
                    if (result != null && result.Count > 0)
                    {
                        result.ForEach(x =>
                        {
                            if (x.CustoTotal != null)
                            {
                                CustoTotalAjudaCusto = CustoTotalAjudaCusto + (decimal)x.CustoTotal;
                            }
                        });
                    }

                    return(CustoTotalAjudaCusto);
                }
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
Ejemplo n.º 3
0
        public static int GetMaxPercursoByFolhaHoraNo(string FolhaHoraNo)
        {
            try
            {
                using (var ctx = new SuchDBContext())
                {
                    int max = 0;

                    List <LinhasFolhaHorasViewModel> result = DBLinhasFolhaHoras.GetAllByPercursoToList(FolhaHoraNo);
                    result.ForEach(x =>
                    {
                        if (x.NoLinha >= max)
                        {
                            max = x.NoLinha;
                        }
                    });

                    max = max + 1;

                    return(max);
                }
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
Ejemplo n.º 4
0
        public static decimal GetCustoTotalKMByFolhaHoraNo(string FolhaHoraNo)
        {
            decimal CustoTotalKM = 0;

            try
            {
                using (var ctx = new SuchDBContext())
                {
                    List <LinhasFolhaHoras> result = DBLinhasFolhaHoras.GetAll().Where(x => x.NoFolhaHoras == FolhaHoraNo && x.TipoCusto == 1).ToList();
                    if (result != null && result.Count > 0)
                    {
                        result.ForEach(x =>
                        {
                            if (x.CustoUnitario != null)
                            {
                                if (x.Distancia != null && x.Distancia == 0)
                                {
                                    CustoTotalKM = CustoTotalKM + ((decimal)x.Distancia * (decimal)x.CustoUnitario);
                                }
                                else
                                {
                                    if (x.DistanciaPrevista != null && x.DistanciaPrevista > 0)
                                    {
                                        CustoTotalKM = CustoTotalKM + ((decimal)x.DistanciaPrevista * (decimal)x.CustoUnitario);
                                    }
                                    else
                                    {
                                        if (x.Distancia != null)
                                        {
                                            CustoTotalKM = CustoTotalKM + ((decimal)x.Distancia * (decimal)x.CustoUnitario);
                                        }
                                    }
                                }
                            }
                        });
                    }


                    return(CustoTotalKM);
                }
            }
            catch (Exception ex)
            {
                return(0);
            }
        }