简单的用户登陆

作者在 2007-05-11 19:42:00 发布以下内容

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;

namespace WindowsApplication1
{
 /// <summary>
 /// Form1 的摘要说明。
 /// </summary>
 public class login : System.Windows.Forms.Form
 {
  private System.Windows.Forms.Label label1;
  private System.Windows.Forms.Label label3;
  private System.Windows.Forms.TextBox textName;
  private System.Windows.Forms.Label label4;
  private System.Windows.Forms.TextBox textPassword;
  private System.Windows.Forms.Button buttonOK;
  /// <summary>
  /// 必需的设计器变量。
  /// </summary>
  private System.ComponentModel.Container components = null;
  private System.Windows.Forms.Button buttonCancel;

  private DataSet myDataSet = null;

  public DataSet MyDataSet
  {
   get
   {return myDataSet;}
   set
   {myDataSet = ;}
  }

  private DataSet LoadDataSet()
  {
   SqlConnection con = new SqlConnection("server = .; uid = sa;pwd = sa; database = YT_action;");
   con.Open();
   //SqlDataAdapter da = new SqlDataAdapter("select UserName,UserPassword from YT_user where UserName = '"+ this.textName.Text.Trim()+"' and UserPassword = '" + this.textPassword.Text.Trim() +"'" ,con);
   SqlDataAdapter da = new SqlDataAdapter("select * from YT_user",con);
   DataSet ds = new DataSet();
   da.Fill(ds,"YT_user");

   return ds;
  }

  public login()
  {
   //
   // Windows 窗体设计器支持所必需的
   //
   InitializeComponent();
   Init();

   //
   // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
   //
  }
  public void Init()
  {
   MyDataSet = LoadDataSet();
  }

  /// <summary>
  /// 清理所有正在使用的资源。
  /// </summary>
  protected override void Dispose( bool disposing )
  {
   if( disposing )
   {
    if (components != null)
    {
     components.Dispose();
    }
   }
   base.Dispose( disposing );
  }

  #region Windows 窗体设计器生成的代码
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// </summary>
  private void InitializeComponent()
  {
   this.label1 = new System.Windows.Forms.Label();
   this.label3 = new System.Windows.Forms.Label();
   this.textName = new System.Windows.Forms.TextBox();
   this.label4 = new System.Windows.Forms.Label();
   this.textPassword = new System.Windows.Forms.TextBox();
   this.buttonOK = new System.Windows.Forms.Button();
   this.buttonCancel = new System.Windows.Forms.Button();
   this.SuspendLayout();
   //
   // label1
   //
   this.label1.Font = new System.Drawing.Font("楷体_GB2312", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
   this.label1.Location = new Syste

C# | 阅读 1031 次
文章评论,共0条
游客请输入验证码
最新评论