Beispiel #1
0
 public void Insert(TextBox name, TextBox adress, TextBox email, TextBox user, TextBox password, Label date)
 {
     ctrl(user);
     if (state == true)
     {
         SqlCommand komut = new SqlCommand("Insert into Customer (Name,Adress,Email,Username,Password,Register_Time) Values(@name,@address,@email,@user, @pass,@time)", baglan);
         komut.Parameters.AddWithValue("@name", name.Text);
         komut.Parameters.AddWithValue("@address", adress.Text);
         komut.Parameters.AddWithValue("@email", email.Text);
         komut.Parameters.AddWithValue("@User", user.Text);
         komut.Parameters.AddWithValue("@pass", password.Text.ToString());
         komut.Parameters.AddWithValue("@time", Convert.ToDateTime(date.Text));
         if (baglan.State == System.Data.ConnectionState.Closed)
         {
             baglan.Open();
         }
         komut.ExecuteNonQuery();
         baglan.Close();
         MessageBox.Show("Successful Registration");
         name.Text     = "";
         adress.Text   = "";
         email.Text    = "";
         user.Text     = "";
         password.Text = "";
         Customer_Page cstmr = new Customer_Page();
         cstmr.Show();
         SignUp_Page sign = new SignUp_Page();
         sign.Hide();
     }
     else
     {
         MessageBox.Show("There is another user with the same username", "Warning !", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         baglan.Close();
     }
 }
Beispiel #2
0
        public void Login(TextBox user, TextBox pass, Form frm)
        {
            SqlCommand cmd = new SqlCommand(sorgu, baglan);

            cmd.Parameters.AddWithValue("@kullaniciadi", user.Text);
            cmd.Parameters.AddWithValue("@sifre", pass.Text);
            baglan.Open();

            SqlDataReader dr = cmd.ExecuteReader();

            if (dr.Read())
            {
                if (dr["Access"].ToString() == "1")
                {
                    Customer_Page customer = new Customer_Page();
                    Customer_Page.usr = user.Text;
                    customer.Show();
                }
                else
                {
                    Admin_Page admin = new Admin_Page();
                    Admin_Page.usr = user.Text;
                    admin.Show();
                    frm.Hide();
                }
            }
            else
            {
                MessageBox.Show("Incorrect username or password", "ERROR !", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }

            baglan.Close();
        }