public ActionResult AddNewTelephoneUser(TelephoneUserInfo aTelephoneUserInfo)
        {
            if (aTelephoneUserInfo.RankID == null)
            {
                ViewData["Message"] = "Error! Please Set All Fields";
                ViewData["TelephoneUserInfo"] = aTelephoneUserInfo;
                return View("Index");
            }
            if (aTelephoneUserInfo.BANumber.Trim().Length == 0
                || aTelephoneUserInfo.Appointment.Trim().Length == 0
                || aTelephoneUserInfo.EmailAddress.Trim().Length == 0
                || aTelephoneUserInfo.FullName.Trim().Length == 0
                || aTelephoneUserInfo.JoiningDate.ToString("yyyy-MM-dd") == "0001-01-01"
                || aTelephoneUserInfo.MaritalStatus.Trim().Length == 0
                || aTelephoneUserInfo.OfficeAddress.Trim().Length == 0
                || aTelephoneUserInfo.PermanentAddress.Trim().Length == 0
                || aTelephoneUserInfo.PlateName.Trim().Length == 0
                || aTelephoneUserInfo.PresentAddress.Trim().Length == 0
                || aTelephoneUserInfo.RankID.Trim().Length == 0
                || aTelephoneUserInfo.ServiceStatus.Trim().Length == 0
                || aTelephoneUserInfo.Sex.Trim().Length == 0
                || aTelephoneUserInfo.Unit.Trim().Length == 0)

            {

                ViewData["Message"] = "Error! Please Set All Fields";
                ViewData["TelephoneUserInfo"] = aTelephoneUserInfo;
                return View("Index");
            }

            if (aTelephoneUserInfo.ServiceStatus.Trim().ToLower() == "LPR"
                && aTelephoneUserInfo.LPRDate.ToString("yyyy-MM-dd") == "0001-01-01")
            {
                ViewData["Message"] = "Error! Please Set LPR Date Fields";
                ViewData["TelephoneUserInfo"] = aTelephoneUserInfo;
                return View("Index");
            }

            TelephoneUser aUser = new TelephoneUser();
            string message = aUser.AddTelephoneUser(aTelephoneUserInfo);

            ViewData["Message"] = message;
            ViewData["TelephoneUserInfo"] = aTelephoneUserInfo;
            return View("Index");
        }
        public ActionResult GetActiveTelephoneUsers(JQueryDataTableParamModel aModel)
        {
            TelephoneUser aUser = new TelephoneUser();
            int totalRecords = 0;
            int filteredRecord = 0;

            string baNumber = Convert.ToString(Request["sSearch_0"]);
            string name = Convert.ToString(Request["sSearch_1"]);
            string palteName = Convert.ToString(Request["sSearch_2"]);
            string rank = Convert.ToString(Request["sSearch_3"]);

            List<string[]> allUsers = aUser.GetAllTelephoneUser(out totalRecords,out filteredRecord,aModel.iDisplayStart,aModel.iDisplayLength,baNumber,name,palteName,rank);
            return Json(new
            {
                sEcho = aModel.sEcho,
                iTotalRecords = filteredRecord,
                iTotalDisplayRecords = totalRecords,
                aaData = allUsers
            }, JsonRequestBehavior.AllowGet);
        }
        public ActionResult SearchRequestNewForm()
        {
            string baNumber = Request["BANumberSearch"].Trim().ToString();
            string reqType = Request["reqType"].Trim().ToString();
            string addressType = Request["AddressType"].Trim().ToString();
            string connectionType = Request["ConnectionType"].Trim().ToString();
            if (baNumber.Length == 0 || reqType.Length == 0 || reqType == "--Request Type--")
            {
                ViewData["Message"] = "Error! Complete Search Fields";
                ViewData["baNumber"] = baNumber;
                ViewData["reqType"] = reqType;
                ViewData["addressType"] = addressType;
                ViewData["connectionType"] = connectionType;

                return View("Index");
            }

            TelephoneNumber aTelephoneNumber = new TelephoneNumber();
            TelephoneUser aUser = new TelephoneUser();
            TelephoneUserInfo aInfo = aUser.GetTelephoneUserInfo(baNumber);

            if (aInfo.BANumber == null)
            {
                string url = UtilityLibrary.GetBaseURL() + "TelephoneUser/AddTelephoneUser";
                ViewData["Message"] = "Error! Telephone User not found. To Add Telephone User Click <a href=\""+url+"\" style=\"color: blue;\">Here</a>";
                ViewData["baNumber"] = baNumber;
                ViewData["reqType"] = reqType;
                ViewData["addressType"] = addressType;
                ViewData["connectionType"] = connectionType;
                return View("Index");
            }

            ViewData["UserInfo"] = aInfo;
            ViewData["AddressType"] = addressType;
            ViewData["ConnectionType"] = connectionType;

            if (reqType == "1")
            {
                if (addressType == "Office")
                {
                    ViewData["Address"] = aInfo.OfficeAddress;
                }
                else
                {
                    ViewData["Address"] = aInfo.PresentAddress;
                }
                ViewData["RequestType"] = "New Connection";
                ViewData["AvailableNumbers"] = aTelephoneNumber.GetAvailableTelephoneNumberForNewConnection(connectionType);
                ViewData["baNumber"] = baNumber;
                ViewData["reqType"] = reqType;
                ViewData["addressType"] = addressType;
                ViewData["connectionType"] = connectionType;
                return View("Index");
            }
            if (reqType == "2")
            {
                if (addressType == "Office")
                {
                    ViewData["Address"] = aInfo.OfficeAddress;
                }
                else
                {
                    ViewData["Address"] = aInfo.PresentAddress;
                }
                ViewData["RequestType"] = "Shifting";
                ViewData["AvailableNumbers"] = aTelephoneNumber.GetAllotedNumbersForExistingUser(connectionType,addressType,baNumber);
                ViewData["baNumber"] = baNumber;
                ViewData["reqType"] = reqType;
                ViewData["addressType"] = addressType;
                ViewData["connectionType"] = connectionType;
                return View("Index");
            }
            if (reqType == "3")
            {
                if (addressType == "Office")
                {
                    ViewData["Address"] = aInfo.OfficeAddress;
                }
                else
                {
                    ViewData["Address"] = aInfo.PresentAddress;
                }
                ViewData["RequestType"] = "Termination";
                ViewData["AvailableNumbers"] = aTelephoneNumber.GetAllotedNumbersForExistingUser(connectionType, addressType, baNumber);
                ViewData["baNumber"] = baNumber;
                ViewData["reqType"] = reqType;
                ViewData["addressType"] = addressType;
                ViewData["connectionType"] = connectionType;
                return View("Index");
            }

            ViewData["baNumber"] = baNumber;
            ViewData["reqType"] = reqType;
            ViewData["addressType"] = addressType;
            ViewData["connectionType"] = connectionType;
            return View("Index");
        }