this.txtPasswd.Name = “txtPasswd”;
this.txtPasswd.PasswordChar = ‘*’;
this.txtPasswd.TabIndex = 3;
this.txtPasswd.Text = “”;
//
// btnOK
//
this.btnOK.Location = new System.Drawing.Point(40, 120);
this.btnOK.Name = “btnOK”;
this.btnOK.Size = new System.Drawing.Size(72, 23);
this.btnOK.TabIndex = 4;
this.btnOK.Text = “OK”;
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// btnCancel
//
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point(176, 120);
this.btnCancel.Name = “btnCancel”;
this.btnCancel.TabIndex = 5;
this.btnCancel.Text = “Cancel”;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// Form1
//
this.AcceptButton = this.btnOK;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(298, 167);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOK);
this.Controls.Add(this.txtPasswd);
this.Controls.Add(this.txtUser);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(304, 192);
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(304, 192);
this.Name = “Form1”;
this.ShowInTaskbar = false;
this.Text = “Login”;
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
#endregion
///
/// 应用程序的主入口点 。
/// private void btnCancel_Click(object sender, System.EventArgs e)
{
Application.Exit();
}
private void Form1_Load(object sender, System.EventArgs e)
{
this.SetDesktopLocation(280,180);
}
private void btnOK_Click(object sender, System.EventArgs e)
{
Form2 theOwner = (Form2)this.Owner;
if(this.txtUser.Text == “”)
{
MessageBox.Show(“用户名不能为空!”,”错误”);
}
else if(this.txtPasswd.Text == “”)
{
MessageBox.Show(“密码不能为空!”,”错误”);
}
else
{
if(IsUser(this.txtUser.Text))
{
if(this.txtPasswd.Text == LoginUser(this.txtUser.Text))
{
this.DialogResult = DialogResult.OK;
theOwner.getUserName = this.txtUser.Text;
}
else
{
MessageBox.Show(“用户名或密码错误!”);
}
}
else
{
MessageBox.Show(“用户名或密码错误!”);
}
}
}
private string LoginUser(string User)
{
SqlConnection conn = new SqlConnection(“XXXXXXXX”);
SqlCommand cmd = new SqlCommand();
cmd.CommandType =
CommandType.StoredProcedure;
cmd.CommandText = “Login”;
cmd.Connection = conn;
conn.Open();
SqlParameter parName = new SqlParameter(“@Name”,SqlDbType.VarChar,50);
parName.Value = https://www.scwdwl.com/n/User;
cmd.Parameters.Add(parName);
cmd.ExecuteNonQuery();
conn.Close();
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataSet ds = new DataSet();
da.Fill(ds);
return ds.Tables[0].Rows[0][“UserPasswd”].ToString();
}
private bool IsUser(string User)
{
SqlConnection conn = new SqlConnection(“XXXXXXXX”);
SqlCommand cmd = new SqlCommand();
cmd.CommandType =
CommandType.StoredProcedure;
cmd.CommandText = “IsUser”;
cmd.Connection = conn;
conn.Open();
SqlParameter parName = new SqlParameter(“@UserName”,SqlDbType.VarChar,50);
- 钻展图设计思路,钻展图推广图片的设计技巧?
- 怎样设计房子的装修图 怎样设计
- 404页面怎么制作网页设计404页面技巧和示例?
- 网站设计与SEO的关系,高手是从这4个维度分析的!?
- 怎么给视频添加边框?彩色边框的视频怎么制作? 视频怎么加边框教程
- 换电动车家族设计语言 新款比亚迪唐EV实车曝光
- 新一代奔驰GLC,燃油车最后的“辉煌”,奔驰S级设计语言全下放
- 全新一代蒙迪欧有望四月内上市,全新设计风格,对标日系三剑客?
- 价格微调,二次改款的全新奔驰E,经典外观设计,配2.0T发动机
- 采用复古外观设计 欧拉朋克猫无伪谍照曝光