public ActionResult DeleteSector(int PrimaryID)
        {
            Tbl_FMSector_Sector    sector    = (from a in BOSSDB.Tbl_FMSector_Sector where a.SectorID == PrimaryID select a).FirstOrDefault();
            Tbl_FMSector_SubSector subSector = (from a in BOSSDB.Tbl_FMSector_SubSector where a.SectorID == PrimaryID select a).FirstOrDefault();

            Tbl_FMRes_Department dept = (from e in BOSSDB.Tbl_FMRes_Department where e.SectorID == PrimaryID select e).FirstOrDefault();
            Tbl_FMRes_Function   func = (from e in BOSSDB.Tbl_FMRes_Function where e.SectorID == PrimaryID select e).FirstOrDefault();
            var confirmDelete         = "";

            if (sector != null)
            {
                if (dept != null || func != null)
                {
                    confirmDelete = "restricted";
                }
                else if (subSector != null)
                {
                    confirmDelete = "true";
                }
                else
                {
                    confirmDelete = "false";
                }
            }
            var result = new { confirmDelete = confirmDelete };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        public ActionResult ConfirmDeleteFunction(int PrimaryID)
        {
            Tbl_FMRes_Function functionTbl = (from a in BOSSDB.Tbl_FMRes_Function where a.FunctionID == PrimaryID select a).FirstOrDefault();

            BOSSDB.Tbl_FMRes_Function.Remove(functionTbl);
            BOSSDB.SaveChanges();

            var result = "";

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
예제 #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));
        }
        public ActionResult DeleteOfficeType(int PrimaryID)
        {
            Tbl_FMOfficeType     officetype = (from a in BOSSDB.Tbl_FMOfficeType where a.OfficeTypeID == PrimaryID select a).FirstOrDefault();
            Tbl_FMRes_Department dept       = (from e in BOSSDB.Tbl_FMRes_Department where e.OfficeTypeID == PrimaryID select e).FirstOrDefault();
            Tbl_FMRes_Function   func       = (from e in BOSSDB.Tbl_FMRes_Function where e.OfficeTypeID == PrimaryID select e).FirstOrDefault();
            var confirmDelete = "";

            if (officetype != null)
            {
                if (dept != null || func != null)
                {
                    confirmDelete = "restricted";
                }
                else
                {
                    confirmDelete = "false";
                }
            }
            var result = new { confirmDelete = confirmDelete };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
예제 #5
0
        public ActionResult SaveFunction(FunctionModel model)
        {
            var isExist = "";

            if (ModelState.IsValid)
            {
                var FunctionTitle      = GlobalFunction.RemoveSpaces(model.FunctionList.FunctionTitle);
                var FunctionAbbrv      = GlobalFunction.RemoveSpaces(model.FunctionList.FunctionAbbrv);
                var FunctionCode       = GlobalFunction.RemoveSpaces(model.FunctionList.FunctionCode);
                var DeptOfficeCodefunc = GlobalFunction.RemoveSpaces(model.FunctionList.DeptOfficeCodefunc);
                var SectorID           = model.FunctionList.SectorID;
                var OfficeTypeID       = model.FunctionList.OfficeTypeID;
                var DeptID             = model.FunctionList.DeptID;
                var FunctionID         = model.FunctionList.FunctionID;

                int?SubSectorID = model.FunctionList.SubSectorID;
                if (SubSectorID == 000 || SubSectorID == 0)
                {
                    SubSectorID = null;
                }
                else
                {
                    SubSectorID = model.FunctionList.SubSectorID;
                }

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

                switch (save)
                {
                case true:
                    switch (model.ActionID)
                    {
                    case 1:
                        Tbl_FMRes_Function functionAdd = new Tbl_FMRes_Function();
                        functionAdd.FunctionTitle      = FunctionTitle;
                        functionAdd.FunctionAbbrv      = FunctionAbbrv;
                        functionAdd.FunctionCode       = FunctionCode;
                        functionAdd.DeptOfficeCodefunc = DeptOfficeCodefunc;
                        functionAdd.SectorID           = SectorID;
                        functionAdd.SubSectorID        = SubSectorID;
                        functionAdd.OfficeTypeID       = OfficeTypeID;
                        functionAdd.DeptID             = DeptID;

                        BOSSDB.Tbl_FMRes_Function.Add(functionAdd);
                        BOSSDB.SaveChanges();
                        isExist = "false";
                        break;

                    case 2:
                        functionRecord.FunctionTitle      = FunctionTitle;
                        functionRecord.FunctionAbbrv      = FunctionAbbrv;
                        functionRecord.FunctionCode       = FunctionCode;
                        functionRecord.DeptOfficeCodefunc = DeptOfficeCodefunc;
                        functionRecord.SectorID           = SectorID;
                        functionRecord.SubSectorID        = SubSectorID;
                        functionRecord.OfficeTypeID       = OfficeTypeID;
                        functionRecord.DeptID             = DeptID;

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

                default:
                    isExist = "true";
                    break;
                }
            }
            return(new JsonResult()
            {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                Data = new { isExist = isExist }
            });
        }
예제 #6
0
        public ActionResult GetFuncForm(int ActionID, int FunctionID)
        {
            FunctionModel model = new FunctionModel();

            if (ActionID == 2)
            {
                Tbl_FMRes_Function funcTbl = (from a in BOSSDB.Tbl_FMRes_Function where a.FunctionID == FunctionID select a).FirstOrDefault();
                model.FunctionList.FunctionTitle = funcTbl.FunctionTitle;
                model.FunctionList.FunctionAbbrv = funcTbl.FunctionAbbrv;
                model.FunctionList.FunctionCode  = funcTbl.FunctionCode;
                model.FunctionList.SectorID      = GlobalFunction.ReturnEmptyInt(funcTbl.SectorID);
                model.FunctionList.SubSectorID   = GlobalFunction.ReturnEmptyInt(funcTbl.SubSectorID);
                model.FunctionList.OfficeTypeID  = GlobalFunction.ReturnEmptyInt(funcTbl.OfficeTypeID);
                model.FunctionList.DeptID        = GlobalFunction.ReturnEmptyInt(funcTbl.DeptID);
                model.FunctionList.FundTitle     = GlobalFunction.ReturnEmptyString(funcTbl.Tbl_FMRes_Department.Tbl_FMFund_Fund.FundTitle);

                model.FunctionList.DeptOfficeCodefunc = funcTbl.DeptOfficeCodefunc;
                model.FunctionList.FunctionID         = funcTbl.FunctionID;

                var getSubSector = (from a in BOSSDB.Tbl_FMSector_SubSector where a.SectorID == model.FunctionList.SectorID select a).ToList();
                foreach (var item in getSubSector)
                {
                    model.SubSectorList.Add(new SelectListItem()
                    {
                        Text = item.SubSectorTitle, Value = item.SubSectorID.ToString()
                    });
                }
                model.SubSectorList.Add(new SelectListItem()
                {
                    Text = "N/A", Value = "0"
                });
            }
            else
            {
                var firstSector  = (from a in BOSSDB.Tbl_FMSector_Sector orderby a.SectorTitle select a).FirstOrDefault();
                var getSubSector = (from a in BOSSDB.Tbl_FMSector_SubSector where a.SectorID == firstSector.SectorID select a).ToList();
                foreach (var item in getSubSector)
                {
                    model.SubSectorList.Add(new SelectListItem()
                    {
                        Text = item.SubSectorTitle, Value = item.SubSectorID.ToString()
                    });
                }
                model.SubSectorList.Add(new SelectListItem()
                {
                    Text = "N/A", Value = "000"
                });
                var getFirstDept = (from a in BOSSDB.Tbl_FMRes_Department orderby a.DeptTitle select a).FirstOrDefault();
                if (getFirstDept != null)
                {
                    model.FunctionList.FundTitle          = getFirstDept.Tbl_FMFund_Fund.FundTitle;
                    model.FunctionList.DeptOfficeCodefunc = getFirstDept.DeptOfficeCode;
                }
            }

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

            model.SectorList = new SelectList(BOSSDB.Tbl_FMSector_Sector, "SectorID", "SectorTitle");
            model.SectorList = (from li in model.SectorList orderby li.Text select li).ToList();

            model.OfficeTypeList = new SelectList(BOSSDB.Tbl_FMOfficeType, "OfficeTypeID", "OfficeTypeTitle");
            model.OfficeTypeList = (from li in model.OfficeTypeList orderby li.Text select li).ToList();



            model.ActionID = ActionID;

            return(PartialView("FunctionTab/_FuncForm", model));
        }