Beispiel #1
0
    Int32 DisplayBrands(string BrandFilter)
    {
        Int32  PhoneNo;   //var to store the primary key
        string PhoneName; //var to store the PhoneName
        string Brand;     // var to store the Brand

        ;                 //create an instance of the phone book class
        clsPhoneCollection PhoneBook = new clsPhoneCollection();

        PhoneBook.FilterByBrand(BrandFilter);                 //filter by brand
        Int32 RecordCount;                                    //var store the count of records
        Int32 Index = 0;                                      //var to store the index for the loop

        RecordCount = PhoneBook.Count;                        //get the count of records
        lstPhones.Items.Clear();                              //clear the list box
        while (Index < RecordCount)                           //while there are records to process
        {
            PhoneNo   = PhoneBook.PhoneList[Index].PhoneNo;   //get the primary key
            PhoneName = PhoneBook.PhoneList[Index].PhoneName; //get the phonename
            Brand     = PhoneBook.PhoneList[Index].Brand;     //get the brand
            //create a new entry for the list box
            ListItem NewEntry = new ListItem(Brand + " " + PhoneName, PhoneNo.ToString());
            lstPhones.Items.Add(NewEntry); // add the phone to the list
            Index++;                       // move the index to the next record
        }
        return(RecordCount);
    }
        private async void RegisterAction()
        {
            RollNo  = RollNo.Trim();
            PhoneNo = PhoneNo.Trim();
            if (string.IsNullOrWhiteSpace(Password))
            {
                _dialog.ShowMessage("Error", "Invalid Password");
            }
            else if (Password.Length < 8)
            {
                _dialog.ShowMessage("Error", "Password must be at least 8digit");
            }
            else if (Password != ConfirmPassword)
            {
                _dialog.ShowMessage("Error", "Password does not match");
            }
            else
            {
                var res = await _memberHandler.Register(RollNo, PhoneNo, Password);

                if (res != null)
                {
                    _dialog.ShowToastMessage(res.Message);
                    _nav.GoBack();
                }
            }
        }
Beispiel #3
0
        void AssignPhoneMain(StringBuilder segment, PhoneNo phone)
        {
            ParserPattern _pattern      = context.Pattern;
            char          separator     = ' ';
            int           bSeparatorLen = 0;

            if (_pattern == ParserPattern.NorthAmerica)
            {
                separator = '-';
            }
            if (phone.Main == null)
            {
                phone.Main = segment.ToString();
            }
            else if (phone.Main.Length < 5)
            {
                phone.Main   += separator + segment.ToString();
                bSeparatorLen = 1;
            }
            if (IsMobileNo(phone.Main, _pattern))
            {
                phone.IsMobile = true;
            }
            else
            {
                //非手机号码,8位
                if (_pattern == ParserPattern.China && phone.Main.Length > 8 + bSeparatorLen)
                {
                    phone.Main = null;
                }
            }
        }
Beispiel #4
0
 public override string ToString()
 {
     return(base.ToString() + ": "
            + "[User Id:" + UserId.ToString()
            + "], [Name:" + Name.ToString()
            + "], [Age:" + Age.ToString()
            + "], [Email:" + Email.ToString()
            + "], [PhoneNo:" + PhoneNo.ToString() + "]");
 }
Beispiel #5
0
 private void Clear_Click(object sender, EventArgs e)
 {
     //Clear all the textboxes
     PhoneNo.Clear();
     Address.Clear();
     Email.Clear();
     CustName.Clear();
     CustomerName.Clear();
     CustID.Clear();
 }
Beispiel #6
0
 protected override void Packet()
 {
     SetString(0, "0100");
     SetString(3, "310000");
     SetString(11, GetTraceNo());
     SetString(25, "81");
     SetString(48, "TT" + "CC" + MiddleFlowNo.PadRight(12, ' ') +
               PhoneNo.PadRight(20, ' ') + "#");
     SetString(49, "156");
 }
Beispiel #7
0
        void AssertPhoneValue(ParseResult pr, string countrycode, string citycode, string main, string extension, bool isMobile)
        {
            Assert.AreEqual(pr.Value.GetType(), typeof(PhoneNo));
            PhoneNo value = (PhoneNo)pr.Value;

            Assert.AreEqual(countrycode, value.CountryCode);
            Assert.AreEqual(citycode, value.AreaCode);
            Assert.AreEqual(main, value.Main);
            Assert.AreEqual(extension, value.Extension);
            Assert.AreEqual(isMobile, value.IsMobile);
        }
