Example #1
0
        public string AddTelephoneUser(TelephoneUserInfo aTelephoneUserInfo)
        {
            if (!IsBANumberUnique(aTelephoneUserInfo))
            {
                return "Error! BANumber Already Exist In Database";
            }

            InsertDataInfoDatabase(aTelephoneUserInfo);

            return "Telephone User Successfully Added";
        }
        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");
        }
Example #3
0
        public TelephoneUserInfo GetTelephoneUserInfo(string baNumber)
        {
            TelephoneUserInfo aInfo = new TelephoneUserInfo();
            string query =
                "select * from phoneuserpersonalinfo " +
                "left join menusrank on menusrank.id = phoneuserpersonalinfo.RankId " +
                "where phoneuserpersonalinfo.BANumber='"+baNumber+"';";

            DataSet aSet = aGateway.Select(query);
            foreach (DataRow dataRow in aSet.Tables[0].Rows)
            {
                aInfo.Id = Convert.ToInt32(dataRow["ID"].ToString().Trim());
                aInfo.BANumber = dataRow["BANumber"].ToString().Trim();
                aInfo.FullName = dataRow["FullName"].ToString().Trim();
                aInfo.RankID = dataRow["Value"].ToString().Trim();
                aInfo.OfficeAddress = dataRow["OfficeAddress"].ToString().Trim();
                aInfo.PresentAddress = dataRow["PresentAddress"].ToString().Trim();

            }
            return aInfo;
        }
Example #4
0
        private bool IsBANumberUnique(TelephoneUserInfo aTelephoneUserInfo)
        {
            string query = "select * from phoneuserpersonalinfo where BANumber='" + aTelephoneUserInfo.BANumber + "';";

            if (aGateway.Select(query).Tables[0].Rows.Count == 0)
            {
                return true;
            }
            return false;
        }
Example #5
0
        private void InsertDataInfoDatabase(TelephoneUserInfo aTelephoneUserInfo)
        {
            string nonQuery = "INSERT INTO `phoneuserpersonalinfo` " +
                              "(`BANumber`, `FullName`, `Appointment`, `PlateName`, `ServiceStatus`, " +
                              "`RankId`, `Sex`, `Unit`, `JoiningDate`, `LPRDate`, `MaritalStatus`, " +
                              "`PresentAddress`, `PermanentAddress`, `OfficeAddress`, `PersonalPhoneNumber`, " +
                              "`EmailAddress`) VALUES " +
                              "(@BANumber, @FullName, @Appointment, @PlateName, @ServiceStatus, " +
                              "@RankId, @Sex, @Unit, @JoiningDate, @LPRDate, @MaritalStatus, " +
                              "@PresentAddress, @PermanentAddress, @OfficeAddress, @PersonalPhoneNumber, " +
                              "@EmailAddress);";
            Hashtable aHashtable = new Hashtable()
            {
                {"BANumber", aTelephoneUserInfo.BANumber},
                {"FullName", aTelephoneUserInfo.FullName},
                {"Appointment", aTelephoneUserInfo.Appointment},
                {"PlateName", aTelephoneUserInfo.PlateName},
                {"ServiceStatus", aTelephoneUserInfo.ServiceStatus},
                {"RankId", aTelephoneUserInfo.RankID},
                {"Sex", aTelephoneUserInfo.Sex},
                {"Unit", aTelephoneUserInfo.Unit},
                {"JoiningDate", aTelephoneUserInfo.JoiningDate.ToString("yyyy-MM-dd")},
                {"LPRDate", aTelephoneUserInfo.LPRDate.ToString("yyyy-MM-dd")},
                {"MaritalStatus", aTelephoneUserInfo.MaritalStatus},
                {"PresentAddress", aTelephoneUserInfo.PresentAddress},
                {"PermanentAddress", aTelephoneUserInfo.PermanentAddress},
                {"OfficeAddress", aTelephoneUserInfo.OfficeAddress},
                {"PersonalPhoneNumber", aTelephoneUserInfo.PersonalPhoneNumber},
                {"EmailAddress", aTelephoneUserInfo.EmailAddress},
            };

            aGateway.Insert(nonQuery, aHashtable);
        }