Form2.cs
上传用户:miknos
上传日期:2022-04-30
资源大小:802k
文件大小:7k
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using supershop;
- namespace supershop2
- {
- /// <summary>
- /// Form2 的摘要说明。
- /// </summary>
- public class Form2 : System.Windows.Forms.Form
- {
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.TextBox textBox1;
- private System.Windows.Forms.TextBox textBox2;
- private System.Windows.Forms.Button button1;
- private System.Windows.Forms.Button button2;
- private System.Data.SqlClient.SqlConnection sqlConnection1;
- private System.Data.SqlClient.SqlCommand sqlCommand1;
- private System.Windows.Forms.RadioButton radioButton1;
- private System.Windows.Forms.RadioButton radioButton2;
- //public static string name;
- //public static string isman;
-
- /// <summary>
- /// 必需的设计器变量。
- /// </summary>
- private System.ComponentModel.Container components = null;
- public Form2()
- {
- //
- // Windows 窗体设计器支持所必需的
- //
- InitializeComponent();
- //
- // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
- //
- }
- /// <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.label2 = new System.Windows.Forms.Label();
- this.textBox1 = new System.Windows.Forms.TextBox();
- this.textBox2 = new System.Windows.Forms.TextBox();
- this.button1 = new System.Windows.Forms.Button();
- this.button2 = new System.Windows.Forms.Button();
- this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
- this.sqlCommand1 = new System.Data.SqlClient.SqlCommand();
- this.radioButton1 = new System.Windows.Forms.RadioButton();
- this.radioButton2 = new System.Windows.Forms.RadioButton();
- this.SuspendLayout();
- //
- // label1
- //
- this.label1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
- this.label1.Location = new System.Drawing.Point(32, 32);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(64, 23);
- this.label1.TabIndex = 0;
- this.label1.Text = "用户名:";
- //
- // label2
- //
- this.label2.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
- this.label2.Location = new System.Drawing.Point(32, 72);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(64, 23);
- this.label2.TabIndex = 1;
- this.label2.Text = "密 码:";
- //
- // textBox1
- //
- this.textBox1.Location = new System.Drawing.Point(112, 32);
- this.textBox1.Name = "textBox1";
- this.textBox1.Size = new System.Drawing.Size(136, 21);
- this.textBox1.TabIndex = 2;
- this.textBox1.Text = "";
- this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
- //
- // textBox2
- //
- this.textBox2.Location = new System.Drawing.Point(112, 72);
- this.textBox2.Name = "textBox2";
- this.textBox2.PasswordChar = '*';
- this.textBox2.Size = new System.Drawing.Size(136, 21);
- this.textBox2.TabIndex = 3;
- this.textBox2.Text = "";
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(40, 144);
- this.button1.Name = "button1";
- this.button1.TabIndex = 4;
- this.button1.Text = "确 定";
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // button2
- //
- this.button2.Location = new System.Drawing.Point(152, 144);
- this.button2.Name = "button2";
- this.button2.TabIndex = 5;
- this.button2.Text = "取 消";
- this.button2.Click += new System.EventHandler(this.button2_Click);
- //
- // sqlConnection1
- //
- this.sqlConnection1.ConnectionString = "workstation id=MICROSOFTPANG;packet size=4096;integrated security=SSPI;data sourc" +
- "e=MICROSOFTPANG;persist security info=False;initial catalog=supershop";
- //
- // radioButton1
- //
- this.radioButton1.Checked = true;
- this.radioButton1.Location = new System.Drawing.Point(32, 104);
- this.radioButton1.Name = "radioButton1";
- this.radioButton1.TabIndex = 6;
- this.radioButton1.TabStop = true;
- this.radioButton1.Text = "销售人员";
- //
- // radioButton2
- //
- this.radioButton2.Location = new System.Drawing.Point(144, 104);
- this.radioButton2.Name = "radioButton2";
- this.radioButton2.TabIndex = 7;
- this.radioButton2.Text = "管理人员";
- //
- // Form2
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
- this.ClientSize = new System.Drawing.Size(272, 190);
- this.ControlBox = false;
- this.Controls.Add(this.radioButton2);
- this.Controls.Add(this.radioButton1);
- this.Controls.Add(this.button2);
- this.Controls.Add(this.button1);
- this.Controls.Add(this.textBox2);
- this.Controls.Add(this.textBox1);
- this.Controls.Add(this.label2);
- this.Controls.Add(this.label1);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.Name = "Form2";
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- this.Text = "登录";
- this.TopMost = true;
- this.ResumeLayout(false);
- }
- #endregion
- private void button1_Click(object sender, System.EventArgs e)
- {
- string uname=textBox1.Text;
- string pwd=textBox2.Text;
- if(radioButton1.Checked)
- {
- this.sqlCommand1.CommandText="select * from login where uname = '"+uname+"' and pwd = '"+pwd+"' and ismanage='no'";
- }
- else if(radioButton2.Checked)
- {
- this.sqlCommand1.CommandText="select * from login where uname = '"+uname+"' and pwd = '"+pwd+"' and ismanage='yes'";
- }
- this.sqlCommand1.Connection=this.sqlConnection1;
- this.sqlConnection1.Open();
- try
- {
- System.Data.SqlClient.SqlDataReader MyReader = this.sqlCommand1.ExecuteReader();
- MyReader.Read();
- string name=MyReader.GetValue(1).ToString();
- string isman=MyReader.GetValue(3).ToString();
- //supershop.Form1.
- //string id=flog.ToString();
- this.Visible=false;
- supershop.Form1.name=name;
- supershop.Form1.isman=isman;
- //pictureBox1.Visible=true;
- //label1.Visible=false;
- //label2.Visible=false;
- //textBox1.Visible=false;
- //textBox2.Visible=false;
- //button1.Visible=false;
- //button2.Visible=false;
- //label3.Visible=true;
- //timer1.Enabled=true;
- //char ss=(char)flog;
- //textBox3.Text=flog;
- //textBox3.Text=atoi(flog);
- //textBox3.Text=flog.ToString();
- //textBox3.Text="no username or passward!";
- }
- catch(Exception err)
- {
- this.sqlConnection1.Close();
- MessageBox.Show("该用户不存在","信息提示",
- MessageBoxButtons.OK,MessageBoxIcon.Information);
- return;
- }
- this.sqlConnection1.Close();
- this.Close();
- }
- private void button2_Click(object sender, System.EventArgs e)
- {
- Application.Exit();
- }
- private void textBox1_TextChanged(object sender, System.EventArgs e)
- {
-
- }
- }
- }