Esempio n. 1
0
        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));
        }
Esempio n. 2
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));
        }
Esempio n. 3
0
        private Boolean IsDescendantOf(hidServices <GLaccounts> hs, string pk)
        {
            SqlHierarchyId h     = Conversions.Bytes2HierarchyId(hid);
            SqlHierarchyId pkHid = Conversions.Bytes2HierarchyId(hs.GetHid(pk));

            return((Boolean)h.IsDescendantOf(pkHid));
        }
Esempio n. 4
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))));
        }
Esempio n. 5
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());
        }
Esempio n. 6
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);

            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));
        }
Esempio n. 7
0
        public ActionResult Expand(long id, int?pagenumber, string ipp)
        {
            AtualizaListaRecolhidos(id.ToString(), false);
            ArrayList recolhidas        = (ArrayList)Session["ContasCollapsedList"];
            hidServices <GLaccounts> hs = new hidServices <GLaccounts>(db);
            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))));
        }
Esempio n. 8
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))));
        }
Esempio n. 9
0
        // GET: GLaccounts
        public ActionResult Index(int?page, string ipp)
        {
            if (TempData["ExclError"] != null)
            {
                ModelState.AddModelError("", TempData["ExclError"].ToString());
            }
            ArrayList recolhidas        = (ArrayList)Session["ContasCollapsedList"];
            hidServices <GLaccounts> hs = new hidServices <GLaccounts>(db);
            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))));
        }
Esempio n. 10
0
 public ActionResult Edit([Bind(Include = "Account,Name,hid")] GLaccounts 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 <GLaccounts> hs = new hidServices <GLaccounts>(db);
         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));
 }
Esempio n. 11
0
        public Boolean IsNotCollapsed(hidServices <GLaccounts> hs, ArrayList c)
        {
            Boolean condition = true;

            foreach (string i in c)
            {
                if ((!IsDescendantOf(hs, i)) || (Account == long.Parse(i)))
                {
                    condition = true;
                }
                else
                {
                    condition = false;
                    return(false);
                }
            }
            return(condition);
        }
Esempio n. 12
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));
 }
Esempio n. 13
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))));
        }
Esempio n. 14
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))));
        }
Esempio n. 15
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"];
                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));
        }
Esempio n. 16
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);
            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));
        }
Esempio n. 17
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));
        }
Esempio n. 18
0
        public ActionResult Create([Bind(Include = "LeglislationID, Name, ClauseText, NonComplianceText, RemedialActionText, hid")] GLLeglislation gLaccounts, int?page, string ipp)
        {
            int pageNumber = (page ?? 1);

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

                gLaccounts.hid = hs.GetNextSonHid(mae);
                db.GLLeglislation.Add(gLaccounts);
                db.SaveChanges();
                //gLaccounts.InsertNewConta(gLaccounts.Name, mae);
                ArrayList recolhidas = (ArrayList)Session["ContasCollapsedList"];
                string    wc         = hs.WhereClause(recolhidas);
                var       result     = db.Database.SqlQuery <GLLeglislation>("select * from GLLeglislation 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));
        }
Esempio n. 19
0
        public ActionResult HCommand(GLaccounts conta, int?page, string ipp, string refresh, string promote, string up, string down, string demote)
        {
            hidServices <GLaccounts> hs = new hidServices <GLaccounts>(db);

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