コード例 #1
0
        //
        // GET: /ListTable/Delete/5

        public ActionResult Delete(int ListTableID)
        {
            ViewBag.ListTableID = ListTableID;
            listtable listtable = ListTableRepository.GetListByID(ListTableID);

            return(PartialView(listtable));
        }
コード例 #2
0
 public bool AddRecord(listtable Record)
 {
     myRecords.Add(Record);
     context.listtables.Add(Record);
     context.SaveChanges();
     return(true);
 }
コード例 #3
0
        public ActionResult Create(int ListTableID)
        {
            GetData();
            ViewBag.BeginDate   = DateTime.Today;
            ViewBag.ListTableID = ListTableID;
            listtable table = ListTableRepository.GetListByID(ListTableID);

            if (table == null)
            {
                return(Content("Table not found"));
            }
            ViewBag.TableName = string.Format("Add record to table ({0})", table.Title);
            listheader header = ListHeaderRepository.GetByListTableID(ListTableID);

            ViewBag.TableHeaderID = header.ListHeaderID;
            ViewBag.Type1         = header.Type1;
            ViewBag.Type2         = header.Type2;
            ViewBag.Type3         = header.Type3;
            ViewBag.Type4         = header.Type4;
            ViewBag.Type5         = header.Type5;
            ViewBag.Type6         = header.Type6;
            ViewBag.Type7         = header.Type7;
            ViewBag.Type8         = header.Type8;
            ViewBag.Type9         = header.Type9;
            ViewBag.Type10        = header.Type10;

            return(PartialView(new listitem {
                DateEntered = System.DateTime.Today, EnteredBy = User.Identity.Name.ToString(), listTableID = ListTableID, Status = "Active"
            }));
        }
コード例 #4
0
        public ActionResult ListStatus(int ListTableID, string Status)
        {
            ViewBag.ListTableID = ListTableID;
            listtable  table  = ListTableRepository.GetListByID(ListTableID);
            listheader header = ListHeaderRepository.GetByListTableID(ListTableID);

            ViewBag.Header = header;

            IEnumerable <listitem> ListItem;

            ListItem            = ListItemRepository.GetListItemByListStatus(ListTableID, Status);
            ViewBag.RecordCount = ListItem.Count();

            //security
            ViewBag.Supervisor = false;
            int memberID = Convert.ToInt16(System.Web.HttpContext.Current.Session["personID"]);

            if (MembershipRepositroy.IsUser(memberID))
            {
                user user = MembershipRepositroy.GetUserByID(memberID);
                if ((user.role.Name == "WebMaster") || (user.role.Name == "Officer") || (user.role.Name == "Admin")) //creator access
                {
                    ViewBag.Supervisor = true;
                }
            }

            return(PartialView(ListItem));
        }
コード例 #5
0
        public ActionResult Edit(int ListTableID)
        {
            listtable listtable = ListTableRepository.GetListByID(ListTableID);

            GetData(listtable.ministryID);
            ViewBag.TableHeader = string.Format("Edit Table ({0})", listtable.Title);
            return(PartialView(listtable));
        }
コード例 #6
0
        public void HideListTable(int ListTableID = 0)
        {
            listtable table = ListTableRepository.GetListByID(ListTableID);

            if (table != null)
            {
                table.Status          = "Inactive";
                table.EnteredBy       = User.Identity.Name.ToString();
                table.DateEntered     = DateTime.Now;
                db.Entry(table).State = EntityState.Modified;
                db.SaveChanges();
            }
        }
コード例 #7
0
        public ActionResult DeleteConfirmed(int ListTableID)
        {
            listtable listtable           = ListTableRepository.GetListByID(ListTableID);
            IEnumerable <listitem> litems = ListItemRepository.GetAllListItemByListTable(ListTableID);

            ListItemRepository.DeleteAllRecords(litems);
            listheader header = ListHeaderRepository.GetByListTableID(ListTableID);

            ListHeaderRepository.DeleteRecord(header);
            ListTableRepository.DeleteRecord(listtable);

            //return RedirectToAction("List");
            return(Content("Table deleted successfully"));
        }
コード例 #8
0
        public ActionResult List(int ListTableID, bool canEdit = true)
        {
            ViewBag.CanEdit     = canEdit;
            ViewBag.ListTableID = ListTableID;
            listtable table = ListTableRepository.GetListByID(ListTableID);

            ViewBag.TableName = table.Title;
            listheader header = ListHeaderRepository.GetByListTableID(ListTableID);

            ViewBag.Header = header;

            IEnumerable <listitem> ListItem = null;

            // ListItem = ListItemRepository.GetListItemByList(ListTableID);
            //ViewBag.RecordCount = ListItem.Count();

            //security
            ViewBag.Supervisor = false;
            int memberID = Convert.ToInt16(System.Web.HttpContext.Current.Session["personID"]);

            if (MembershipRepositroy.IsUser(memberID))
            {
                user user = MembershipRepositroy.GetUserByID(memberID);
                if ((user.role.Name == "WebMaster") || (user.role.Name == "Officer") || (user.role.Name == "Admin")) //creator access
                {
                    ViewBag.Supervisor  = true;
                    ListItem            = ListItemRepository.GetAllListItemByListTable(ListTableID);
                    ViewBag.RecordCount = ListItem.Count();
                }
                else
                {
                    ListItem            = ListItemRepository.GetActiveListItemByListTable(ListTableID);
                    ViewBag.RecordCount = ListItem.Count();
                }
            }

            ViewBag.HasComment = false;
            foreach (listitem i in ListItem)
            {
                if (i.Comment.Trim() != "")
                {
                    ViewBag.HasComment = true;
                }
            }
            return(PartialView(ListItem));
        }
コード例 #9
0
        public ActionResult Display(int ListTableID, bool canEdit = true)
        {
            ViewBag.CanEdit     = canEdit;
            ViewBag.ListTableID = ListTableID;
            listtable              table  = ListTableRepository.GetListByID(ListTableID);
            listheader             header = ListHeaderRepository.GetByListTableID(ListTableID);
            IEnumerable <listitem> items  = ListItemRepository.GetAllListItemByListTable(ListTableID);

            ViewBag.HasHeader = false;
            if (header != null)
            {
                ViewBag.HasHeader = true;
            }



            return(PartialView(table));
        }
コード例 #10
0
 public ActionResult Edit(listtable listtable)
 {
     try
     {
         //if (contribution.CheckNumber == null) { contribution.CheckNumber = ""; }
         if (ModelState.IsValid)
         {
             db.Entry(listtable).State = EntityState.Modified;
             db.SaveChanges();
             TempData["Message2"] = string.Format("Table update successfully.");
             GetData(listtable.ministryID);
             return(RedirectToAction("Create", "ListItem", new { ListTableID = listtable.listTableID }));
         }
     }
     catch (Exception ex)
     {
         TempData["Message2"] = string.Format("Error editing {0} table data.", listtable.Title);
     }
     GetData(listtable.ministryID);
     return(PartialView(listtable));
 }
コード例 #11
0
        public ActionResult DisableTable(int ListTableID)
        {
            listtable listtable = ListTableRepository.GetListByID(ListTableID);

            try
            {
                listtable.Status = "Deleted";
                //if (contribution.CheckNumber == null) { contribution.CheckNumber = ""; }
                if (ModelState.IsValid)
                {
                    db.Entry(listtable).State = EntityState.Modified;
                    db.SaveChanges();
                    return(Content("Table deleted successfully"));
                }
            }
            catch (Exception ex)
            {
                TempData["Message2"] = string.Format("Error deleteing {0} table.", listtable.Title);
            }
            GetData();
            return(PartialView(listtable));
        }
コード例 #12
0
        public ActionResult Create(listtable listtable)
        {
            try
            {
                //if (contribution.CheckNumber == null) { contribution.CheckNumber = ""; }

                if (ModelState.IsValid)
                {
                    db.listtables.Add(listtable);
                    db.SaveChanges();
                    //ListTableRepository.AddRecord(listtable);
                    TempData["Message2"] = "Table record added successfully.";
                    GetData();
                    return(Content("Table record added successfully"));
                }
            }
            catch (Exception ex)
            {
                TempData["Message2"] = "Error adding table";
            }
            GetData();
            return(PartialView(listtable));
        }
