[转贴]葡京在线开户大量.net学习资源

eclipse项目中启做前的逐条客户端与服务端的窗口和工具类,效果使下图:

VS.NET 学习方法论

登录时查询数据库DBLogin类代码:

   http://authors.aspalliance.com/aldotnet/examples/translate.aspx

package com.swift.frame;

import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.ConnectException;
import java.net.Socket;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.TitledBorder;

import com.google.gson.Gson;
import com.swift.util.Center;

public class LoginDialog extends JDialog {

    private JPasswordField passwordField_2;
    private JPasswordField passwordField_1;
    private JTextField textField_2;
    private JTextField textField;
    String request = null;
    String response = null;

    Socket s;
    DataOutputStream dos;
    DataInputStream dis;

    public static void main(String args[]) {
        JFrame.setDefaultLookAndFeelDecorated(true);
        JDialog.setDefaultLookAndFeelDecorated(true);

        try {
            UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
        } catch (ClassNotFoundException e1) {
            e1.printStackTrace();
        } catch (InstantiationException e1) {
            e1.printStackTrace();
        } catch (IllegalAccessException e1) {
            e1.printStackTrace();
        } catch (UnsupportedLookAndFeelException e1) {
            e1.printStackTrace();
        }

        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    LoginDialog dialog = new LoginDialog();
                    dialog.addWindowListener(new WindowAdapter() {
                        public void windowClosing(WindowEvent e) {
                            System.exit(0);
                        }
                    });
                    dialog.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    public LoginDialog() {
        super();
        setResizable(false);
        setTitle("在线聊天登录框");
        getContentPane().setLayout(null);
        setBounds(100, 100, 427, 301);// 注册时高度为578,不注册是301

        // 设置窗口居中
        this.setLocation(Center.getPoint(this.getSize()));

        final JTextField textField_1 = new JTextField();
        textField_1.setBounds(148, 90, 192, 42);
        getContentPane().add(textField_1);

        final JLabel label = new JLabel();
        label.setText("帐    号");
        label.setBounds(76, 102, 66, 18);
        getContentPane().add(label);

        final JLabel label_1 = new JLabel();
        label_1.setText("密    码");
        label_1.setBounds(76, 167, 66, 18);
        getContentPane().add(label_1);

        final JPasswordField passwordField = new JPasswordField();
        passwordField.setBounds(148, 155, 192, 42);
        getContentPane().add(passwordField);

        final JButton button_1 = new JButton();
        button_1.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent e) {

                String phone = new String(textField_1.getText()).trim();
                String password = new String(passwordField.getPassword()).trim();
                if (!phone.equals("") && !password.equals("")) {
                    try {
                        request = "login";
                        dos.writeUTF(request);
                        response = dis.readUTF();
                        if (response.equals("login")) {
                            dos.writeUTF(phone);
                            dos.writeUTF(password);
                            String flag=dis.readUTF();
                            if(flag.equals("success")) {
                                javax.swing.JOptionPane.showMessageDialog(LoginDialog.this, "登录成功");
                            }else if(flag.equals("fail")) {
                                javax.swing.JOptionPane.showMessageDialog(LoginDialog.this, "登录失败");
                            }
                        }
                    } catch (IOException e1) {
                        e1.printStackTrace();
                    }
                } else {
                    javax.swing.JOptionPane.showMessageDialog(LoginDialog.this, "用户名密码必须填写...");
                    return;
                }
            }
        });
        button_1.setText("登录");
        button_1.setBounds(230, 222, 106, 36);
        getContentPane().add(button_1);

        final JButton button = new JButton();
        button.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent e) {
                if (LoginDialog.this.getHeight() == 301) {
                    LoginDialog.this.setSize(427, 578);
                } else {
                    LoginDialog.this.setSize(427, 301);
                }
                // 设置窗口不断居中
                LoginDialog.this.setLocation(Center.getPoint(LoginDialog.this.getSize()));
            }
        });
        button.setText("注册");
        button.setBounds(76, 222, 106, 36);
        getContentPane().add(button);

        final JPanel panel = new JPanel();
        panel.setLayout(null);
        panel.setBorder(new TitledBorder(null, "注册用户", TitledBorder.DEFAULT_JUSTIFICATION,
                TitledBorder.DEFAULT_POSITION, null, null));
        panel.setBounds(10, 278, 401, 226);
        getContentPane().add(panel);

        final JLabel label_2 = new JLabel();
        label_2.setBounds(44, 41, 65, 18);
        label_2.setText("手机号:");
        panel.add(label_2);

        textField = new JTextField();
        textField.setBounds(115, 35, 225, 30);
        panel.add(textField);

        final JButton button_2 = new JButton();
        button_2.setText("发送验证");
        button_2.setBounds(243, 75, 97, 30);
        panel.add(button_2);

        textField_2 = new JTextField();
        textField_2.setBounds(115, 104, 95, 30);
        panel.add(textField_2);

        final JLabel label_3 = new JLabel();
        label_3.setText("验证码:");
        label_3.setBounds(44, 110, 65, 18);
        panel.add(label_3);

        passwordField_1 = new JPasswordField();
        passwordField_1.setBounds(115, 143, 231, 30);
        panel.add(passwordField_1);

        passwordField_2 = new JPasswordField();
        passwordField_2.setBounds(115, 175, 231, 30);
        panel.add(passwordField_2);

        final JLabel label_4 = new JLabel();
        label_4.setText("密        码:");
        label_4.setBounds(44, 149, 65, 18);
        panel.add(label_4);

        final JLabel label_5 = new JLabel();
        label_5.setText("验证密码:");
        label_5.setBounds(44, 181, 65, 18);
        panel.add(label_5);

        final JButton button_3 = new JButton();
        button_3.setBounds(47, 510, 97, 30);
        getContentPane().add(button_3);
        button_3.setText("放弃");

        final JButton button_4 = new JButton();
        button_4.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent e) {

                String phone = textField.getText();
                String password = null;
                String str1 = new String(passwordField_1.getPassword()).trim();
                String str2 = new String(passwordField_2.getPassword()).trim();
                if (!phone.equals("") && !str1.equals("") && !str2.equals("")) {
                    if (str1.equals(str2)) {
                        password = new String(passwordField_2.getPassword()).trim();
                        try {
                            request = "reg";
                            dos.writeUTF(request);
                            String response = dis.readUTF();
                            if (response.equals("reg")) {
                                dos.writeUTF(phone);
                                dos.writeUTF(password);
                            }
                            javax.swing.JOptionPane.showMessageDialog(LoginDialog.this, "注册成功...");
                        } catch (IOException e1) {
                            e1.printStackTrace();
                        }
                    } else {
                        javax.swing.JOptionPane.showMessageDialog(LoginDialog.this, "输入密码不一致...");
                        System.out.println("输入密码不一致...");
                        passwordField_1.setText("");
                        passwordField_2.setText("");
                    }

                } else {
                    javax.swing.JOptionPane.showMessageDialog(LoginDialog.this, "用户名密码必须填写...");
                    return;
                }
            }
        });

        button_4.setBounds(262, 510, 97, 30);
        getContentPane().add(button_4);
        button_4.setText("注册用户");

        connect();
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosed(WindowEvent e) {
                disconnect();
            }
        });
    }

    public void connect() {
        try {
            s = new Socket("127.0.0.1", 8888);
            System.out.println("一个客户端登陆中....!");
            dos = new DataOutputStream(s.getOutputStream());
            dis = new DataInputStream(s.getInputStream());

        } catch (ConnectException e) {
            System.out.println("服务端异常.........");
            System.out.println("请确认服务端是否开启.........");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void disconnect() {
        try {
            if (dos != null)
                dos.close();
            if (s != null)
                s.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}

      ——我的VS.NET学习的一起

连天数据库工具类DBUtil类代码:

  http://www.123aspx.com

签到对话框LoginDialog类代码如下:

  http://www.devx.com/dotnet

长到数据库的类DBAdd代码:

  第五碰体会:精通并使用大量大网资源来帮忙VS.NET的念,你将经济。

Center类:

  http://www.chinaaspx.com

package com.swift.server;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.EOFException;
import java.io.IOException;
import java.net.BindException;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;

import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.swift.frame.LoginDialog;
import com.swift.jdbc.DBAdd;
import com.swift.jdbc.DBLogin;
import com.swift.other.User;

public class LoginServer {

    boolean started = false;
    ServerSocket ss = null;
    Socket s = null;
    String request = null;
    String response = null;

    public static void main(String[] args) {
        new LoginServer().fun();
    }

    private void fun() {
        try {
            ss = new ServerSocket(8888);
            started = true;
        } catch (BindException e) {
            System.out.println("端口使用中......");
        } catch (IOException e1) {
            e1.printStackTrace();
        }
        try {
            while (started) {
                s = ss.accept();
                System.out.println("a client connected success");
                Client c = new Client(s);
                new Thread(c).start();
            }
        } catch (EOFException e) {
            System.out.println("client has closed.");
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                ss.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }

    class Client implements Runnable {

        private Socket s;
        private DataInputStream dis;
        private DataOutputStream dos;
        private boolean connected = false;

        public Client(Socket s) {
            this.s = s;
            try {
                this.dis = new DataInputStream(s.getInputStream());
                this.dos = new DataOutputStream(s.getOutputStream());
                connected = true;
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        @Override
        public void run() {
            try {
                while (connected) {
                    request = dis.readUTF();
                    response = request;
                    dos.writeUTF(response);
                    if (request.equals("login")) {

                        String phone = dis.readUTF();
                        String password = dis.readUTF();
                        System.out.println(phone);
                        System.out.println(password);

                        User user = new User(phone, password);
                        boolean login = DBLogin.login(user);
                        if (login) {
                            dos.writeUTF("success");
                        }else {
                            dos.writeUTF("fail");
                        }

                    } else if (request.equals("reg")) {
                        String phone = dis.readUTF();
                        String password = dis.readUTF();
                        System.out.println(phone);
                        System.out.println(password);

                        User user = new User(phone, password);
                        DBAdd.add(user);
                    }
                }
            } catch (SocketException e) {
                System.out.println("一个登陆窗已经关闭....");
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                if (s != null) {
                    try {
                        s.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
                if (dis != null) {
                    try {
                        dis.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
                if (dos != null) {
                    try {
                        dos.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        }

    }
}

  http://218.56.11.178:8009/   海波.NET的水晶报表专栏

葡京在线开户 1

  DotNet中华网(http://www.aspxcn.com/

 

京城可望电子出版社图书素材资料下载(http://www.b-xr.com/bbs.htm)
 
  北大大学出版社VS.NET源码下载(http://www.wenyuan.com.cn/xiazai.htm)

package com.swift.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class DBUtil {

    public static Connection getConn() {
        Connection conn=null;
        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        try {
            String url="jdbc:mysql://localhost:3306/sw_database";
            String user="root";
            String password="root";
            conn=DriverManager.getConnection(url, user, password);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return conn;
    }

    public static void closeAll(Connection conn,PreparedStatement ps,ResultSet rs) {

        if(conn!=null) {
            try {
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        if(ps!=null) {
            try {
                ps.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        if(rs!=null) {
            try {
                rs.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
}

  5.海外资源
   假设你的E文不错,不妨上E文网站去取经。  

package com.swift.jdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import com.swift.other.User;

public class DBAdd {

    public static void add(User user) {

        String phone = user.getUsername();
        String password = user.getPassword();

        Connection conn = DBUtil.getConn();
        PreparedStatement ps=null;
        try {
            ps = conn.prepareStatement("insert into sw_user(username,password) values(?,?)");
            ps.setString(1, phone);
            ps.setString(2, password);
            int count = ps.executeUpdate();
            if (count == 1) {
                System.out.println("用户添加成功");
            } else {
                System.out.println("用户添加失败");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            DBUtil.closeAll(conn, ps, null);
        }

    }

}

http://dev.csdn.net/develop/article/23/23542.shtm
1.微软襄助
  于您上VS.NET的长河中,有疑问首先要往MicroSoft求助。虽然您无清楚运用MicroSoft提供的翻天覆地的攻资源,我而告您,你死丧气,你得不偿失了。
  (1)首先,你一旦安装MSDN,他比有VS.NET书籍详细。我以装MSDN,可是牺牺了自的98以及XP双起动,改化WindowsXP单系统。装了MSDN后,你若读书正则表达式,VS.NET
2003丁点击“协助”,再点击“搜索”,然后输入“正则”,一磨车,哇,找到470只主题,这生您日渐探讨吧。实在切磋不浮,也未用急,还有谷歌和CSDN呢。   
  (2)在线Microsoft .NET 框架 SDK
飞速入门教程(http://chs.gotdotnet.com/QuickStart),可匹配MSDN使用。分三片内容,
ASP.NET | Windows 窗体 | 如何…?常见任务 。
“常见任务急速入门”目的在于帮忙你快找到常见编程问题之答案。
  (3)微软中国社区(http://www.mscommunity.com/Profile/)。在社区注册,有问题虽到社区去问问吧。
 
(4)在线闽南语MSDN(http://www.microsoft.com/china/MSDN/default.asp);在线英文MSDN(http://msdn.microsoft.com/),考考你的E文,但是出金山词霸在,我还固然,你还用怕什么呢!
  (5).NET主页(http://www.microsoft.com/china/net
  (6)Visual Studio
.NET主页(http://www.microsoft.com/china/msdn/vstudio/prodinfo/overview.asp)。
  
为啥拔取VS.NET,为啥主张VS.NET,看看MicroSoft的Help文档有差不多详尽就知了。倘若你无错过用MicroSoft提供的宏大之Help资源,是不是聊对不起盖茨也!  

 

  http://blog.joycode.com/ 博客堂

package com.swift.jdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.swift.other.User;

public class DBLogin {

    public static boolean login(User user) {

        Connection conn=DBUtil.getConn();
        PreparedStatement ps=null;
        ResultSet rs=null;
        try {
            ps=conn.prepareStatement("select * from sw_user where username=? and password=?");
            ps.setString(1, user.getUsername());
            ps.setString(2, user.getPassword());
            rs=ps.executeQuery();
            if(rs.next()) {
                return true;
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        DBUtil.closeAll(conn, ps, rs);
        return false;
    }
}

  http://www.devcity.net

package com.swift.other;

public class User {

    private int id;
    private String username;
    private String password;
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    public User(int id, String username, String password) {
        this.id = id;
        this.username = username;
        this.password = password;
    }
    public User() {
        super();
    }
    public User(String username, String password) {
        this.username = username;
        this.password = password;
    }
    @Override
    public String toString() {
        return "User [id=" + id + ", username=" + username + ", password=" + password + "]";
    }

}

  http://www.programmersheaven.com/

有数独帮忙类User类和居中类Center

  http://sourceforge.net/ 

曾经用注册服务器线程RegServer效率放到LoginServer中,使用客户端与劳动端的request请求机制,依据请求是登记或登录,分别展开对应response,客户端按照对应内容判断下同样步操作。

  http://www.a1vbcode.com/   

发送音信的形式还相比原始,没有行使json方法,但gson包已经导入,援助发送键值对之字符串,及活动分析。

  http://www.regexplib.com/

报到以及注册之服务端代 LoginServer类码如下:

  ccidnet的NET专区(http://tech.ccidnet.com/pub/column/c340.html

葡京在线开户 2

  2.CSDN http://www.csdn.net/
  CSDN号称中国最为酷的开发者网络,确实不假。我最为常错过之凡CSDN的
  文档(http://www.csdn.net/develop/
  论坛(http://expert.csdn.net/expert/forum.asp)
  只要您善于使寻功用,你当开中相见的多数问题而是在文档和论坛受到找到答案。假使您于开发进程中遇棘手,而若而看
比尔(Bill)Gates帮不达标你的无暇,那么,你就高达CSDN吧,一定会吃您称心的。
  
教你少只绝招,第一招,是“搜索大法”。境遇题目,首先是以CSDN的文档和论坛举行搜,看起无类似答案。如老,再下一样招。
  
第二导致,“提问大法”,只要暴发礼有诚意地于论坛提问,一定生无数人数肯回答你的题目。

package com.swift.util;

import java.awt.Dimension;
import java.awt.Point;
import java.awt.Toolkit;

public class Center {
    public static Point getPoint(int width,int height) {
        Toolkit toolkit=Toolkit.getDefaultToolkit();//应该是单例
        int screenW=toolkit.getScreenSize().width;
        int screenH=toolkit.getScreenSize().height;
        int x=(screenW-width)/2;
        int y=(screenH-height)/2;
        Point p=new Point(x,y);
        return p;
    }
    //函数的重载,参数是包装类尺寸——Dimension
    public static Point getPoint(Dimension d) {
        Point p=getPoint(d.width,d.height);
        return p;
    }
}

  http://www.dotnet247.com

兑现力量图:

  http://www.startvbdotnet.com

  【孟宪会之精世界】(http://xml.sz.luohuedu.net/xml/) 

  6.任何特色网站、专栏
  CSDN上Latitude的VS.NET专栏(http://www.csdn.net/develop/author/netauthor/Latitude/

  http://www.c-sharpcorner.com/

   ASP酷(http://www.aspcool.com/

  http://www.csharphelp.com/   

  http://www.vbip.com

http://www.webasp.net/

  http://www.gotdotnet.com

  3.另外有关网站
   有成百上千网站开发VS.NET专栏,常错过探访,必起取。
  pconline跟我学NET专栏(http://www.pconline.com.cn/pcedu/empolder/net/

  http://www.only4gurus.com/v2

 

  http://builder.com.com

  http://www.vbcity.com/

  yesky的Visual
Studio.NET专栏(http://www.yesky.com/SoftChannel/72342380467978240/index.shtml

  4.素材下载
  假如未是包月上网,那么下充斥大量资源,再断线渐渐讨论就十分有必不可少了。

  http://www.codeproject.com
  
  http://www.planet-source-code.com/

  http://panopticoncentral.net/

 
网友供的大气VS.NET资源下载(ftp://qydn.vicp.net) 

  http://www.harding.edu/USER/fmccown/WWW/vbnet_csharp_comparison.html

 

  http://www.cnblogs.com/ 博客园

  http://www.devhood.com

  http://dotnet.mblogger.cn

  http://www.syncfusion.com/FAQ/WinForms/

  http://www.aspx8.cn/  asp.net资源吧

  
  
当然,还有一个地人犹清楚的,全球最为老之知识仓库,我弗说,你为都应该了解之,这非是http://www.google.com而且是什么!

  http://www.aspnetpro.com

  http://searchvb.techtarget.com/

  http://www.dotnetgenius.com/

  http://www.datagridgirl.com
   
  http://www.codestudy.com    

  http://www.vbdotnetheaven.com