Beispiel #8
0
 protected override void Packet()
 {
     SetString(0, "0320");
     SetString(3, "290000");
     SetString(11, GetTraceNo());
     SetString(15, Field15);
     SetString(37, PayReferenceNo);
     SetString(48, "QR" + "CC" +
               MobileType + PhoneNo.PadRight(20, ' ') + MiddleFlowNo.PadRight(12, ' ') + "#");
     SetString(60, "00" + GetBatchNo() + "362");
 }
        public CustomerCreate()
        {
            _customer = new Domain.Customer.Customer(
                new CustomerId(Guid.NewGuid()),
                FullName.FromString("ST Skolebyg"),
                Adresse.FromString("Vardevej 98", 7100, "Vejle"),
                PhoneNo.FromInt(22222222),
                Email.FromString("*****@*****.**"),
                CustomerType.FromString(1.ToString())

                );
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (text_Name.Text != string.Empty && Father_name.Text != string.Empty && DOB.Text != string.Empty && CNIC.Text != string.Empty && PhoneNo.Text != string.Empty && genderCombo.Text != string.Empty && textBox_Address.Text != string.Empty && height.Text != string.Empty && textBox_diseases.Text != string.Empty && BGroup.Text != string.Empty && donated_Date.Text != string.Empty)
            {
                try
                {
                    if (Donated_YES_rbtn.Checked == true)
                    {
                        database.con.Open();
                        SqlCommand csd = new SqlCommand("insert into Donor values('" + text_Name.Text + "','" + Father_name.Text + "','" + DOB.Text + "','" + CNIC.Text + "','" + PhoneNo.Text + "','" + genderCombo.Text + "','" + textBox_Address.Text + "','" + height.Text.ToString() + "','" + textBox_diseases.Text + "','" + BGroup.Text + "','" + Donated_YES_rbtn.Text + "','" + donated_Date.Text + "');", database.con);
                        csd.ExecuteNonQuery();
                        database.con.Close();
                        listboxdata();
                        MessageBox.Show("Info Added", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    else
                    {
                        database.con.Open();
                        SqlCommand csd = new SqlCommand("insert into Donor values('" + text_Name.Text + "','" + Father_name.Text + "','" + DOB.Text + "','" + CNIC.Text + "','" + PhoneNo.Text + "','" + genderCombo.Text + "','" + textBox_Address.Text + "','" + height.Text.ToString() + "','" + textBox_diseases.Text + "','" + BGroup.Text + "','" + Donated_NO_rbtn.Text + "','" + donated_Date.Text + "');", database.con);
                        csd.ExecuteNonQuery();
                        database.con.Close();
                        listboxdata();
                        MessageBox.Show("Info Added", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    text_Name.ResetText();
                    DOB.ResetText();
                    Father_name.ResetText();
                    textBox_diseases.ResetText();
                    textBox_Address.ResetText();
                    BGroup.ResetText();
                    CNIC.ResetText();
                    PhoneNo.ResetText();
                    height.ResetText();
                    ID.Text = "ID: ------";
                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    database.con.Close();
                }
            }
            else
            {
                MessageBox.Show("Fill All Fields", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private void button2_Click(object sender, EventArgs e)
 {
     text_Name.ResetText();
     DOB.ResetText();
     Father_name.ResetText();
     textBox_diseases.ResetText();
     textBox_Address.ResetText();
     BGroup.ResetText();
     CNIC.ResetText();
     PhoneNo.ResetText();
     height.ResetText();
     ID.Text          = "ID: ------";
     genderCombo.Text = "";
 }
Beispiel #12
0
        public void Test_ExtractClass_ReFac_Case1()
        {
            string privateNo = "12345678";
            string workNo    = "+3487654321";

            _beforePerson = new ReFac.Simple.ExtractClass.Before.Person("Jim", privateNo, workNo);

            PhoneNo privatePhoneNo = new PhoneNo(privateNo);
            PhoneNo workPhoneNo    = new PhoneNo(workNo);

            _afterPerson = new ReFac.Simple.ExtractClass.After.Person("Jim", privatePhoneNo, workPhoneNo);

            Assert.AreEqual(_beforePerson.PrivatePhoneNo, _afterPerson.PrivatePhoneNo);
            Assert.AreEqual(_beforePerson.WorkPhoneNo, _afterPerson.WorkPhoneNo);
        }
Beispiel #13
0
        public Task Handle(object command)
        {
            return(command switch
            {
                V1.RegisterCustomer cmd =>
                HandleCreate(cmd),
                V1.UpdateCustomerFullName cmd =>
                HandleUpdate(cmd.CustomerId, profile => profile.UpdateName(FullName.FromString(cmd.FullName))),

                V1.UpdateCustomerEmail cmd =>
                HandleUpdate(
                    cmd.CustomerId,
                    profile => profile.UpdateEmail(
                        Email.FromString(cmd.Email)
                        )
                    ),
                V1.UpdateCustomerAdresse cmd =>
                HandleUpdate(
                    cmd.CustomerId,
                    profile => profile.UpdateAdresse(
                        new Adresse(Street.FromString(cmd.Street), ZipCode.FromInt(cmd.ZipCode), City.FromString(cmd.City))
                        )
                    ),
                V1.ChangeCustomerType cmd =>
                HandleUpdate(
                    cmd.CustomerId,
                    profile => profile.ChangeCustomerType(
                        CustomerType.FromString(cmd.CustomerType.ToString())
                        )
                    ),
                V1.UpdateCustomerPhoneNo cmd =>
                HandleUpdate(
                    cmd.CustomerId,
                    profile => profile.UpdatePhoneNo(
                        PhoneNo.FromInt(cmd.PhoneNo)
                        )
                    ),

                V1.DeleteCustomer cmd =>
                HandleUpdate(
                    cmd.CustomerId,
                    profile => profile.DeleteCustomer(
                        IsDeleted.FromBool(cmd.IsDeleted)
                        )
                    ),
                _ => Task.CompletedTask
            });
Beispiel #14
0
        public void Test_ExtractClass_ReFac_Case3()
        {
            string privateNo = "12345678";
            string workNo    = "-3487654321"; // NB: INVALID

            Assert.ThrowsException <ArgumentException>(() =>
            {
                _beforePerson = new ReFac.Simple.ExtractClass.Before.Person("Jim", privateNo, workNo);
            });

            Assert.ThrowsException <ArgumentException>(() =>
            {
                PhoneNo privatePhoneNo = new PhoneNo(privateNo);
                PhoneNo workPhoneNo    = new PhoneNo(workNo);
                _afterPerson           = new ReFac.Simple.ExtractClass.After.Person("Jim", privatePhoneNo, workPhoneNo);
            });
        }
 private void SetRandomPhoneNo()
 {
     PhoneNo.Clear();
     PhoneNo.SendKeys(Data.RandomValuesGenerator.RandomNumber(10));
 }
Beispiel #16
0
 public Contact GetContactByPhoneNumber(PhoneNo phoneNo)
 {
     return(Repository.GetAnyElements(x => x.PhoneNumber.Prefix.Equals(phoneNo.Prefix) &&
                                      x.PhoneNumber.PhoneNumber.Equals(phoneNo.PhoneNumber)).FirstOrDefault());
 }
 public void Cannot_update_with_wrong_PhoneNo()
 {
     Assert.Throws <System.ArgumentNullException>(() => _customer.UpdatePhoneNo(PhoneNo.FromInt(0)));
 }
Beispiel #18
0
        public ParseResultCollection Parse(int startIndex)
        {
            string                _text    = context.Text;
            ParserPattern         _pattern = context.Pattern;
            int                   k        = startIndex;
            char                  ch;
            StringBuilder         sb  = new StringBuilder(10);
            ParseResultCollection prc = new ParseResultCollection();

            if (_text[startIndex] == ' ' || _text[startIndex] == ' ')
            {
                return(prc);
            }

            int braceStartPos = -1;

            while (k < _text.Length)
            {
                ch = _text[k];
                if (!IsAllowedChar(ch, _pattern))
                {
                    break;
                }
                if (ch >= '0' && ch <= '9')
                {
                    ch = (char)(ch - '0' + '0');
                }
                if (ch == ' ')
                {
                    ch = ' ';
                }
                else if (ch == '(')
                {
                    ch = '(';
                }
                else if (ch == ')')
                {
                    ch = ')';
                }
                else if (ch == '-' || ch == '—')
                {
                    ch = '-';
                }

                if (ch == '(')
                {
                    braceStartPos = k;
                }
                else if (ch == ')')
                {
                    braceStartPos = -1;
                }
                sb.Append(ch);
                k++;
            }
            string allowedString = sb.ToString().TrimEnd();

            if (braceStartPos >= 0)
            {
                allowedString = allowedString.Substring(0, braceStartPos);
            }

            if (allowedString.Length < 3 || allowedString.Length == 4)
            {
                return(prc);
            }

            bool bNumberInBrace      = false;
            bool bCountryCodeStarted = false;
            bool bAreaCodeStarted    = false;
            bool bExtStarted         = false;
            int  i = 0;

            StringBuilder segment = new StringBuilder();
            StringBuilder whole   = new StringBuilder();

            PhoneNo phone = new PhoneNo();

            if (_pattern == ParserPattern.China)
            {
                while (i < allowedString.Length)
                {
                    ch = allowedString[i];
                    if (ch == '(')
                    {
                        bNumberInBrace      = true;
                        bCountryCodeStarted = false;
                        whole.Append(ch);
                    }
                    else if (NumeralUtil.IsArabicNumeral(ch))
                    {
                        if (segment.Length == 0 && !bAreaCodeStarted &&
                            phone.AreaCode == null && !bCountryCodeStarted)
                        {
                            bAreaCodeStarted = true;
                        }

                        segment.Append(ch);
                        whole.Append(ch);
                    }
                    else if (ch == ')' && bNumberInBrace)
                    {
                        if (bCountryCodeStarted)
                        {
                            if (segment.Length > 0)
                            {
                                phone.CountryCode = segment.ToString();
                            }
                            bCountryCodeStarted = false;
                        }
                        if (bAreaCodeStarted)
                        {
                            if (segment.Length > 0 && (segment[0] == '0' ? segment.Length <= 4 : segment.Length <= 3))  //城市代码以0开头,最多4个数字;不以0开头,三个数字
                            {
                                phone.AreaCode = segment.ToString();
                            }
                            bAreaCodeStarted = false;
                        }
                        whole.Append(ch);
                        segment        = new StringBuilder();
                        bNumberInBrace = false;
                    }
                    else if (ch == ' ')
                    {
                        if (bCountryCodeStarted)
                        {
                            if (segment.Length > 0)
                            {
                                phone.CountryCode = segment.ToString();
                            }
                            bCountryCodeStarted = false;
                        }
                        else if (bAreaCodeStarted)
                        {
                            if (segment.Length > 0)
                            {
                                phone.AreaCode = segment.ToString();
                            }
                            bAreaCodeStarted = false;
                        }
                        else if (segment.Length > 0)
                        {
                            AssignPhoneMain(segment, phone);
                        }
                        segment             = new StringBuilder();
                        bCountryCodeStarted = false;
                        whole.Append(ch);
                    }
                    else if (ch == '-' || ch == '#')
                    {
                        if (segment[0] == '0' && (segment.Length == 3 || segment.Length == 4))
                        {
                            phone.AreaCode = segment.ToString();
                        }
                        else if (segment.Length > 0)
                        {
                            AssignPhoneMain(segment, phone);
                            bExtStarted = true;
                        }
                        segment = new StringBuilder();
                        whole.Append(ch);
                    }
                    else if (ch == '+')
                    {
                        whole.Append(ch);
                        bCountryCodeStarted = true;
                    }
                    i++;
                }
                if (segment.Length > 0)
                {
                    AssignPhoneMain(segment, phone);
                    if (bExtStarted)
                    {
                        phone.Extension = segment.ToString();
                        bExtStarted     = false;
                    }
                }
            }
            else if (_pattern == ParserPattern.NorthAmerica)
            {
                while (i < allowedString.Length)
                {
                    ch = allowedString[i];

                    if (NumeralUtil.IsArabicNumeral(ch))
                    {
                        whole.Append(ch);
                        segment.Append(ch);
                    }
                    else if (ch == ' ')
                    {
                        whole.Append(ch);
                    }
                    else if (ch == '(')
                    {
                        bAreaCodeStarted = true;
                        whole.Append(ch);
                    }
                    else if (ch == ')')
                    {
                        if (bAreaCodeStarted)
                        {
                            if (segment.Length > 0)
                            {
                                phone.AreaCode = segment.ToString();
                            }
                            bAreaCodeStarted = false;
                        }
                        segment = new StringBuilder();
                        whole.Append(ch);
                    }
                    else if (ch == '-')
                    {
                        if (bCountryCodeStarted)
                        {
                            if (segment.Length > 0)
                            {
                                phone.CountryCode = segment.ToString();
                            }
                            bCountryCodeStarted = false;
                            bAreaCodeStarted    = true;
                        }
                        else if (bAreaCodeStarted)
                        {
                            if (segment.Length > 0)
                            {
                                phone.AreaCode = segment.ToString();
                            }
                            bAreaCodeStarted = false;
                        }
                        else if (segment.Length > 0)
                        {
                            AssignPhoneMain(segment, phone);
                        }
                        whole.Append(ch);
                        segment = new StringBuilder();
                    }
                    else if (ch == '+')
                    {
                        bCountryCodeStarted = true;
                        whole.Append(ch);
                    }
                    else if (ch == '.')
                    {
                        if (segment.ToString() != "ext")
                        {
                            break;
                        }

                        whole.Append("ext.");
                    }
                    else if (ch == 'e' || ch == 'x' || ch == 't')
                    {
                        segment.Append(ch);
                    }
                    i++;
                }
                if (segment.Length > 0)
                {
                    AssignPhoneMain(segment, phone);
                    if (bExtStarted)
                    {
                        phone.Extension = segment.ToString();
                        bExtStarted     = false;
                    }
                }
            }
            else
            {
                throw new NotImplementedException("Phone No. in " + _pattern.ToString() + " is not implemented in the parser.");
            }
            if (whole.Length > 0 && phone.Main != null)
            {
                prc.Add(ParseResult.Create(whole.ToString(), startIndex, POSType.A_M, phone));
            }
            return(prc);
        }