示例#1
0
        // GET: GLApectsandElements/Details/5
        public ActionResult Details(long?id, int?page, string ipp)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }


            var resultList = db.Database.SqlQuery <GLAspectsandElementLeglislation>("DECLARE @Manager hierarchyid SELECT @Manager = GLAspectsandElements.hid FROM GLAspectsandElements   WHERE AspectsElementsID =" + id + "SELECT        GLAspectsandElements.AspectsElementsID, GLAspectsandElements.Name, GLAspectsandElements.hid, GLAspectsandElements.[Level], GLAspectsandElements.parent, GLAspectsandElements.LeglislationLINK, GLAspectsandElements.Comment, GLAspectsandElements.CommentLINK, GLAccounts.Name AS[Clause], GLAccounts.ClauseText FROM  GLAspectsandElements INNER JOIN   GLAccounts ON GLAspectsandElements.LeglislationLINK = GLAccounts.Account WHERE cast(GLAspectsandElements.hid as hierarchyid).IsDescendantOf(@Manager) = 1 ORDER BY GLAspectsandElements.hid").ToList();

            //if (contas == null)
            //{
            //    return HttpNotFound();

            //}

            if (resultList == null)
            {
                return(HttpNotFound());
            }
            else
            {
                ViewBag.parent = resultList.First().Name;
            }
            ArrayList recolhidas        = (ArrayList)Session["ContasCollapsedList"];
            hidServices <GLaccounts> hs = new hidServices <GLaccounts>(db);
            string wc     = hs.WhereClause(recolhidas);                                                                           // Sql server only
            var    result = db.Database.SqlQuery <GLaccounts>("select * from GLaccounts where " + wc + " order by hid").ToList(); // Sql server only
            //var result = db.GLaccounts.OrderBy(c => c.hid).ToList().Where(c => c.IsNotCollapsed(hs, recolhidas));
            int pageNumber = page ?? 1;

            ipp = ipp ?? (string)Session["DefaultItemsPerPage"];
            // return View(resultList.ToList());
            return(View(resultList));
        }
示例#2
0
        public ActionResult DeleteConfirmed(long id, int?page, string ipp)
        {
            GLaccounts gLaccounts       = db.GLaccounts.Find(id);
            hidServices <GLaccounts> hs = new hidServices <GLaccounts>(db);
            hidServices <GLaccounts> hh = new hidServices <GLaccounts>(db);

            try
            {
                hh.delete(id.ToString());
            }
            catch (Exception ex)
            {
                TempData["ExclError"] = "Error deleting: " + ex.Message;
                //ModelState.AddModelError("", "Erro na remoção: " + ex.Message);
                return(RedirectToAction("Index", new { page = (Request.QueryString["page"] ?? (string)Session["DefaultItemsPerPage"]), ipp = (Request.QueryString["ipp"] ?? (string)Session["DefaultItemsPerPage"]) }));
            }
            int pageNumber = (page ?? 1);

            ipp = ipp ?? (string)Session["DefaultItemsPerPage"];
            ArrayList recolhidas = (ArrayList)Session["ContasCollapsedList"];
            string    wc         = hs.WhereClause(recolhidas);
            var       result     = db.Database.SqlQuery <GLaccounts>("select * from GLaccounts where " + wc + " order by hid").ToList(); // Sql server only

            //var result = db.GLaccounts.OrderBy(c => c.hid).ToList().Where(c => c.IsNotCollapsed(hs, recolhidas));
            return(View("Index", result.ToPagedList(pageNumber, int.Parse(ipp))));
        }
示例#3
0
        // GET: GLaccounts/Create
        public ActionResult Create(int?page, string ipp)
        {
            var mae = Session["itemSelecionado"] as String;
            hidServices <GLaccounts> hs = new hidServices <GLaccounts>(db);

            if (!hs.RootExists())
            {
                ViewBag.mensagem = "As root account";
            }
            else
            {
                try
                {
                    GLaccounts r = db.GLaccounts.Find(long.Parse(mae));
                    ViewBag.mensagem = "As last child of account " + mae + " (" + r.Name + ")";
                }
                catch (Exception)
                {
                    mae = "";
                }
                if (string.IsNullOrEmpty(mae))
                {
                    ModelState.AddModelError("", "Root exists. Please select parent account.");
                    ArrayList recolhidas = (ArrayList)Session["ContasCollapsedList"];
                    string    wc         = hs.WhereClause(recolhidas);
                    var       result     = db.Database.SqlQuery <GLaccounts>("select * from GLaccounts where " + wc + " order by hid").ToList(); // Sql server only
                    //var result = db.GLaccounts.OrderBy(c => c.hid).ToList().Where(c => c.IsNotCollapsed(hs, recolhidas));
                    int pageNumber = (page ?? 1);
                    ipp = ipp ?? (string)Session["DefaultItemsPerPage"];
                    return(View("Index", result.ToPagedList(pageNumber, int.Parse(ipp))));
                }
            }
            return(View());
        }
        public ActionResult DetailofAncestors(long?id, int?page, string ipp)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            //GLaccounts contas = db.GLaccounts.Find(id);

            var resultList = db.Database.SqlQuery <GLAccountsViewmodel>("GetClauseAncestors @Account", new SqlParameter("Account", id)).ToList();

            //if (contas == null)
            //{
            //    return HttpNotFound();

            //}

            if (resultList == null)
            {
                return(HttpNotFound());
            }
            else
            {
                ViewBag.parent = resultList.First().Name + " " + resultList.First().ClauseText;
            }
            ArrayList recolhidas        = (ArrayList)Session["ContasCollapsedList"];
            hidServices <GLaccounts> hs = new hidServices <GLaccounts>(db);
            string wc     = hs.WhereClause(recolhidas);                                                                           // Sql server only
            var    result = db.Database.SqlQuery <GLaccounts>("select * from GLaccounts where " + wc + " order by hid").ToList(); // Sql server only
            //var result = db.GLaccounts.OrderBy(c => c.hid).ToList().Where(c => c.IsNotCollapsed(hs, recolhidas));
            int pageNumber = page ?? 1;

            ipp = ipp ?? (string)Session["DefaultItemsPerPage"];
            // return View(resultList.ToList());
            return(View(resultList));
        }
        // GET: GLaccounts/Details/5
        public ActionResult Details(long?id, int?page, string ipp)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            //GLaccounts contas = db.GLaccounts.Find(id);

            var resultList = db.Database.SqlQuery <GLaccounts>("DECLARE @Manager hierarchyid  SELECT @Manager = hid FROM GLAccounts   WHERE account = " + id + " SELECT* FROM GLAccounts WHERE cast(hid as hierarchyid).IsDescendantOf(@Manager) = 1 ORDER BY hid").ToList();

            //if (contas == null)
            //{
            //    return HttpNotFound();

            //}

            if (resultList == null)
            {
                return(HttpNotFound());
            }
            else
            {
                ViewBag.parent = resultList.First().Name + " " + resultList.First().ClauseText;
            }
            ArrayList recolhidas        = (ArrayList)Session["ContasCollapsedList"];
            hidServices <GLaccounts> hs = new hidServices <GLaccounts>(db);
            string wc     = hs.WhereClause(recolhidas);                                                                           // Sql server only
            var    result = db.Database.SqlQuery <GLaccounts>("select * from GLaccounts where " + wc + " order by hid").ToList(); // Sql server only
            //var result = db.GLaccounts.OrderBy(c => c.hid).ToList().Where(c => c.IsNotCollapsed(hs, recolhidas));
            int pageNumber = page ?? 1;

            ipp = ipp ?? (string)Session["DefaultItemsPerPage"];
            // return View(resultList.ToList());
            return(View(resultList));
        }
示例#6
0
        public ActionResult Collapse(long id, int?pagenumber, string ipp)
        {
            AtualizaListaRecolhidos(id.ToString(), true);
            ArrayList recolhidas = (ArrayList)Session["ContasCollapsedList"];
            hidServices <GLAspectsandElements> hs = new hidServices <GLAspectsandElements>(db);
            string wc     = hs.WhereClause(recolhidas);
            var    result = db.Database.SqlQuery <GLAspectsandElements>("select * from GLAspectsandElements where " + wc + " order by hid").ToList(); // Sql server only
            //var result = db.GLaccounts.OrderBy(c => c.hid).ToList().Where(c => c.IsNotCollapsed(hs, recolhidas));
            int pageNumber = (pagenumber ?? 1);

            ipp = ipp ?? (string)Session["DefaultItemsPerPage"];
            return(View("Index", result.ToPagedList(pageNumber, int.Parse(ipp))));
        }
示例#7
0
 public ActionResult Edit([Bind(Include = "AspectsElementsID,Name,hid,Level,parent,LeglislationLINK,Comment,CommentLINK")] GLAspectsandElements gLaccounts, int?page, string ipp)
 {
     if (ModelState.IsValid)
     {
         gLaccounts.hid             = (byte[])TempData["hid"];
         db.Entry(gLaccounts).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         int pageNumber = (page ?? 1);
         ipp = ipp ?? (string)Session["DefaultItemsPerPage"];
         ArrayList recolhidas = (ArrayList)Session["ContasCollapsedList"];
         hidServices <GLAspectsandElements> hs = new hidServices <GLAspectsandElements>(db);
         string wc     = hs.WhereClause(recolhidas);
         var    result = db.Database.SqlQuery <GLAspectsandElements>("select * from GLAspectsandElements where " + wc + " order by hid").ToList(); // Sql server only
         //var result = db.GLaccounts.OrderBy(c => c.hid).ToList().Where(c => c.IsNotCollapsed(hs, recolhidas));
         return(View("Index", result.ToPagedList(pageNumber, int.Parse(ipp))));
     }
     return(View(gLaccounts));
 }
