public ActionResult GetBrgyNameDTable()
        {
            BrgyNameModel           model = new BrgyNameModel();
            List <BarangayNameList> getBarangayNameList = new List <BarangayNameList>();
            var SQLQuery = "SELECT * FROM [Tbl_FMBrgy_Barangay]";

            using (SqlConnection Connection = new SqlConnection(GlobalFunction.ReturnConnectionString()))
            {
                Connection.Open();
                using (SqlCommand command = new SqlCommand("[dbo].[SP_Brgy]", Connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add(new SqlParameter("@SQLStatement", SQLQuery));
                    SqlDataReader dr = command.ExecuteReader();
                    while (dr.Read())
                    {
                        getBarangayNameList.Add(new BarangayNameList()
                        {
                            BrgyID   = GlobalFunction.ReturnEmptyInt(dr[0]),
                            BrgyName = GlobalFunction.ReturnEmptyString(dr[1])
                        });
                    }
                }
                Connection.Close();
            }
            model.getBarangayNameList = getBarangayNameList.ToList();
            return(PartialView("BrgyNameTab/_TableBrgyName", getBarangayNameList));
        }
        public ActionResult SaveBrgyName(BrgyNameModel model)
        {
            var isExist = "";

            if (ModelState.IsValid)
            {
                var brgyname = model.BarangayNameList.BrgyName;

                Tbl_FMBrgy_Barangay checkbrgy = (from a in BOSSDB.Tbl_FMBrgy_Barangay where (a.BrgyName == brgyname) select a).FirstOrDefault();

                if (model.ActionID == 1)
                {
                    if (checkbrgy == null)
                    {
                        Tbl_FMBrgy_Barangay brgy = new Tbl_FMBrgy_Barangay();
                        brgy.BrgyName = brgyname;
                        BOSSDB.Tbl_FMBrgy_Barangay.Add(brgy);
                        BOSSDB.SaveChanges();
                        isExist = "false";
                    }
                    else if (checkbrgy != null)
                    {
                        isExist = "true";
                    }
                }
                else if (model.ActionID == 2)
                {
                    Tbl_FMBrgy_Barangay        bgryii    = (from a in BOSSDB.Tbl_FMBrgy_Barangay where a.BrgyID == model.BarangayNameList.BrgyID select a).FirstOrDefault();
                    List <Tbl_FMBrgy_Barangay> brgyCount = (from e in BOSSDB.Tbl_FMBrgy_Barangay where e.BrgyName == brgyname select e).ToList();
                    if (checkbrgy != null)
                    {
                        if (bgryii.BrgyName != brgyname && brgyCount.Count >= 1)
                        {
                            isExist = "true";
                        }
                        else
                        {
                            isExist = "justUpdate";
                        }
                    }
                    else if (checkbrgy == null)
                    {
                        isExist = "justUpdate";
                    }

                    if (isExist == "justUpdate")
                    {
                        bgryii.BrgyName = brgyname;
                        BOSSDB.Entry(bgryii);
                        BOSSDB.SaveChanges();
                    }
                }
            }
            return(new JsonResult()
            {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                Data = new { isExist = isExist }
            });
        }
        public ActionResult GetBrgyNameForm(int ActionID, int PrimaryID)
        {
            BrgyNameModel model = new BrgyNameModel();

            if (ActionID == 2)
            {
                var brgy = (from a in BOSSDB.Tbl_FMBrgy_Barangay where a.BrgyID == PrimaryID select a).FirstOrDefault();
                model.BarangayNameList.BrgyID   = brgy.BrgyID;
                model.BarangayNameList.BrgyName = brgy.BrgyName;
            }
            model.ActionID = ActionID;
            return(PartialView("BrgyNameTab/_BrgyNameForm", model));
        }
        //---------------------------------------------------------------------------------------------------------------------
        //Barangay Name Tab
        //---------------------------------------------------------------------------------------------------------------------
        public ActionResult GetBrgyNameTab()
        {
            BrgyNameModel model = new BrgyNameModel();

            return(PartialView("BrgyNameTab/IndexBrgyName", model));
        }
        // GET: FileMaintenanceBarangay
        public ActionResult FileBarangay()
        {
            BrgyNameModel model = new BrgyNameModel();

            return(View(model));
        }