Ejemplo n.º 1
0
        private void ChangePasswordForm_Load_1(object sender, EventArgs e)
        {
            ConnectionClass conn = new ConnectionClass();
            SqlCommand      cmd  = new SqlCommand("select * from Admin", conn.connect);

            conn.connect.Open();
            SqlDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                Emailbox.AutoCompleteCustomSource.Add(dr["E_mail"].ToString());
            }
            conn.connect.Close();
            Emailbox.Focus();
        }
Ejemplo n.º 2
0
 private void EMSLOGINFORM_Load(object sender, EventArgs e)
 {
     try {
         ConnectionClass conn = new ConnectionClass();
         SqlCommand      cmd  = new SqlCommand("select * from Admin", conn.connect);
         conn.connect.Open();
         SqlDataReader dr = cmd.ExecuteReader();
         while (dr.Read())
         {
             textBox1.AutoCompleteCustomSource.Add(dr["E_mail"].ToString());
         }
         conn.connect.Close();
         textBox1.Focus();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 3
0
        private bool SignupUser()
        {
            bool ret = true;

            if (txtName.Text == "")
            {
                lblNameIsRequired.Visible = true;
                ret = false;
            }
            else
            {
                lblNameIsRequired.Visible = false;
            }

            if (txtEmail.Text == "")
            {
                lblEmailIsRequired.Visible = true;
                ret = false;
            }
            else
            {
                lblEmailIsRequired.Visible = false;
            }

            if (txtPassword.Text == "")
            {
                lblPasswordIsRequired.Visible = true;
                ret = false;
            }
            else
            {
                lblPasswordIsRequired.Visible = false;
            }

            if (txtConfirmPassword.Text == "")
            {
                lblConfirmPasswordIsRequired.Visible = true;
                ret = false;
            }
            else
            {
                lblConfirmPasswordIsRequired.Visible = false;
            }

            if (txtPassword.Text != "" && txtConfirmPassword.Text != "")
            {
                if (txtPassword != txtConfirmPassword)
                {
                    lblConfirmPasswordAndPasswordSame.Visible = true;
                    ret = false;
                }
            }
            else
            {
                lblConfirmPasswordAndPasswordSame.Visible = false;
            }
            if ((txtName.Text != "") && (txtEmail.Text != "") && (txtPassword.Text != "") && (txtConfirmPassword.Text != "") && (txtPassword.Text == txtConfirmPassword.Text))
            {
                lblConfirmPasswordAndPasswordSame.Visible = false;
                ConnectionClass con = new ConnectionClass();
                SqlCommand      cmd = new SqlCommand("Select Count(*) From Admin Where E_mail = @E_mail", con.connect);
                cmd.Parameters.AddWithValue("@E_mail", txtEmail.Text);
                con.connect.Open();
                int Result = (int)cmd.ExecuteScalar();
                if (Result != 1)
                {
                    SqlCommand cmdInsert = new SqlCommand("Insert Into Admin (E_mail,Password,Name) Values (@E_mail,@Password,@Name)", con.connect);
                    cmdInsert.Parameters.AddWithValue("@E_mail", txtEmail.Text);
                    //MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
                    //UTF8Encoding utf8 = new UTF8Encoding();
                    //byte[] data = md5.ComputeHash(utf8.GetBytes(txtPassword.Text));
                    //string EncryptedPassword = Convert.ToBase64String(data);
                    cmdInsert.Parameters.AddWithValue("@Password", txtConfirmPassword.Text);
                    cmdInsert.Parameters.AddWithValue("@Name", txtName.Text);
                    cmdInsert.ExecuteNonQuery();
                    conn.connect.Close();
                    DialogResult DR = MessageBox.Show("New User Added", "Successfully", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    if (DR == DialogResult.OK)
                    {
                        EMSLOGINFORM ems       = new EMSLOGINFORM();
                        RefreshClass LoadEvent = new RefreshClass();
                        LoadEvent.zeeshansami(ems.textBox1);
                        //this.Refresh();
                        //MyForm1Instance.Refresh();
                        //MyForm1Instance.EMSLOGINFORM_Load_1(null, null);
                        //MyForm1Instance.EMSLOGINFORM_Load_1(this, new EventArgs());
                        //MessageBoxButtons.OK += new System.EventHandler(this.button1_Click);
                    }
                }
                else
                {
                    MessageBox.Show("This Email is already exist");
                    txtPassword.Clear();
                    txtConfirmPassword.Clear();
                    con.connect.Close();
                }
            }
            return(ret);
        }