public static bool delete(long id)
        {
            db = new SMSDataClassesDataContext();
            var x = (from i in db.SMS_ReceivedMsgs.Where(i => i.Id == id) select i).Take(1).FirstOrDefault();

            try
            {
                db.SMS_ReceivedMsgs.DeleteOnSubmit(x);
                db.SubmitChanges();
                config.log("Successful deleted in inbox");
                return true;
            }
            catch (Exception ex)
            {
                config.log(ex.Message);
                return false;
            }
        }
        public static bool save(string number, string message)
        {
            if (message != "OK")
            {
                db = new SMSDataClassesDataContext();
                SMS_QueuedBox que = new SMS_QueuedBox();
                que.Message = config.encrypt(message);
                que.Number = number;
                que.Network = (short)config.prefixes(number);
                que.Status = false;

                try
                {
                    db.SMS_QueuedBoxes.InsertOnSubmit(que);
                    db.SubmitChanges();
                    return true;
                }
                catch (Exception ex)
                {
                    config.log(ex.Message);
                }
            }
            return false;
        }
        public static bool save(string number, string message)
        {
            db = new SMSDataClassesDataContext();
            SMS_Inbox inbox = new SMS_Inbox();
            SMS_ReceivedMsg receivedMsg = new SMS_ReceivedMsg();

            inbox.Sender = number;
            inbox.Message = message;
            inbox.DateReceived = config.receivedDateTime();
            inbox.MonthOf = DateTime.Now.Month;
            inbox.YearOf = DateTime.Now.Year;
            inbox.Status = false;

            receivedMsg.Sender = number;
            receivedMsg.Message = message;
            receivedMsg.DateReceived = config.receivedDateTime();
            receivedMsg.MonthOf = DateTime.Now.Month;
            receivedMsg.YearOf = DateTime.Now.Year;
            receivedMsg.Status = false;

            validatorMessage.save(number, "Sorry, your message cannot be processed at this time, " +
                    "but your message is on queue. and it will process later. thank you!");

            try
            {
                db.SMS_Inboxes.InsertOnSubmit(inbox);
                db.SMS_ReceivedMsgs.InsertOnSubmit(receivedMsg);
                db.SubmitChanges();
                return true;
            }
            catch (Exception ex)
            {
                config.log(ex.Message);
                return false;
            }
        }
        public static bool saveToSentItemThenDelete(long id, bool status)
        {
            db = new SMSDataClassesDataContext();
            SMS_SentItem sentItems = new SMS_SentItem();
            var x = (from i in db.SMS_QueuedBoxes.Where(i => i.ID == id) select i).Take(1).FirstOrDefault();
            if (x != null)
            {
                sentItems.Number = x.Number;
                sentItems.Message = x.Message;
                sentItems.DateTime = config.receivedDateTime();
                sentItems.Status = status;
                sentItems.MonthOf = DateTime.Now.Month;
                sentItems.YearOf = DateTime.Now.Year;

                try
                {
                    db.SMS_SentItems.InsertOnSubmit(sentItems);
                    db.SMS_QueuedBoxes.DeleteOnSubmit(x);
                    db.SubmitChanges();
                    config.log("Successful updated in inbox");
                    return true;
                }
                catch (Exception ex)
                {
                    config.log(ex.Message);
                }
            }
            return false;
        }
        public static string Registration(string number, string input)
        {
            db = new SMSDataClassesDataContext();
            string returnMessage = replyMessage("NREG", "NOK0");

            if (checkNumber(number))
            {
                return "Oop, Your number already exist to our record!Pleas try a new number";
            }

            if (checkCode(populate(input)))
            {
                string refCode = "CIA" + config.generateReferenceNo(4) + "-" + DateTime.Now.Year;
                SMS_Member m = new SMS_Member();
                m.ReferenceNo = refCode;
                m.Group_Name = "BAYANIHAN";
                m.Account_Number = number;
                m.Family_Name = Lastname;
                m.First_Name = Firstname;
                m.Town = Town;
                m.Sponsor_ID = Sponsor;
                m.CP_Number  = number;
                m.DateReg = config.receivedDateTime();
                m.Status = true;
                m.monthOf = DateTime.Now.Month;
                m.yearOf = DateTime.Now.Year;

                SMS_eMoney e = new SMS_eMoney();
                e.Account = number;
                e.Amount = 100;
                e.Status = true;

                if (!checkRef(refCode))
                {
                    try
                    {
                        db.SMS_Members.InsertOnSubmit(m);
                        db.SMS_eMoneys.InsertOnSubmit(e);
                        db.SubmitChanges();
                        returnMessage = replyMessage("NREG", "OK", Firstname);
                    }
                    catch (Exception ex)
                    {
                        return "Sorry, our system has encountered an error, please try again later. thank you!";
                    }
                }
                else
                {
                    returnMessage = replyMessage("NREG", "NOK1");
                }
            }
            return returnMessage;
        }