//back private void button2_Click(object sender, EventArgs e) { RegMenu myForm = new RegMenu(); this.Hide(); myForm.ShowDialog(); }
private void button4_Click(object sender, EventArgs e) { int count = 0; SqlConnection con = new SqlConnection(@"Data Source=MATAN-PC;Initial Catalog=master;Integrated Security=True"); SqlDataAdapter sda = new SqlDataAdapter("Select Username from UsersInfoDataBase Where Username= '******' and Password= '******'", con); DataTable dt = new System.Data.DataTable(); sda.Fill(dt); if (dt.Rows.Count == 1) { UserInformation.CurrentLoggedInUser = Username.Text; RegMenu myForm = new RegMenu(); myForm.Text = Username.Text; this.Hide(); this.Close(); myForm.ShowDialog(); } else { if (count <= 2) { count = count + 1; MessageBox.Show("Wrong Username or Password, Please try again!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error); Username.Clear(); Password.Clear(); } if (count >= 3) { menuGuest newform = new menuGuest(); newform.ShowDialog(); this.Close(); } } }
private void label7_Click(object sender, EventArgs e) { RegMenu myform = new RegMenu(); this.Hide(); myform.ShowDialog(); this.Close(); }
private void button1_Click(object sender, EventArgs e) { bool FlagRated = false, UsernameExists = false; SqlConnection con = new SqlConnection(@"Data Source=MATAN-PC;Initial Catalog=master;Integrated Security=True"); int rate = 0; SqlDataAdapter da = new SqlDataAdapter("Select Username From RateTab where Username='******'", con); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count >= 1) { UsernameExists = true; } if (radioButton1.Checked) { rate = 1; con.Open(); if (UsernameExists == false) { string Query = "insert into RateTab (Username , Rating) values('" + UserInformation.CurrentLoggedInUser + "','" + rate + "')"; SqlDataAdapter SDA = new SqlDataAdapter(Query, con); SDA.SelectCommand.ExecuteNonQuery(); con.Close(); } if (UsernameExists == true) { SqlCommand cmd = new SqlCommand("UPDATE [dbo].[RateTab] SET [Rating] = '" + rate + "'Where Username='******'", con); cmd.ExecuteNonQuery(); con.Close(); } FlagRated = true; } if (radioButton2.Checked) { rate = 2; con.Open(); if (UsernameExists == false) { string Query = "insert into RateTab (Username , Rating) values('" + UserInformation.CurrentLoggedInUser + "','" + rate + "')"; SqlDataAdapter SDA = new SqlDataAdapter(Query, con); SDA.SelectCommand.ExecuteNonQuery(); con.Close(); } if (UsernameExists == true) { SqlCommand cmd = new SqlCommand("UPDATE [dbo].[RateTab] SET [Rating] = '" + rate + "'Where Username='******'", con); cmd.ExecuteNonQuery(); con.Close(); } FlagRated = true; } if (radioButton3.Checked) { rate = 3; con.Open(); if (UsernameExists == false) { string Query = "insert into RateTab (Username , Rating) values('" + UserInformation.CurrentLoggedInUser + "','" + rate + "')"; SqlDataAdapter SDA = new SqlDataAdapter(Query, con); SDA.SelectCommand.ExecuteNonQuery(); con.Close(); } if (UsernameExists == true) { SqlCommand cmd = new SqlCommand("UPDATE [dbo].[RateTab] SET [Rating] = '" + rate + "'Where Username='******'", con); cmd.ExecuteNonQuery(); con.Close(); } FlagRated = true; } if (radioButton4.Checked) { rate = 4; con.Open(); if (UsernameExists == false) { string Query = "insert into RateTab (Username , Rating) values('" + UserInformation.CurrentLoggedInUser + "','" + rate + "')"; SqlDataAdapter SDA = new SqlDataAdapter(Query, con); SDA.SelectCommand.ExecuteNonQuery(); con.Close(); } if (UsernameExists == true) { SqlCommand cmd = new SqlCommand("UPDATE [dbo].[RateTab] SET [Rating] = '" + rate + "'Where Username='******'", con); cmd.ExecuteNonQuery(); con.Close(); } FlagRated = true; } if (radioButton5.Checked) { rate = 5; con.Open(); if (UsernameExists == false) { string Query = "insert into RateTab (Username , Rating) values('" + UserInformation.CurrentLoggedInUser + "','" + rate + "')"; SqlDataAdapter SDA = new SqlDataAdapter(Query, con); SDA.SelectCommand.ExecuteNonQuery(); con.Close(); } if (UsernameExists == true) { SqlCommand cmd = new SqlCommand("UPDATE [dbo].[RateTab] SET [Rating] = '" + rate + "'Where Username='******'", con); cmd.ExecuteNonQuery(); con.Close(); } FlagRated = true; } if (!radioButton1.Checked && !radioButton2.Checked) { if (!radioButton3.Checked && !radioButton4.Checked) { if (!radioButton5.Checked) { MessageBox.Show("No Rating given!"); } } } if (FlagRated == true) { MessageBox.Show("Thanks For Rating Us!"); RegMenu myform = new RegMenu(); this.Hide(); myform.ShowDialog(); this.Close(); } }