示例#1
0
        private void Save()
        {
            try
            {
                string cGender;
                if (rbMale.Checked == true)
                {
                    cGender = "M";
                }
                else if (rbFemale.Checked == true)
                {
                    cGender = "F";
                }
                else
                {
                    cGender = "N";
                }

                Libs.querystring = "INSERT into registration (MobileNumber, FirstName, LastName, Gender, Email, user_add, date_add) " +
                                   "values ('" + txtMobileNum.Text + "', '" + txtFirstName.Text + "', '" + txtLastName.Text + "', " +
                                   "'" + cGender + "', '" + txtEmail.Text + "', '" + Libs.user.ToString() + "', now())";
                Libs.Requery();
            }
            catch (Exception ex)
            {
                Libs.LogError(ex);
            }
        }
示例#2
0
        private void ValidateForm()
        {
            bool isExistMobile = false, isExistEmail = false;

            if (txtMobileNum.Text != "" || IsPhoneNumber(txtMobileNum.Text))
            {
                MySqlConnection conn;
                conn = new MySqlConnection(Libs.connectionString);
                try
                {
                    string       query = "select MobileNumber from Registration where MobileNumber = '" + txtMobileNum.Text + "'";
                    MySqlCommand cmd   = new MySqlCommand(query, conn);
                    conn.Open();
                    MySqlDataReader dr = cmd.ExecuteReader();
                    if (dr.Read())
                    {
                        isExistMobile = true;
                    }
                    else
                    {
                        isExistMobile = false;
                    }
                    dr.Close();
                    conn.Close();
                }
                catch (Exception ex) { Libs.LogError(ex); }
                finally
                {
                    conn.Close();
                }
            }

            if (txtEmail.Text != "")
            {
                MySqlConnection conn;
                conn = new MySqlConnection(Libs.connectionString);
                try
                {
                    string       query = "select Email from Registration where Email = '" + txtEmail.Text + "'";
                    MySqlCommand cmd   = new MySqlCommand(query, conn);
                    conn.Open();
                    MySqlDataReader dr = cmd.ExecuteReader();
                    if (dr.Read())
                    {
                        isExistEmail = true;
                    }
                    else
                    {
                        isExistEmail = false;
                    }
                    dr.Close();
                    conn.Close();
                }
                catch (Exception ex) { Libs.LogError(ex); }
                finally
                {
                    conn.Close();
                }
            }

            if (txtMobileNum.Text == "" || IsPhoneNumber(txtMobileNum.Text))
            {
                frmError.SetError(txtMobileNum, "Please enter valid Mobile Number");
                InputsOnOff(this, true);
                return;
            }
            else if (isExistMobile)
            {
                frmError.SetError(txtMobileNum, "Mobile Number already registered");
                InputsOnOff(this, true);
                return;
            }
            else if (txtEmail.Text == "")
            {
                frmError.SetError(txtEmail, "Please enter valid Email");
                InputsOnOff(this, true);
                return;
            }
            else if (isExistEmail)
            {
                frmError.SetError(txtMobileNum, "Email already registered");
                InputsOnOff(this, true);
                return;
            }
            else if (txtFirstName.Text == "")
            {
                frmError.SetError(txtFirstName, "Please enter a First Name");
                InputsOnOff(this, true);
                return;
            }
            else if (txtLastName.Text == "")
            {
                frmError.SetError(txtLastName, "Please enter a Last Name");
                InputsOnOff(this, true);
                return;
            }
            else
            {
                Save();
                btnLogin.Enabled = true;
                btnLogin.Visible = true;
            }
        }
示例#3
0
 private void FrmRegistration_Load(object sender, EventArgs e)
 {
     Libs.CallSettingsConn();
     getYear();
 }