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

📄 zengjia.cs

📁 火车票的销售系统
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;


namespace pwxt
{
    public partial class zengjia : Form
    {
        public zengjia()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
          
            string luxian=label4.Text+"-"+zm1.Text+"-"+zm2.Text+"-"+zm3.Text+"-"+zm4.Text+"-"+zm5.Text;
            string itlc1="Insert into LCtable values('" + this.label4.Text+"','" + this.cc.Text +"','" + this.qzt.Text+"','"+this.label7.Text+"')";
            string itlc2="Insert into LCtable values('"+this.zm1.Text+"','"+this.cc.Text+"','"+this.zmt1.Text+"','"+this.zmj1.Text+"')";
            string itlc3="Insert into LCtable values('"+this.zm2.Text+"','"+this.cc.Text+"','"+this.zmt2.Text+"','"+this.zmj2.Text+"')";
            string itlc4="Insert into LCtable values('"+this.zm3.Text+"','"+this.cc.Text+"','"+this.zmt3.Text+"','"+this.zmj3.Text+"')";
            string itlc5="Insert into LCtable values('"+this.zm4.Text+"','"+this.cc.Text+"','"+this.zmt4.Text+"','"+this.zmj4.Text+"')";
            string itlc6="Insert into LCtable values('"+this.zm5.Text+"','"+this.cc.Text+"','"+this.zmt5.Text+"','"+this.zmj5.Text+"')";
            string itlc7="Insert into Lxtable values('"+this.cc.Text+"','"+this.qzt.Text+"','"+luxian+"')";
            SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["connectionstring"]);
            SqlCommand cmd1 = new SqlCommand (itlc1,conn);
            SqlCommand cmd2 = new SqlCommand (itlc2,conn);
            SqlCommand cmd3 = new SqlCommand (itlc3,conn);
            SqlCommand cmd4 = new SqlCommand (itlc4,conn);
            SqlCommand cmd5 = new SqlCommand (itlc5,conn);
            SqlCommand cmd6 = new SqlCommand (itlc6,conn);
            SqlCommand cmd7 = new SqlCommand (itlc7,conn);
            conn.Open();
            try
            {
                cmd1.ExecuteNonQuery();
                if (zm1.Text != "")
                    cmd2.ExecuteNonQuery();
                if (zm2.Text != "")
                    cmd3.ExecuteNonQuery();
                if (zm3.Text != "")
                    cmd4.ExecuteNonQuery();
                if (zm4.Text != "")
                    cmd5.ExecuteNonQuery();
                if (zm5.Text != "")
                    cmd6.ExecuteNonQuery();
                cmd7.ExecuteNonQuery();
                MessageBox.Show("添加成功", "添加成功页面", MessageBoxButtons.OK);
            }
            catch (Exception e2)
            {

                MessageBox.Show(e2.Message);
            }
            conn.Close();

        }

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

      
    }
}

⌨️ 快捷键说明

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