• 注册
当前位置:1313e > 默认分类 >正文

c# 注册窗体

d button1_Click(object sender, EventArgs e)函数中添加
如下代码: string thisConnectin = "server=XIAOLI-PC\\XIAOLI;Integrated Security=true;database=map";SqlConnection con;con = new SqlConnection(thisConnectin);if (this.CheckInfo()){string cmd = "INSERT INTO tb_user VALUES('" + textBox1.Text + "','" + textBox2.Text + "')";SqlCommand com = new SqlCommand(cmd, con);con.Open();//关?闭?//com.ExecuteNonQuery();if (com.ExecuteNonQuery() != 0)//com.ExecuteNonQuery()执′行D语?句?,?并¢返う?回?受酣?影?响ì行D数簓MessageBox.Show("注痢?册á成é功|!?");elseMessageBox.Show("注痢?册á不?成é功|!?");con.Close();//关?闭?Form3 frm2 = new Form3();frm2.Show();}



 

按钮函数中调用了两个自写的函数Alert()和checkInfo()函数这两个函数的作用是为了确认编辑框中是否为空,以及密码和确认密码的值是否一致。void Alert(string message){MessageBox.Show(null, message, "信?息¢提?示?",MessageBoxButtons.OK, MessageBoxIcon.Information);}bool CheckInfo(){if ( this.textBox1.Text.Trim()== ""){Alert("用?户§名?不?完?整?");return false;}if (this.textBox2.Text.Trim() == ""){Alert("密ü码?不?完?整?");return false;}if (this.textBox3.Text.Trim() == ""){Alert("确ā?认?密ü码?不?完?整?");return false;}if (this.textBox2.Text.Trim ()!= this.textBox3.Text.Trim()){Alert("密ü码?和í确ā?认?密ü码?不?一?致?");return false;}return true;




 

 

本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 162202241@qq.com 举报,一经查实,本站将立刻删除。

最新评论

欢迎您发表评论:

请登录之后再进行评论

登录