Exemplo n.º 1
0
        public ActionResult GetSectionForm(int ActionID, int SectionID)
        {
            SectionModel model = new SectionModel();

            if (ActionID == 2)
            {
                Tbl_FMRes_Section sectionTbl = (from a in BOSSDB.Tbl_FMRes_Section where a.SectionID == SectionID select a).FirstOrDefault();
                model.SectionList.SectionTitle = sectionTbl.SectionTitle;
                model.SectionList.FunctionID   = GlobalFunction.ReturnEmptyInt(sectionTbl.FunctionID);
                model.SectionList.DeptID       = GlobalFunction.ReturnEmptyInt(sectionTbl.Tbl_FMRes_Function.Tbl_FMRes_Department.DeptID);
                model.SectionList.SectionID    = sectionTbl.SectionID;
                var functionList = (from a in BOSSDB.Tbl_FMRes_Function where a.DeptID == model.SectionList.DeptID orderby a.FunctionTitle select a).ToList();
                model.FunctionList = new SelectList(functionList, "FunctionID", "FunctionTitle");
            }
            else
            {
                model.SectionList.DeptID = (from a in BOSSDB.Tbl_FMRes_Department orderby a.DeptTitle select a.DeptID).FirstOrDefault();
                var functionList = (from a in BOSSDB.Tbl_FMRes_Function where a.DeptID == model.SectionList.DeptID orderby a.FunctionTitle select a).ToList();
                model.FunctionList = new SelectList(functionList, "FunctionID", "FunctionTitle");
            }

            model.DeptList = new SelectList(BOSSDB.Tbl_FMRes_Department, "DeptID", "DeptTitle");
            model.DeptList = (from li in model.DeptList orderby li.Text select li).ToList();


            model.ActionID = ActionID;
            return(PartialView("SectionTab/_SectionForm", model));
        }
Exemplo n.º 2
0
        public ActionResult ConfirmDeleteSection(int PrimaryID)
        {
            Tbl_FMRes_Section section = (from a in BOSSDB.Tbl_FMRes_Section where a.SectionID == PrimaryID select a).FirstOrDefault();

            BOSSDB.Tbl_FMRes_Section.Remove(section);
            BOSSDB.SaveChanges();

            var result = "";

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        public ActionResult DeleteFunction(int PrimaryID)
        {
            Tbl_FMRes_Function functionTbl   = (from a in BOSSDB.Tbl_FMRes_Function where a.FunctionID == PrimaryID select a).FirstOrDefault();
            Tbl_FMRes_Section  sectionRecord = (from a in BOSSDB.Tbl_FMRes_Section where a.FunctionID == PrimaryID select a).FirstOrDefault();
            var confirmDelete = "";

            if (functionTbl != null)
            {
                if (sectionRecord != null)
                {
                    confirmDelete = "restricted";
                }

                else
                {
                    confirmDelete = "false";
                }
            }
            var result = new { confirmDelete = confirmDelete };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 4
0
        public ActionResult DeleteSection(int PrimaryID)
        {
            Tbl_FMRes_Section section = (from a in BOSSDB.Tbl_FMRes_Section where a.SectionID == PrimaryID select a).FirstOrDefault();
            //Tbl_FMRes_Section sectionRecord = (from a in BOSSDB.Tbl_FMRes_Section where a.FunctionID == PrimaryID select a).FirstOrDefault();
            var confirmDelete = "";

            if (section != null)
            {
                //if (sectionRecord != null)
                //{
                //    confirmDelete = "restricted";
                //}

                //else
                //{
                //    confirmDelete = "false";
                //}
                confirmDelete = "false";
            }
            var result = new { confirmDelete = confirmDelete };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 5
0
        public ActionResult SaveSection(SectionModel model)
        {
            var isExist = "";

            if (ModelState.IsValid)
            {
                var SectionTitle = GlobalFunction.RemoveSpaces(model.SectionList.SectionTitle);
                var FunctionID   = model.SectionList.FunctionID;
                var SectionID    = model.SectionList.SectionID;
                var DeptID       = model.SectionList.DeptID;


                List <Tbl_FMRes_Section> sectionList   = (from a in BOSSDB.Tbl_FMRes_Section where (a.FunctionID == FunctionID && a.Tbl_FMRes_Function.DeptID == DeptID) select a).ToList();
                Tbl_FMRes_Section        sectionRecord = (from a in BOSSDB.Tbl_FMRes_Section where a.SectionID == SectionID select a).FirstOrDefault();
                var save = false;
                if (sectionList.Count > 0)
                {
                    foreach (var item in sectionList)
                    {
                        if (sectionRecord != null)
                        {
                            if (GlobalFunction.AutoCaps_RemoveSpaces(item.SectionTitle) == GlobalFunction.AutoCaps_RemoveSpaces(SectionTitle) && item.SectionID == sectionRecord.SectionID)  // walang binago
                            {
                                save = true;
                            }
                            else if (GlobalFunction.AutoCaps_RemoveSpaces(item.SectionTitle) != GlobalFunction.AutoCaps_RemoveSpaces(SectionTitle) || item.SectionID == sectionRecord.SectionID) // may binago pero walang kaparehas
                            {
                                save = true;
                            }
                            else if (GlobalFunction.AutoCaps_RemoveSpaces(item.SectionTitle) == GlobalFunction.AutoCaps_RemoveSpaces(SectionTitle)) // may binago pero may kaparehas
                            {
                                save = false;
                                break;
                            }
                        }
                        else
                        {
                            if (GlobalFunction.AutoCaps_RemoveSpaces(item.SectionTitle) != GlobalFunction.AutoCaps_RemoveSpaces(SectionTitle)) // for adding
                            {
                                save = true;
                            }
                            else
                            {
                                save = false;
                                break;
                            }
                        }
                    }
                }
                else
                {
                    save = true;
                }

                switch (save)
                {
                case true:
                    switch (model.ActionID)
                    {
                    case 1:
                        Tbl_FMRes_Section sectionAdd = new Tbl_FMRes_Section();
                        sectionAdd.SectionTitle = SectionTitle;
                        sectionAdd.FunctionID   = FunctionID;

                        BOSSDB.Tbl_FMRes_Section.Add(sectionAdd);
                        BOSSDB.SaveChanges();
                        isExist = "false";
                        break;

                    case 2:
                        sectionRecord.SectionTitle = SectionTitle;
                        sectionRecord.FunctionID   = FunctionID;

                        BOSSDB.Entry(sectionRecord);
                        BOSSDB.SaveChanges();
                        isExist = "justUpdate";
                        break;
                    }
                    break;

                default:
                    isExist = "true";
                    break;
                }
            }
            return(new JsonResult()
            {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                Data = new { isExist = isExist }
            });
        }