Exemple #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            //lay computer name: System.Environment.MachineName
            string tendn = textBox1.Text;
            string strDbPath = Application.StartupPath + @"\CodeChildren1Offical.mdb";
            string strCnn = "Provider = Microsoft.Jet.OleDb.4.0; Data Source = " + strDbPath;
            OleDbConnection cnn = new OleDbConnection(strCnn);

            DataTable dtt = new DataTable();
            OleDbDataAdapter da = new OleDbDataAdapter("Select * from UserOffline", cnn);
            da.Fill(dtt);
            if (dtt.Rows.Count == 0)
            {
                DataTable dt = new DataTable();
                dt = cn.Select("SELECT * FROM ChildrenCode where username='******' and password='******' ");
                if (dt.Rows.Count == 1)
                {

                    Session.TenDN = textBox1.Text;
                    Session.MatKhau = MaHoa.MD5Hash(MaHoa.MD5Hash(textBox2.Text));
                    GetMac frm1 = new GetMac();
                    Session.Mac = frm1.GetMACAddress();
                    string a = frm1.GetMACAddress();
                    
                    cn.ExecuteSQL("Update ChildrenCode set cpname='" + System.Environment.MachineName + "' where username='******' and password='******'");
                    DataTable dttt = new DataTable();
                    dttt = cn.Select("SELECT email, name, username, password, phone, cpname,phone FROM ChildrenCode where username='******' and password='******' ");
                    if (dttt.Rows.Count == 1)
                    {
                        try
                        {
                            string email = dt.Rows[0]["email"].ToString();
                            string pass = dt.Rows[0]["password"].ToString();
                            string cpname = dt.Rows[0]["cpname"].ToString();
                            string name = dt.Rows[0]["name"].ToString();
                            string username = dt.Rows[0]["username"].ToString();
                            string phone = dt.Rows[0]["phone"].ToString();



                            string duongdan = Application.StartupPath + @"\CodeChildren1Offical.mdb";
                            string strCn = "Provider = Microsoft.Jet.OleDb.4.0; Data Source = " + duongdan;
                            OleDbConnection con = new OleDbConnection(strCn);

                            string sql = @"INSERT INTO UserOffline VALUES  (@p1,@p2,@p3,@p4,@p5,@p6)";
                            OleDbCommand cmd = new OleDbCommand(sql, con);
                            con.Open();
                            cmd.Parameters.AddWithValue("@p1", email); // if you have date time column give DateTime object as value
                            cmd.Parameters.AddWithValue("@p2", username);
                            cmd.Parameters.AddWithValue("@p3", pass);
                            cmd.Parameters.AddWithValue("@p4", cpname);
                            cmd.Parameters.AddWithValue("@p5", name);
                            cmd.Parameters.AddWithValue("@p6", phone);
                            cmd.ExecuteNonQuery();
                            con.Close();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                        }
                    }

                    ShowTaskbar();
                    //Registry.SetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System\\", "DisableTaskMgr", "0", Microsoft.Win32.RegistryValueKind.DWord);
                    //Registry.SetValue("HKEY_CURRENT_USER\\Software\\Policies\\Microsoft\\Windows\\System\\", "DisableCMD", "0", Microsoft.Win32.RegistryValueKind.DWord);
                    MenuOffical frm = new MenuOffical();
                    frm.MdiParent = this.ParentForm;
                    this.Close();
                    frm.Show();
                }
            }

            else
            {
                if (dtt.Rows.Count == 1)
                {
                    try
                    {

                        cnn.Open();

                        string strSql = "SELECT COUNT(*) FROM UserOffline WHERE UserName = @textBox1 AND Password = @textBox2";
                        OleDbCommand cmd = new OleDbCommand(strSql, cnn);
                        cmd.Parameters.AddWithValue("@textBox1", textBox1.Text);
                        cmd.Parameters.AddWithValue("@textBox2", MaHoa.MD5Hash(MaHoa.MD5Hash(textBox2.Text)));
                        Session.TenDN = textBox1.Text;
                        Session.MatKhau = MaHoa.MD5Hash(MaHoa.MD5Hash(textBox2.Text));
                        

                        if (Convert.ToBoolean(cmd.ExecuteScalar()))
                        {

                            MessageBox.Show("Login successful !!!");
                            ShowTaskbar();
                            //Registry.SetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System\\", "DisableTaskMgr", "0", Microsoft.Win32.RegistryValueKind.DWord);
                            //Registry.SetValue("HKEY_CURRENT_USER\\Software\\Policies\\Microsoft\\Windows\\System\\", "DisableCMD", "0", Microsoft.Win32.RegistryValueKind.DWord);
                            MenuOffical frm = new MenuOffical();
                            frm.MdiParent = this.ParentForm;
                            this.Close();
                            frm.Show();
                        }
                        else
                        {
                            MessageBox.Show("Invalid Username Or Password - Please Login Again !!");

                        }
                        cnn.Close();
                    }
                    catch (Exception exc)
                    {
                        MessageBox.Show(exc.Message);
                    }
                }
                else
                {
                    
                }


            }


        }
Exemple #2
0
        void CheckSTT()
        {

            DataTable dt = new DataTable();
            GetMac frm1 = new GetMac();
            Session.Mac = frm1.GetMACAddress();
            string a = frm1.GetMACAddress();
            
            dt = cn.Select("SELECT action,inforOfMess FROM ChildrenCode where username='******' and password='******' ");
            if (dt.Rows.Count == 1)
            {
                int step = 5;
                for (int i = 0; i <= step; i++)
                {
                    if (i == step)
                    {
                        i = 0;
                    }
                    else
                    {
                        if (dt.Rows[0][0].ToString() == "lock")
                        {
                            cn.ExecuteSQL("Update ChildrenCode set action='' where username='******' and password='******'");
                            Login fr = new Login();
                            fr.ShowDialog();

                        }


                        if (dt.Rows[0][0].ToString() == "tatmay")
                        {
                            cn.ExecuteSQL("Update ChildrenCode set action='' where username='******' and password='******'");
                            System.Diagnostics.Process.Start("Shutdown", "-s -f -t 1");
                        }

                        if (dt.Rows[0][0].ToString() == "khoidong")
                        {
                            cn.ExecuteSQL("Update ChildrenCode set action='' where username='******' and password='******'");
                            System.Diagnostics.Process.Start("Shutdown", "-r -f -t 1");
                        }

                        if (dt.Rows[0][0].ToString() == "chup")
                        {
                            cn.ExecuteSQL("Update ChildrenCode set action='' where username='******' and password='******'");
                            ScreenCapture chup = new ScreenCapture();
                            chup.Chup();

                        }

                        if (dt.Rows[0][1].ToString() != "")
                        {
                            cn.ExecuteSQL("Update ChildrenCode set inforOfMess='' where username='******' and password='******'");
                            MessageBox.Show(dt.Rows[0][1].ToString(), "Thong Bao");
                            
                        }
                        else
                        {

                        }


                    }

                }

            }
        }