The project title is "Flower boquet shop", i made this simpler for my college assessment ....
The database is
myDb.
There are 3 tables in myDb database.
myTb => name,username,password,emailid
admin => username,password
userorder => name,address,mobile,quantity
First design the forms like this,
Form1.cs[design] :
Double click the login button , and enter the code,
private void button1_Click(object sender, EventArgs e)
{
if ((textBox1.Text == "admin") && (textBox2.Text == "admin"))
{
this.Hide();
ahome ah = new ahome();
ah.Show();
}
else if (textBox1.Text == textBox2.Text)
{
this.Hide();
flowers f = new flowers();
f.Show();
}
else
{
MessageBox.Show("Invalid username / password");
}
}
for register button,
private void button2_Click(object sender, EventArgs e)
{
register reg = new register();
this.Hide();
reg.Show();
}
register.cs[design]
for registerme button,
private void button1_Click(object sender, EventArgs e)
{
string connectionString = "Data Source=AMMUKUTTI;Initial Catalog=myDb;Integrated Security=True";
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "Insert into mytb values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "');";
cmd.CommandType = CommandType.Text;
cmd.Connection = connection;
connection.Open();
cmd.ExecuteNonQuery();
MessageBox.Show("Account created successfully");
}
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
this.Hide();
Form1 f1 = new Form1();
f1.Show();
}
for back to login button,
private void button2_Click(object sender, EventArgs e)
{
Form1 f1 = new Form1();
this.Hide();
f1.Show();
}
flowers.cs[design]
after clicking a flower picture, you have to place order by,
order.cs[design]
for ordernow button,
private void button1_Click(object sender, EventArgs e)
{
string connectionString = "Data Source=AMMUKUTTI;Initial Catalog=myDb;Integrated Security=True";
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "Insert into userorder values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "');";
cmd.CommandType = CommandType.Text;
cmd.Connection = connection;
connection.Open();
cmd.ExecuteNonQuery();
MessageBox.Show("Your order is placed successfully");
// connection.Close();
}
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
this.Hide();
thankyou t = new thankyou();
t.Show();
}
for close button ,
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
thankyou.cs[design]
ahome.cs[design]
for viewuserlist button,
private void button1_Click(object sender, EventArgs e)
{
aview av = new aview();
this.Hide();
av.Show();
}
for vieworderlist button,
private void button2_Click(object sender, EventArgs e)
{
vieworder vo = new vieworder();
this.Hide();
vo.Show();
}
aview.cs[design]
After placing the datagridview, choose tha dataset ,the below code will generated automatically,
private void aview_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'myDbDataSet1.mytb' table. You can move, or remove it, as needed.
this.mytbTableAdapter.Fill(this.myDbDataSet1.mytb);
}
vieworder.cs[design]
private void vieworder_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'myDbDataSet3.userorder' table. You can move, or remove it, as needed.
this.userorderTableAdapter.Fill(this.myDbDataSet3.userorder);
}