private void btnsubmit1_Click(object sender, EventArgs e) { if (txtusername1.Text == "" || txtpassword.Text == "") { MessageBox.Show("Please provide UserName and Password"); return; } try { SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\User\source\repos\FollowUpSSB\FollowUpSSB\NewRepo\SSBFollowWin\adminfollow.mdf;Integrated Security=True;Connect Timeout=30"); SqlDataAdapter sda = new SqlDataAdapter("Select * from Sales_Person where salesperson_username='******' and sales_password='******' and usertype='" + cmbtype + "'", con); DataTable ds = new DataTable(); sda.Fill(ds); //If count is greater than 1, than show Adminpanel form if (ds.Rows.Count >= 1) { this.Hide(); Adminpanel fm = new Adminpanel(); fm.Show(); } else { MessageBox.Show("Login Failed!"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void Adminbtn_Click(object sender, EventArgs e) { var ad = new Adminpanel(); ad.Dock = DockStyle.Fill; metroPanel3.Controls.Clear(); metroPanel3.Controls.Add(ad); label1.Text = "Admin panel"; }