コード例 #13
0
        public ActionResult Edit(int ListItemID)
        {
            listitem listitem = ListItemRepository.GetListItemByID(ListItemID);

            GetData();
            listtable table = ListTableRepository.GetListByID(listitem.listTableID);

            ViewBag.TableName = string.Format("Add new record to the{0}", table.Title);
            listheader header = ListHeaderRepository.GetByListTableID(listitem.listTableID);

            ViewBag.Type1  = header.Type1;
            ViewBag.Type2  = header.Type2;
            ViewBag.Type3  = header.Type3;
            ViewBag.Type4  = header.Type4;
            ViewBag.Type5  = header.Type5;
            ViewBag.Type6  = header.Type6;
            ViewBag.Type7  = header.Type7;
            ViewBag.Type8  = header.Type8;
            ViewBag.Type9  = header.Type9;
            ViewBag.Type10 = header.Type10;

            return(PartialView(listitem));
        }
コード例 #14
0
        public ActionResult Create(listheader listheader)
        {
            try
            {
                // if (listheader.Type1 == null) { listheader.Type1 = ""; }
                if (listheader.Type2 == null)
                {
                    listheader.Type2 = "";
                }
                if (listheader.Type3 == null)
                {
                    listheader.Type3 = "";
                }
                if (listheader.Type4 == null)
                {
                    listheader.Type4 = "";
                }
                if (listheader.Type5 == null)
                {
                    listheader.Type5 = "";
                }
                if (listheader.Type6 == null)
                {
                    listheader.Type6 = "";
                }
                if (listheader.Type7 == null)
                {
                    listheader.Type7 = "";
                }
                if (listheader.Type8 == null)
                {
                    listheader.Type8 = "";
                }
                if (listheader.Type9 == null)
                {
                    listheader.Type9 = "";
                }
                if (listheader.Type10 == null)
                {
                    listheader.Type10 = "";
                }

                // if (listheader.FieldName1 == null) { listheader.FieldName1 = ""; }
                if (listheader.FieldName2 == null)
                {
                    listheader.FieldName2 = "";
                }
                if (listheader.FieldName3 == null)
                {
                    listheader.FieldName3 = "";
                }
                if (listheader.FieldName4 == null)
                {
                    listheader.FieldName4 = "";
                }
                if (listheader.FieldName5 == null)
                {
                    listheader.FieldName5 = "";
                }
                if (listheader.FieldName6 == null)
                {
                    listheader.FieldName6 = "";
                }
                if (listheader.FieldName7 == null)
                {
                    listheader.FieldName7 = "";
                }
                if (listheader.FieldName8 == null)
                {
                    listheader.FieldName8 = "";
                }
                if (listheader.FieldName9 == null)
                {
                    listheader.FieldName9 = "";
                }
                if (listheader.FieldName10 == null)
                {
                    listheader.FieldName10 = "";
                }

                if (ModelState.IsValid)
                {
                    listtable table = new listtable();
                    table.ministryID  = listheader.ministryID;
                    table.Title       = listheader.TableName;
                    table.Status      = "Active";
                    table.ministryID  = listheader.ministryID;
                    table.EnteredBy   = User.Identity.Name.ToString();
                    table.DateEntered = System.DateTime.Today;
                    table.DateCreated = System.DateTime.Today;
                    ListTableRepository.AddRecord(table);

                    listheader.ListTableID = table.listTableID;
                    db.listheaders.Add(listheader);
                    db.SaveChanges();
                    ListHeaderRepository.AddRecord(listheader);
                    TempData["Message2"] = "Table header added successfully.";
                    GetData();
                    return(RedirectToAction("Create", "ListItem", new { ListTableID = listheader.ListTableID }));
                }
            }
            catch (Exception ex)
            {
                TempData["Message2"] = "Error adding table header";
            }
            GetData();

            return(PartialView(listheader));
        }
コード例 #15
0
 public void DeleteRecord(listtable record)
 {
     myRecords.Remove(record);
     context.listtables.Remove(record);
     context.SaveChanges();
 }
コード例 #16
0
 /*
  *
  *     public Lookup<int, listtable> GetList(int ministryID)
  *     {
  *       //  Dictionary<string, int> aList;
  *
  *         var aList = myRecords
  *         .Where(e => e.ministryID == ministryID)
  *         .OrderBy(e => (string)e.Title)
  *         .ToLookup(e =>e.listTableID,e => e);
  *
  *         return (aList);
  *     }
  */
 public listtable GetListByID(int listID)
 {
     record = myRecords.FirstOrDefault(e => e.listTableID == listID);
     return(record);
 }