public JsonResult GetSubMenuTipe(string pid, string table)
        {
            // this action for Get Sub Menus from database and return as json data
            //System.Threading.Thread.Sleep(5000);
            List <Tipe> subMenus = new List <Tipe>();
            int         pID      = 0;

            int.TryParse(pid, out pID);
            using (taskDb dc = new taskDb())
            {
                var all = dc.SelectAllActiveRec_Entitet_tip("tbl_" + table).Where(a => a.aktiv = true && a.id_sup == pID).ToList();
                foreach (var item in all)
                {
                    Tipe tip = new Tipe();
                    tip.id       = item.nrrendor;
                    tip.parentId = Convert.ToInt32(item.id_sup);
                    tip.text     = item.emertimi;
                    subMenus.Add(tip);
                }
            }

            return(new JsonResult {
                Data = subMenus, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
        public ActionResult SaveNewTip(TipiViewModel model)
        {
            bool True = true;

            using (var db = new taskDb())
            {
                db.spI_tbl_Analize_tip(model.SelectedParent, True, model.EntitetTip.kodi, model.EntitetTip.kodifillim, model.EntitetTip.kodimbarim, model.EntitetTip.kodiaktual, model.EntitetTip.emertimi, model.EntitetTip.pershkrimi, model.EntitetTip.emertimiang, model.EntitetTip.pershkrimiang, model.EntitetTip.rradha, model.EntitetTip.perdorues_id);
                db.SaveChanges();
                int a = db.SelectAllActiveRec_Entitet_tip("tbl_Analize").OrderByDescending(i => i.nrrendor).FirstOrDefault().nrrendor;
                db.spI_tbl_nder_Analize_tip_kategori(model.SelectedParent, a, model.SelectedKategoriId, model.EntitetTip.perdorues_id);
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult EditimTipPopUp(string idKategori, string name, string id)
        {
            Helper        hp    = new Helper();
            int           ID    = Convert.ToInt32(id);
            TipiViewModel model = new TipiViewModel();

            model.table           = name;
            model.SelectTipParent = hp.GetTip(name, idKategori, id);
            using (var db = new taskDb())
            {
                model.EntitetTip = db.SelectAllActiveRec_Entitet_tip("tbl_" + name).Where(i => i.nrrendor == ID && i.aktiv == true).ToList().FirstOrDefault();

                if (model.EntitetTip.id_sup == ID)
                {
                    ViewBag.Delete = 1;
                }
            }
            return(PartialView("EditimTipPopUp", model));
        }
        public ActionResult SelectTip(string idKategori, string name)
        {
            ViewBag.SelectedKategoriId = Convert.ToInt32(idKategori);
            ViewBag.table = name;
            List <SelectAllActiveRec_Entitet_tip_Result> listaReale1 = new List <SelectAllActiveRec_Entitet_tip_Result>();
            List <Tipe> list = new List <Tipe>();

            using (var db = new taskDb())
            {
                var lista = db.SelectAllActiveRec_nder_Entitet_tip_kategori("tbl_nder_" + name).Where(i => i.Entitet_tip_kategori_id == Convert.ToInt32(idKategori)).ToList();
                List <SelectAllActiveRec_Entitet_tip_Result> listaReale = db.SelectAllActiveRec_Entitet_tip("tbl_" + name).Where(a => a.aktiv == true).ToList();
                foreach (var item in listaReale)
                {
                    foreach (var item1 in lista)
                    {
                        if (item.nrrendor == item1.Entitet_tip_id)
                        {
                            listaReale1.Add(item);
                        }
                    }
                }
            }
            foreach (var item in listaReale1)
            {
                if (item.id_sup == -1)
                {
                    Tipe tip = new Tipe();
                    tip.id       = item.nrrendor;
                    tip.parentId = Convert.ToInt32(item.id_sup);
                    tip.text     = item.emertimi;
                    list.Add(tip);
                }
            }

            return(PartialView("_SelectTip", list));
        }
Ejemplo n.º 5
0
        public List <SelectListItem> GetTip(string table, string id, string idT)
        {
            using (var context = new taskDb())
            {
                var list = context.SelectAllActiveRec_nder_Entitet_tip_kategori("tbl_nder_" + table).Where(i => i.Entitet_tip_kategori_id == Convert.ToInt32(id) && i.aktiv == true).ToList();
                List <SelectAllActiveRec_Entitet_tip_Result> listTipe = new List <SelectAllActiveRec_Entitet_tip_Result>();

                List <SelectListItem> tipe = new List <SelectListItem>();
                foreach (var item in context.SelectAllActiveRec_Entitet_tip("tbl_" + table).Where(a => a.aktiv == true).ToList())
                {
                    foreach (var item1 in list)
                    {
                        if (item.nrrendor == item1.Entitet_tip_id && item.nrrendor != Convert.ToInt32(idT))
                        {
                            listTipe.Add(item);
                        }
                    }
                }

                tipe = listTipe.Select(n => new SelectListItem
                {
                    Value = n.nrrendor.ToString(),
                    Text  = n.emertimi
                }).ToList();
                var entitetTip = new SelectListItem()
                {
                    Value = "-1",
                    Text  = "--Zgjidh--"
                };
                tipe.Insert(0, entitetTip);



                return(tipe);
            }
        }