示例#8
0
        // GET: GLAspectsandElements
        public ActionResult Index(int?page, string ipp)
        {
            if (TempData["ExclError"] != null)
            {
                ModelState.AddModelError("", TempData["ExclError"].ToString());
            }
            ArrayList recolhidas = (ArrayList)Session["ContasCollapsedList"];
            hidServices <GLAspectsandElements> hs = new hidServices <GLAspectsandElements>(db);
            string wc = hs.WhereClause(recolhidas);

            var result = db.Database.SqlQuery <GLAspectsandElements>("select * from GLAspectsandElements where " + wc + " order by hid").ToList();
            //var result = db.GLaccounts.Where(wc).OrderBy(c => c.hid).ToList();   // dynamic where for sql server using isDescendant at server
            //var result = db.GLaccounts.OrderBy(c => c.hid).ToList().Where(c => c.IsNotCollapsed(hs, recolhidas));
            int pageNumber = (page ?? 1);

            ipp = ipp ?? (string)Session["DefaultItemsPerPage"];
            return(View(result.ToPagedList(pageNumber, int.Parse(ipp))));
        }
示例#9
0
        public ActionResult HCommand(GLAspectsandElements conta, int?page, string ipp, string refresh, string promote, string up, string down, string demote)
        {
            hidServices <GLAspectsandElements> hs = new hidServices <GLAspectsandElements>(db);

            if (string.IsNullOrEmpty(refresh))
            {
                var pk = Session["itemSelecionado"] as String;
                try
                {
                    if (!string.IsNullOrEmpty(promote))
                    {
                        hs.Command(pk, hidServices <GLAspectsandElements> .Commands.Promote);
                    }
                    if (!string.IsNullOrEmpty(up))
                    {
                        hs.Command(pk, hidServices <GLAspectsandElements> .Commands.Up);
                    }
                    if (!string.IsNullOrEmpty(down))
                    {
                        hs.Command(pk, hidServices <GLAspectsandElements> .Commands.Down);
                    }
                    if (!string.IsNullOrEmpty(demote))
                    {
                        hs.Command(pk, hidServices <GLAspectsandElements> .Commands.Demote);
                    }
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", ex.Message);
                }
            }
            ArrayList recolhidas = (ArrayList)Session["ContasCollapsedList"];

            db = new GLaccountsModel();                                                                                                               // to refresh entity after sql command
            string wc     = hs.WhereClause(recolhidas);
            var    result = db.Database.SqlQuery <GLAspectsandElements>("select * from GLAspectsandElements where " + wc + " order by hid").ToList(); // Sql server only
            //var result = db.GLaccounts.OrderBy(c => c.hid).ToList().Where(c => c.IsNotCollapsed(hs, recolhidas));
            int pageNumber = page ?? 1;

            ipp = ipp ?? (string)Session["DefaultItemsPerPage"];
            return(View("Index", result.ToPagedList(pageNumber, int.Parse(ipp))));
        }
示例#10
0
        // GET: GLaccounts/Details/5
        public ActionResult Details(long?id, int?page, string ipp)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            GLaccounts contas = db.GLaccounts.Find(id);

            if (contas == null)
            {
                return(HttpNotFound());
            }
            ArrayList recolhidas        = (ArrayList)Session["ContasCollapsedList"];
            hidServices <GLaccounts> hs = new hidServices <GLaccounts>(db);
            string wc     = hs.WhereClause(recolhidas);                                                                           // Sql server only
            var    result = db.Database.SqlQuery <GLaccounts>("select * from GLaccounts where " + wc + " order by hid").ToList(); // Sql server only
            //var result = db.GLaccounts.OrderBy(c => c.hid).ToList().Where(c => c.IsNotCollapsed(hs, recolhidas));
            int pageNumber = page ?? 1;

            ipp = ipp ?? (string)Session["DefaultItemsPerPage"];
            return(View(contas));
        }
示例#11
0
        public ActionResult Create([Bind(Include = "Account,Name,hid")] GLaccounts gLaccounts, int?page, string ipp)
        {
            int pageNumber = (page ?? 1);

            ipp = ipp ?? (string)Session["DefaultItemsPerPage"];
            if (ModelState.IsValid)
            {
                var mae = Session["itemSelecionado"] as String;
                hidServices <GLaccounts> hs = new hidServices <GLaccounts>(db);

                gLaccounts.hid = hs.GetNextSonHid(mae);
                db.GLaccounts.Add(gLaccounts);
                db.SaveChanges();
                //gLaccounts.InsertNewConta(gLaccounts.Name, mae);
                ArrayList recolhidas = (ArrayList)Session["ContasCollapsedList"];
                string    wc         = hs.WhereClause(recolhidas);
                var       result     = db.Database.SqlQuery <GLaccounts>("select * from GLaccounts where " + wc + " order by hid").ToList(); // Sql server only
                //var result = db.GLaccounts.OrderBy(c => c.hid).ToList().Where(c => c.IsNotCollapsed(hs, recolhidas));
                return(View("Index", result.ToPagedList(pageNumber, int.Parse(ipp))));
            }
            return(View(gLaccounts));
        }