• 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("注痢?册á成é功|!?");
                    else
                        MessageBox.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;
            




  • 相关阅读:
    urllib.request.urlretrieve()
    python2.X与python3.X爬虫常用的模块变化对应
    .net 发布程序时出现“类型ASP.global_asax同时存在于...”错误的解决办法
    批量引用iconfont字体图标到项目
    动态设置bootstrapswitch状态
    MD5加密过时方法替换
    SQL语句
    PHP中的闭包
    算法复杂度
    快速排序
  • 原文地址:https://www.cnblogs.com/xinyuyuanm/p/2990542.html
Copyright © 2020-2023  润新知