private void toggleBtn_Click(object sender, EventArgs e)
 {
     Dashboared dObj = new Dashboared();
     // this.FormBorderStyle = FormBorderStyle.None;
     // this.WindowState = FormWindowState.Maximized;
     // toggleBtn.Dock = DockStyle.Right;
     //toggleBtn.MarginTop
     // dObj.Dashboared();
 }
 protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
 {
     if (keyData == (Keys.Control | Keys.F))
     {
         MessageBox.Show("What the Ctrl+F?");
         Dashboared d = new Dashboared();
         // d.FormBorderStyle = FormBorderStyle.None;
         // d.WindowState = FormWindowState.Minimized;
         d.StartPosition = FormStartPosition.CenterScreen;
         return(true);
     }
     return(base.ProcessCmdKey(ref msg, keyData));
 }
Exemple #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool flag = false;

            if ((userTxt.Text == "") || (PassTxt.Text == "") || (comboTxt.SelectedItem.ToString() == ""))//check wheather data field is empty or not
            {
                MessageBox.Show("Please Insert Your Account Information To Login");
            }
            else
            {
                SqlConnection con = new SqlConnection("Data Source=DESKTOP-AGPPMFD\\JAMINURSQLSERVER;Initial Catalog=SystemDatabase;Integrated Security=True");
                //SqlConnection con = new SqlConnection("Data Source=JAMINUR\\JAMINURSQL;Initial Catalog=MyDbse;Integrated Security=True");
                SqlCommand     cmd = new SqlCommand("select * from UserInfo where username='******' and password='******' and usertype='" + comboTxt.SelectedItem.ToString() + "'", con);
                SqlDataAdapter sda = new SqlDataAdapter(cmd);
                DataTable      dt  = new DataTable();
                sda.Fill(dt);
                try
                {
                    con.Open();
                    // MessageBox.Show("se");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                // MessageBox.Show("have data");
                if ((userTxt.Text == "") || (PassTxt.Text == "") || (comboTxt.SelectedItem.ToString() == ""))
                {
                    MessageBox.Show("Please Insert Your Account Information To Login");
                }
                if (dt.Rows.Count > 0)
                {
                    // MessageBox.Show("ddddd");
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        if ((userTxt.Text == dt.Rows[i]["username"].ToString()) && (PassTxt.Text == dt.Rows[i]["password"].ToString()) && (comboTxt.SelectedItem.ToString() == dt.Rows[i]["usertype"].ToString()) && (comboTxt.SelectedItem.ToString() == "Admin"))
                        {
                            flag           = true;
                            loggedUserName = userTxt.Text;
                            if (comboTxt.Text.ToString() == "Admin")
                            {
                                var confirmResult = MessageBox.Show("Hey Admin do you want to login as User??",
                                                                    "Confirm Please!!",
                                                                    MessageBoxButtons.YesNo);
                                if (confirmResult == DialogResult.Yes)
                                {
                                    // If 'Yes', do something here.
                                    // Home h = new Home();
                                    // loggedIn = userTxt.Text;//To display Logged In user
                                    // MainClass.showWindow(h, this, Form1.ActiveForm);
                                    UserDashboared us = new UserDashboared();
                                    this.Hide();
                                    us.Show();
                                }
                                else
                                {
                                    Dashboared db = new Dashboared();
                                    this.Hide();
                                    db.Show();
                                    // If 'No', do something here.
                                    //  Admin_Panel ap5 = new Admin_Panel();
                                    //  loggedIn = comboTxt.Text;//To display Logged In user
                                    //  //loggedIn1 =comboTxt.Text;
                                    //    MainClass.showWindow(ap5, this, Form1.ActiveForm);
                                    // this.Hide();
                                }
                            }
                        }
                        else
                        {
                            if (comboTxt.SelectedItem.ToString() == "User")
                            {
                                if ((userTxt.Text == dt.Rows[i]["username"].ToString()) && (PassTxt.Text == dt.Rows[i]["password"].ToString()))
                                {
                                    flag = true;
                                    UserDashboared us = new UserDashboared();
                                    this.Hide();
                                    us.Show();
                                    //  Home h = new Home();
                                    // loggedIn = comboTxt.Text;
                                    //MainClass.showWindow(h, this, Form1.ActiveForm);
                                    // this.Hide();
                                }
                            }
                        }
                    }
                }
            }
            if (!flag)
            {
                MessageBox.Show("You Are not Allowed To Login");
            }
        }