示例#1
0
 private void button9_Click(object sender, EventArgs e)
 {
     MenuOffical frm = new MenuOffical();
     frm.MdiParent = this.ParentForm;
     this.Close();
     frm.Show();
 }
示例#2
0
 private void button1_Click(object sender, EventArgs e)
 {
     this.DialogResult = DialogResult.OK;
     MenuOffical frm = new MenuOffical();
     frm.MdiParent = this.ParentForm;
     this.Close();
     frm.Show();
 }
示例#3
0
        private void button2_Click(object sender, EventArgs e)
        {

            MessageBox.Show("Cám Ơn Bạn Đã Ghé Thăm");
            MenuOffical frm = new MenuOffical();
            frm.MdiParent = this.ParentForm;
            this.Close();
            frm.Show();

            
        }
示例#4
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
                {
                    
                }


            }


        }