private void EmailAddresstextBox_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         WebServiceUrltextBox.Focus();
         e.Handled = true;
     }
 }
 public void ResetAll()
 {
     //CompanyTypecomboBox.Items.Clear();
     CompanyTypecomboBox.SelectedIndex = -1;
     VendorNametextBox.Clear();
     PhonetextBox.Clear();
     EmailAddresstextBox.Clear();
     WebServiceUrltextBox.Clear();
     ResetResidentialAddress();
 }
        private void WebServiceUrltextBox_Leave(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(WebServiceUrltextBox.Text))
            {
                string urlAddress = WebServiceUrltextBox.Text.Trim();
                Regex  mRegxExpression;
                Regex  mRegxExpression1;

                mRegxExpression  = new Regex(@"^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&%\$#_]*)?$");
                mRegxExpression1 = new Regex(@"^(www.)[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&%\$#_]*)?$");

                if ((!mRegxExpression.IsMatch(urlAddress)) && (!mRegxExpression1.IsMatch(urlAddress)))
                {
                    MessageBox.Show("Please type your valid Url Address.", "MojoCRM", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    WebServiceUrltextBox.Clear();
                    WebServiceUrltextBox.Focus();
                }
            }
        }
        private bool ValidateVendor()
        {
            List <Vendor> vendors = new List <Vendor>();

            con = new SqlConnection(cs.DBConn);
            con.Open();
            string ct3 =
                "SELECT V_Name, Phone, Email, WebUrl FROM tblVendor where  tblVendor.V_Name='" +
                VendorNametextBox.Text + "'";

            cmd = new SqlCommand(ct3, con);
            rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                if (rdr.HasRows)
                {
                    Vendor x = new Vendor();
                    x.Name = rdr.GetString(0);

                    if (!DBNull.Value.Equals(rdr["Phone"]))
                    {
                        x.Phone = rdr.GetString(1);
                    }
                    else
                    {
                        x.Phone = null;
                    }

                    if (!DBNull.Value.Equals(rdr["Email"]))
                    {
                        x.Email = rdr.GetString(2);
                    }
                    else
                    {
                        x.Email = null;
                    }


                    if (!DBNull.Value.Equals(rdr["WebUrl"]))
                    {
                        x.Weburl = rdr.GetString(3);
                    }
                    else
                    {
                        x.Weburl = null;
                    }

                    vendors.Add(x);
                }
            }
            foreach (Vendor p in vendors)
            {
                if (p.Name == VendorNametextBox.Text && p.Phone == PhonetextBox.Text)
                {
                    MessageBox.Show(@"This Person Exists,Please Input another one" + "\n" + @"Or Use another Phone",
                                    "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    VendorNametextBox.Clear();
                    PhonetextBox.Clear();
                    WebServiceUrltextBox.Clear();
                    EmailAddresstextBox.Clear();
                    //VendorNametextBox.Focus();
                    con.Close();
                    return(true);
                }

                if (p.Name == VendorNametextBox.Text && p.Email == EmailAddresstextBox.Text)
                {
                    MessageBox.Show(@"This Person Exists,Please Input another one" + "\n" + @"Or Use another Email",
                                    "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    VendorNametextBox.Clear();
                    PhonetextBox.Clear();
                    WebServiceUrltextBox.Clear();
                    EmailAddresstextBox.Clear();
                    con.Close();
                    return(true);
                }

                if (p.Name == VendorNametextBox.Text && p.Weburl == WebServiceUrltextBox.Text)
                {
                    MessageBox.Show(
                        @"This Person Exists,Please Input another one" + "\n" + @"Or Use another Web Service URL",
                        "Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    VendorNametextBox.Clear();
                    PhonetextBox.Clear();
                    WebServiceUrltextBox.Clear();
                    EmailAddresstextBox.Clear();

                    con.Close();
                    return(true);
                }
            }
            return(false);
        }