public void CaricaComboFKM(decimal idLivelloGFKM = 0, decimal nuovo = 0, decimal idRichiamo = 0)
        {
            var            r_fkm = new List <SelectListItem>();
            SelectListItem el1   = new SelectListItem();

            el1.Value = "0"; el1.Text = "";
            using (dtGruppoFKM dtl = new dtGruppoFKM())
            {
                List <DefFasciaKmModel> llf = new List <DefFasciaKmModel>();

                llf = dtl.getListFasciaKM().ToList();
                if (llf != null && llf.Count > 0)
                {
                    r_fkm = (from t in llf
                             select new SelectListItem()
                    {
                        Text = t.km,
                        Value = t.idfKm.ToString()
                    }).ToList();

                    if (idLivelloGFKM == 0)
                    {
                        r_fkm.First().Selected = true;
                        idLivelloGFKM = Convert.ToDecimal(r_fkm.First().Value);
                    }
                    else
                    {
                        var temp = r_fkm.Where(a => a.Value == idLivelloGFKM.ToString()).ToList();
                        if (temp.Count == 0)
                        {
                            r_fkm.First().Selected = true;
                            idLivelloGFKM = Convert.ToDecimal(r_fkm.First().Value);
                        }
                        else
                        {
                            r_fkm.Where(a => a.Value == idLivelloGFKM.ToString()).First().Selected = true;
                        }
                    }
                }
            }
            r_fkm.Insert(0, el1);
            if (nuovo == 0 && idRichiamo == 0)
            {
                foreach (var x in r_fkm)
                {
                    x.Selected = false;
                }
                r_fkm.Where(a => a.Value == "0").First().Selected = true;
            }
            ViewBag.FasciaKM = r_fkm;
        }
        public void CaricaComboFKM(decimal idLivelloGFKM = 0)
        {
            var r_fkm = new List <SelectListItem>();

            using (dtGruppoFKM dtl = new dtGruppoFKM())
            {
                List <DefFasciaKmModel> llf = new List <DefFasciaKmModel>();
                llf = dtl.getListFasciaKM(idLivelloGFKM).ToList();
                if (llf != null && llf.Count > 0)
                {
                    r_fkm = (from t in llf
                             select new SelectListItem()
                    {
                        Text = t.km,
                        Value = t.idfKm.ToString()
                    }).ToList();

                    if (idLivelloGFKM == 0)
                    {
                        r_fkm.First().Selected = true;
                        idLivelloGFKM = Convert.ToDecimal(r_fkm.First().Value);
                    }
                    else
                    {
                        var temp = r_fkm.Where(a => a.Value == idLivelloGFKM.ToString()).ToList();
                        if (temp.Count == 0)
                        {
                            r_fkm.First().Selected = true;
                            idLivelloGFKM = Convert.ToDecimal(r_fkm.First().Value);
                        }
                        else
                        {
                            r_fkm.Where(a => a.Value == idLivelloGFKM.ToString()).First().Selected = true;
                        }
                    }
                }
            }
            ViewBag.FasciaKM = r_fkm;
        }
        public void CaricaComboGruppoFKM(decimal idLivelloGFKM = 0)
        {
            var r = new List <SelectListItem>();
            List <GruppoFKMModel> llg = new List <GruppoFKMModel>();

            using (dtGruppoFKM dtl = new dtGruppoFKM())
            {
                llg = dtl.getListGruppoFKM().OrderBy(a => a.IDGRUPPOFK).ToList();
                if (llg != null && llg.Count > 0)
                {
                    r = (from t in llg
                         select new SelectListItem()
                    {
                        Text = t.leggeFasciaKM,
                        Value = t.IDGRUPPOFK.ToString()
                    }).ToList();

                    if (idLivelloGFKM == 0)
                    {
                        r.First().Selected = true;
                        idLivelloGFKM = Convert.ToDecimal(r.First().Value);
                    }
                    else
                    {
                        var temp = r.Where(a => a.Value == idLivelloGFKM.ToString()).ToList();
                        if (temp.Count == 0)
                        {
                            r.First().Selected = true;
                            idLivelloGFKM = Convert.ToDecimal(r.First().Value);
                        }
                        else
                        {
                            r.Where(a => a.Value == idLivelloGFKM.ToString()).First().Selected = true;
                        }
                    }
                }
                ViewBag.GruppoFKM = r;
            }
        }
        public void CaricaComboGruppoFKM(decimal idLivelloGFKM = 0, decimal idLivello_FKM = 0)
        {
            var r = new List <SelectListItem>();
            List <GruppoFKMModel> llg = new List <GruppoFKMModel>();

            using (dtGruppoFKM dtl = new dtGruppoFKM())
            {
                llg = dtl.getListGruppoFKM().OrderBy(a => a.IDGRUPPOFK).ToList();
                if (llg != null && llg.Count > 0)
                {
                    r = (from t in llg
                         select new SelectListItem()
                    {
                        Text = t.leggeFasciaKM,
                        Value = t.IDGRUPPOFK.ToString()
                    }).ToList();

                    if (idLivelloGFKM == 0)
                    {
                        r.First().Selected = true;
                        idLivello_FKM = Convert.ToDecimal(r.First().Value);
                    }
                    else
                    {
                        var temp = r.Where(a => a.Value == idLivelloGFKM.ToString()).ToList();
                        if (temp.Count == 0)
                        {
                            r.First().Selected = true;
                            idLivelloGFKM = Convert.ToDecimal(r.First().Value);
                        }
                        else
                        {
                            r.Where(a => a.Value == idLivelloGFKM.ToString()).First().Selected = true;
                        }
                    }
                }
                ViewBag.GruppoFKM = r;
                var r_fkm = new List <SelectListItem>();
                if (r.Count != 0)
                {
                    List <DefFasciaKmModel> llf = new List <DefFasciaKmModel>();
                    if (idLivelloGFKM == 0)
                    {
                        IEnumerable <SelectListItem> GruppoFKM = (IEnumerable <SelectListItem>)ViewBag.GruppoFKM;
                        idLivelloGFKM = Convert.ToDecimal(GruppoFKM.Where(x => x.Selected).FirstOrDefault().Value);
                    }
                    llf   = dtl.getListFasciaKM(idLivelloGFKM).ToList();
                    r_fkm = (from t in llf
                             select new SelectListItem()
                    {
                        Text = t.km,
                        Value = t.idfKm.ToString()
                    }).ToList();

                    if (idLivello_FKM == 0)
                    {
                        r_fkm.First().Selected = true;
                        idLivello_FKM = Convert.ToDecimal(r_fkm.First().Value);
                    }
                    else
                    {
                        var temp = r_fkm.Where(a => a.Value == idLivello_FKM.ToString()).ToList();
                        if (temp.Count == 0)
                        {
                            r_fkm.First().Selected = true;
                            idLivello_FKM = Convert.ToDecimal(r_fkm.First().Value);
                        }
                        else
                        {
                            r_fkm.Where(a => a.Value == idLivello_FKM.ToString()).First().Selected = true;
                        }
                    }
                }
                ViewBag.FasciaKM = r_fkm;
            }
        }