⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form3.cs

📁 简单的通讯录程序
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace OptDB
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            ClsDB.ClsDBControl Con = new OptDB.ClsDB.ClsDBControl();
            string strSql = "";
            
            if (textBox1.Text == "")
            {
                MessageBox.Show("姓名不能为空!!!");
                textBox1.Text = "";
            }

             if (radioButton1.Text == "" && radioButton2.Text == "")
            {
                MessageBox.Show("性别不能为空!!!");
                 radioButton1.Text = "" ;
                 radioButton2.Text = "";
            }

            if (textBox4.Text == "")
            {
                MessageBox.Show("地址不能为空!!!");
                textBox4.Text = "";
            }

             if (textBox3.Text == "")
            {
                MessageBox.Show("邮编不能为空!!!");
                textBox3.Text = "";
            }

             if (textBox2.Text == "")
            {
                MessageBox.Show("手机号不能为空!!!");
                textBox2.Text = "";
            }

            if (radioButton1.Checked) 
            {
                 strSql = "insert into custom values('" + textBox1.Text + "','" + dateTimePicker1.Text + "','" + radioButton1.Text + "','" + textBox4.Text + "','" + textBox3.Text + "','" + textBox2.Text + "','" + textBox5.Text + "','" + comboBox1.Text + "')";
                 if (Con.insertDB(strSql))
                 {
                   MessageBox.Show("添加成功!!!");
                   this.Dispose();
                 }
            }
            else if (radioButton2.Checked)
            {
                 strSql = "insert into custom values('" + textBox1.Text + "','" + dateTimePicker1.Text + "','" + radioButton2.Text + "','" + textBox4.Text + "','" + textBox3.Text + "','" + textBox2.Text + "','" + textBox5.Text + "','" + comboBox1.Text + "')";
                 if (Con.insertDB(strSql))
                 {
                   MessageBox.Show("添加成功!!!");
                   this.Dispose();
                 }
           }
                
            }

        private void Form3_Load(object sender, EventArgs e)
        {
            // TODO: 这行代码将数据加载到表“wupengDataSet1.group1”中。您可以根据需要移动或移除它。
            this.group1TableAdapter.Fill(this.wupengDataSet1.group1);

        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -