Пример #1
0
        public ActionResult List(int ID)
        {
            ItemList newIL = new ItemList { };
            newIL = ItemList.getListByID(ID);
            foreach (var gr in newIL.ListGroups)
            {
                gr.GroupsItems = ItemGroup.GetGroupsItems(gr.gid);
            }
            ViewBag.Measurments = Measurment.GetAllMeasurments();

            var lists = new List<ItemList> { };
            Person person = Person.GetPersonFromSession();
            lists = ItemList.getAllListsForPerson(person.oid);
            ViewBag.UsersList = Person.GetViewersForList(person.oid, person.fid, ID);
            ViewBag.ListsList = lists;
            List<string> items = Item.GetAllItems();
            ViewBag.Typeahead = items;

            return View(newIL);
        }
Пример #2
0
        public static ItemList InsertNewEmptyList(string listname, int listoid)
        {
            ItemList newlist = new ItemList { Name = listname };
            string cmd = "Insert into Lists (ListName, oid) values ('" + listname + "', '" + listoid.ToString() + "')";
            SQLCmd = new SqlCommand(cmd, SQLCon);
            SQLCmd.ExecuteNonQuery();

            SQLCmd = new SqlCommand("Select top 1 lid, oid from Lists order by lid desc", SQLCon);
            SQLDR = SQLCmd.ExecuteReader(CommandBehavior.Default);

            while (SQLDR.Read())
            {
                int tmp = 1;
                int.TryParse(SQLDR["lid"].ToString(), out tmp);
                newlist.lid = tmp;
            }
            SQLDR.Close();

            SQLCmd = new SqlCommand("Insert into Views (lid, oid) values ('" + newlist.lid.ToString() + "', '" + listoid.ToString() + "')", SQLCon);
            SQLCmd.ExecuteNonQuery();

            SQLCmd = new SqlCommand("Insert into ItemGroups (lid) values ('" + newlist.lid.ToString() + "')", SQLCon);
            SQLCmd.ExecuteNonQuery();

            return newlist;
        }
Пример #3
0
        public static ItemList getListByID(int ID)
        {
            SQLCmd = new SqlCommand("Select ListName, ListComment, oid from Lists where lid = " + ID.ToString(), SQLCon);
            SQLDR = SQLCmd.ExecuteReader(CommandBehavior.Default);

            ItemList lst = new ItemList { lid = ID };

            while (SQLDR.Read())
            {
                int tmpoid = 0;
                int.TryParse(SQLDR["oid"].ToString(), out tmpoid);
                lst.Name = SQLDR["ListName"].ToString();
                lst.oid = tmpoid;
                lst.Comment = SQLDR["ListComment"].ToString();
            }
            SQLDR.Close();

            SQLCmd = new SqlCommand("Select gid, Name from ItemGroups where ( lid = " + ID.ToString() + ")", SQLCon);
            SQLDR = SQLCmd.ExecuteReader(CommandBehavior.Default);

            lst.ListGroups = new List<ItemGroup> { };
            while (SQLDR.Read())
            {
                int tmpgid = 0;
                int.TryParse(SQLDR["gid"].ToString(), out tmpgid);
                lst.ListGroups.Add(new ItemGroup { lid = ID, gid = tmpgid, Name = SQLDR["Name"].ToString() });
            }
            SQLDR.Close();
            return lst;
        }