Esempio n. 1
0
        private void btnLog_Click(object sender, EventArgs e)
        {
            Form f1 = new CDashboard();

            f1.Show();
            this.Hide();
            f1.Closed += (s, args) => this.Close();
        }
Esempio n. 2
0
 private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     if (txtMail.Text == "" || txtPass.Text == "")
     {
         MessageBox.Show("Please provide UserName and Password");
         return;
     }
     try
     {
         //Create SqlConnection
         SqlConnection con = new SqlConnection(cs);
         SqlCommand    cmd = new SqlCommand("Select * from CompanyDetails where c_mail=@c_mail and c_password=@c_password", con);
         cmd.Parameters.AddWithValue("@c_mail", txtMail.Text);
         cmd.Parameters.AddWithValue("@c_password", txtPass.Text);
         con.Open();
         SqlDataAdapter adapt = new SqlDataAdapter(cmd);
         DataSet        ds    = new DataSet();
         adapt.Fill(ds);
         con.Close();
         int count = ds.Tables[0].Rows.Count;
         //If count is equal to 1, than show frmMain form
         if (count == 1)
         {
             MessageBox.Show("Login Successful!");
             Form f1 = new CDashboard();
             f1.Show();
             linkLabel1.LinkVisited = true;
             this.Hide();
             f1.Closed += (s, args) => this.Close();
         }
         else
         {
             MessageBox.Show("Login Failed!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }