Exemple #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (check_select == 1)
     {
         AddAddress add_address = new AddAddress(int.Parse(this.user_id), int.Parse(this.house_id));
         add_address.Show();
         this.Close();
         this.Dispose();
     }
     else
     {
         MessageBox.Show("You have not selected row");
     }
 }
        private void button1_Click(object sender, EventArgs e)
        {
            if (name_box.Text == "" || phone_box.Text == "" || email_box.Text == "" || pwd_box.Text == "")
            {
                MessageBox.Show("Cannot be left Empty");
                return;
            }
            if (phone_box.TextLength != 11)
            {
                MessageBox.Show("Enter Valid  Phone Number");
                return;
            }
            if (pwd_box.TextLength < 5)
            {
                MessageBox.Show("Password length must be greater or equal than 5");
                return;
            }
            try
            {
                SqlConnection con = new SqlConnection(ConnectionString.connectionString);
                con.Open();
                // procedure for inserting new user
                SqlCommand cmd  = new SqlCommand("SIGN_UP_PROC", con);
                SqlCommand cmd2 = new SqlCommand("SELECT USER_ID FROM USER_ WHERE NAME = @Name ", con);

                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@NAME", name_box.Text));
                cmd.Parameters.Add(new SqlParameter("@PASS", pwd_box.Text));
                cmd.Parameters.Add(new SqlParameter("@EMAIL", email_box.Text));
                cmd.Parameters.Add(new SqlParameter("@TEL", phone_box.Text));

                cmd.ExecuteNonQuery();
                //get user_name
                cmd2.Parameters.Add(new SqlParameter("@Name", name_box.Text));
                cmd2.ExecuteNonQuery();
                //get user_id
                this.user_id = Convert.ToInt32(cmd2.ExecuteScalar());

                con.Close();

                AddAddress add_address = new AddAddress(this.user_id);
                add_address.ShowDialog();
                this.Close();
                this.Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }