Example #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            MyMeans.SQLstr = "Select * from 临时限速命令";
            DataSet ds = MyMeans.GetDataSet(MyMeans.SQLstr);

            dataGridView1.DataSource = ds.Tables[0];
        }
Example #2
0
        private void 编辑ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            button4.Enabled      = true;
            button5.Enabled      = true;
            isChongxinBj         = 1;
            textBox2.Text        = dataGridView1.SelectedCells[0].Value.ToString();
            comboBox1.Text       = dataGridView1.SelectedCells[1].Value.ToString();
            textBox4.Text        = dataGridView1.SelectedCells[2].Value.ToString();
            textBox5.Text        = dataGridView1.SelectedCells[3].Value.ToString();
            dateTimePicker1.Text = dataGridView1.SelectedCells[4].Value.ToString();
            richTextBox1.Text    = dataGridView1.SelectedCells[5].Value.ToString();
            textBox3.Text        = "未发送";
            string  StrNumber = dataGridView1.SelectedCells[0].Value.ToString();
            DataSet ds;

            ds = MyMeans.GetDataSet("select*from shoulinglb");
            dataGridView4.DataSource = ds.Tables[0];

            for (int i = 0; i < (dataGridView4.Rows.Count - 1); i++)//受令列表中实际为6行,但只有5个受令车站,故i最大为5;
            {
                //注意每次遍历都需要重新从数据库中的读取受令单位,因为Read()方法是读取到SqlDataReader的下一条记录;
                MyMeans.SQLstr = "Select 受令单位,签收状态,签收人,签收时间 from 受令车站对应表 where 命令编号=" + StrNumber;
                SqlDataReader Sds = MyMeans.GgtDataReader(MyMeans.SQLstr);
                while (Sds.Read())
                {
                    string a = dataGridView4.Rows[i].Cells[1].Value.ToString().Trim();
                    string b = Sds[0].ToString().Trim();
                    if (b == a)
                    {
                        DataGridViewCheckBoxCell dgvCheckBoxCell_1 = dataGridView4.Rows[i].Cells[0] as DataGridViewCheckBoxCell;
                        dgvCheckBoxCell_1.Value = 1;
                    }
                }
            }
        }
Example #3
0
        private void button7_Click(object sender, EventArgs e)
        {
            button4.Enabled   = true;
            button5.Enabled   = true;
            textBox2.Text     = "";
            textBox4.Text     = "";
            textBox5.Text     = "";
            comboBox1.Text    = "";
            richTextBox1.Text = "";
            MyMeans.SQLstr    = "select*from shoulinglb";
            DataSet ds = MyMeans.GetDataSet(MyMeans.SQLstr);

            dataGridView4.DataSource = ds.Tables[0];
            for (int i = 0; i < dataGridView4.Rows.Count; i++)
            {
                dataGridView4.Rows[i].Cells[0].Value = "0";
            }
            DataSet dss;

            dss = MyMeans.GetDataSet("Select*from fasongml");
            dataGridView2.DataSource = dss.Tables[0];
            MyMeans.Close();
            dss = MyMeans.GetDataSet("Select*from yifaml");
            dataGridView3.DataSource = dss.Tables[0];
        }
Example #4
0
        private void dataGridView2_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
        {
            textBox2.Text        = dataGridView2.SelectedCells[0].Value.ToString();
            comboBox1.Text       = dataGridView2.SelectedCells[1].Value.ToString();
            textBox4.Text        = dataGridView2.SelectedCells[2].Value.ToString();
            textBox5.Text        = dataGridView2.SelectedCells[3].Value.ToString();
            dateTimePicker1.Text = dataGridView2.SelectedCells[4].Value.ToString();
            richTextBox1.Text    = dataGridView2.SelectedCells[5].Value.ToString();
            textBox3.Text        = "已发送";
            string  StrNumber = dataGridView2.SelectedCells[0].Value.ToString();
            DataSet ds;

            ds = MyMeans.GetDataSet("select 受令单位,签收状态,签收人,签收时间,签收结果 from 受令车站对应表 where 命令编号='" + StrNumber + "'");
            dataGridView4.DataSource = ds.Tables[0];

            for (int i = 0; i < (dataGridView4.Rows.Count - 1); i++)//受令列表中实际为6行,但只有5个受令车站,故i最大为5;
            {
                //注意每次遍历都需要重新从数据库中的读取受令单位,因为Read()方法是读取到SqlDataReader的下一条记录;
                MyMeans.SQLstr = "Select 受令单位,签收状态,签收人,签收时间 from 受令车站对应表 where 命令编号='" + StrNumber + "'";
                SqlDataReader Sds = MyMeans.GgtDataReader(MyMeans.SQLstr);
                while (Sds.Read())
                {
                    string a = dataGridView4.Rows[i].Cells[1].Value.ToString().Trim();
                    string b = Sds[0].ToString().Trim();
                    if (b == a)
                    {
                        DataGridViewCheckBoxCell dgvCheckBoxCell_1 = dataGridView4.Rows[i].Cells[0] as DataGridViewCheckBoxCell;
                        dgvCheckBoxCell_1.Value = 1;
                    }
                }
            }
            button4.Enabled = false;
            button5.Enabled = false;
        }
Example #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            MyMeans.SQLstr = "Insert into mlmoban values ('" + textBox1.Text.Trim() + "','" + textBox2.Text.Trim() + "','" + richTextBox1.Text.Trim() + "')";
            MyMeans.ExecuteSql(MyMeans.SQLstr);
            MessageBox.Show("增加成功");
            Form5 form5 = new Form5();

            textBox2.Text     = "";
            richTextBox1.Text = "";
            int Temple_BH = 1;

            MyMeans.SQLstr = "select* from mlmoban";
            SqlDataReader Sdr = MyMeans.GgtDataReader(MyMeans.SQLstr);

            while (Sdr.Read())
            {
                if (int.Parse(Sdr[0].ToString()) > Temple_BH)
                {
                    Temple_BH = int.Parse(Sdr[0].ToString());
                }
            }
            Temple_BH++;
            textBox1.Text = Temple_BH.ToString();
            textBox2.Focus();
        }
Example #6
0
        private void Form2_Load(object sender, EventArgs e)
        {
            //设置为允许跨线程调用空间
            Control.CheckForIllegalCrossThreadCalls = false;

            DataSet ds;

            ds = MyMeans.GetDataSet("Select*from daifaml");
            dataGridView1.DataSource = ds.Tables[0];
            MyMeans.Close();
            ds = MyMeans.GetDataSet("Select*from fasongml");
            dataGridView2.DataSource = ds.Tables[0];
            MyMeans.Close();
            ds = MyMeans.GetDataSet("Select*from yifaml");
            dataGridView3.DataSource = ds.Tables[0];
            MyMeans.Close();
            ds = MyMeans.GetDataSet("Select*from shoulinglb");
            dataGridView4.DataSource = ds.Tables[0];
            MyMeans.Close();

            MyMeans.linq = new linqtosqlClassDataContext(MyMeans.Constr);
            var result = from items in MyMeans.linq.mlmoban
                         select new
            {
                Number  = items.模板编号,
                LeiXing = items.命令类型,
                NeiRong = items.命令内容,
            };

            foreach (var item in result)
            {
                comboBox1.Items.Add(item.LeiXing);
            }
            SqlDataReader Sdr;

            MyMeans.SQLstr = "select*from changyongch";
            Sdr            = MyMeans.GgtDataReader(MyMeans.SQLstr);
            while (Sdr.Read())
            {
                listBox1.Items.Add(Sdr[0]);
            }

            try //连接服务器,若连接成功,通信状态显示为“通信正常”;
            {
                socket.Connect(IPP);
                string SendStr = "行调系统";
                byte[] Bs      = Encoding.UTF8.GetBytes(SendStr);
                socket.Send(Bs, Bs.Length, 0);
                label7.Text             = "通信正常";
                jieshouMsg              = new Thread(new ThreadStart(RecMsg));
                jieshouMsg.IsBackground = true;
                jieshouMsg.Start();
            }
            catch
            {
            }
            textBox4.Text = Form1.Uers_Now;
        }
Example #7
0
        private void button6_Click(object sender, EventArgs e)
        {
            Number_ML = 6000;
            SqlDataReader Sdr;

            MyMeans.SQLstr = "select*from daifaml";
            Sdr            = MyMeans.GgtDataReader(MyMeans.SQLstr);
            while (Sdr.Read())
            {
                if (int.Parse(Sdr[0].ToString().Trim()) > Number_ML)
                {
                    Number_ML = int.Parse(Sdr[0].ToString());
                }
            }
            MyMeans.SQLstr = "select*from fasongml";
            Sdr            = MyMeans.GgtDataReader(MyMeans.SQLstr);
            while (Sdr.Read())
            {
                if (int.Parse(Sdr[0].ToString().Trim()) > Number_ML)
                {
                    Number_ML = int.Parse(Sdr[0].ToString());
                }
            }
            MyMeans.SQLstr = "select*from yifaml";
            Sdr            = MyMeans.GgtDataReader(MyMeans.SQLstr);
            while (Sdr.Read())
            {
                if (int.Parse(Sdr[0].ToString().Trim()) > Number_ML)
                {
                    Number_ML = int.Parse(Sdr[0].ToString());
                }
            }
            Number_ML++;
            textBox2.Text = Number_ML.ToString();

            textBox4.Text = Form1.Uers_Now;
            textBox5.Text = "调度台";
            //加载模板内容
            MyMeans.linq = new linqtosqlClassDataContext(MyMeans.Constr);    //创建LINQ连接对象
            String StrLeiXing = comboBox1.Text;                              //获取选中的命令模板
            //根据选中的命令模板获取其详细信息
            var result = from items in MyMeans.linq.mlmoban
                         where items.命令类型 == StrLeiXing
                         select new
            {
                Number  = items.模板编号,
                命令类型    = items.命令类型,
                NeiRong = items.命令内容
            };

            //在命令内容正文控件中显示选中命令模板的命令内容
            foreach (var item in result)
            {
                richTextBox1.Text = item.NeiRong.ToString();
            }
        }
Example #8
0
        private void button4_Click(object sender, EventArgs e)      //点击“关闭”按钮,关闭命令模块界面
        {
            MyMeans.SQLstr = "select*from mlmoban";
            DataSet ds = MyMeans.GetDataSet(MyMeans.SQLstr);

            dataGridView1.DataSource = ds.Tables[0];
            richTextBox1.Text        = "";
            textBox1.Text            = "";
            textBox2.Text            = "";
        }
Example #9
0
        private void  除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string SC_ml = dataGridView1.SelectedCells[0].Value.ToString().Trim();

            MyMeans.SQLstr = "Delete from daifaml where 命令编号=" + int.Parse(SC_ml);
            MyMeans.ExecuteSql(MyMeans.SQLstr);
            MyMeans.SQLstr = "Select*from daifaml";
            DataSet ds = MyMeans.GetDataSet(MyMeans.SQLstr);

            dataGridView1.DataSource = ds.Tables[0];
        }
Example #10
0
 private void button1_Click(object sender, EventArgs e)
 {
     mlbh = textBox6.Text.Trim();
     mllx = comboBox1.Text.Trim();
     slcz = comboBox2.Text.Trim();
     xl   = comboBox3.Text.Trim();
     qsz  = comboBox4.Text.Trim();
     jsz  = comboBox5.Text.Trim();
     xsqd = textBox1.Text.Trim() + "km" + textBox2.Text.Trim() + "m";
     xszd = textBox3.Text.Trim() + "km" + textBox4.Text.Trim() + "m";
     xsyy = textBox5.Text.Trim();
     if (checkBox1.CheckState == CheckState.Checked)
     {
         xsxt = "列控中心";
     }
     if (checkBox2.CheckState == CheckState.Checked)
     {
         xsxt += " RBC";
     }
     kssj = dateTimePicker1.Text;
     jssj = dateTimePicker2.Text;
     xsnr = comboBox7.Text;
     // 如果所有信息填写完整,则完成新建命令,将命令插入到数据库中
     if (mlbh != "" && mllx != "" && slcz != "" && xl != "" && qsz != "" && jsz != "" && xsqd != "" && xszd != "" && xsyy != "" && xsxt != "" && kssj != "" && jssj != "" && xsnr != "")
     {
         MyMeans.SQLstr = "Insert Into 临时限速命令 Values('" + int.Parse(mlbh) + "','" + mllx + "','" + slcz + "','" + xl + "','" + qsz + "','" + jsz + "','" + xsqd + "','" + xszd + "','" + xsyy + "','" + xsxt + "','" + kssj + "','" + jssj + "','" + xsnr + "',null)";
         MyMeans.ExecuteSql(MyMeans.SQLstr);
         MyMeans.SQLstr = "Select * from 临时限速命令";
         DataSet ds = null;
         ds = MyMeans.GetDataSet(MyMeans.SQLstr);
         dataGridView1.DataSource = ds.Tables[0];
         comboBox1.Text           = "";
         comboBox2.Text           = "";
         comboBox3.Text           = "";
         comboBox4.Text           = "";
         comboBox5.Text           = "";
         comboBox6.Text           = "";
         comboBox7.Text           = "";
         textBox1.Text            = "";
         textBox2.Text            = "";
         textBox3.Text            = "";
         textBox4.Text            = "";
         textBox5.Text            = "";
         textBox6.Text            = "";
         checkBox1.CheckState     = CheckState.Unchecked;
         checkBox2.CheckState     = CheckState.Unchecked;
     }
     else
     {
         MessageBox.Show("请补全命令内容");
     }
 }
Example #11
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (listBox1.SelectedItems.Count == 0)
     {
         MessageBox.Show("请选择要删除的数据");
     }
     else
     {
         MyMeans.SQLstr = "delete from changyongch where 常用词汇='" + listBox1.SelectedItem + "'";
         MyMeans.ExecuteSql(MyMeans.SQLstr);
         listBox1.Items.Remove(listBox1.SelectedItem);
     }
 }
Example #12
0
        private void Form4_Load(object sender, EventArgs e)
        {
            MyMeans.SQLstr = "Select * from 临时限速命令";
            DataSet ds = null;

            ds = MyMeans.GetDataSet(MyMeans.SQLstr);
            dataGridView1.DataSource = ds.Tables[0];
            comboBox7.Items.Add("45");
            comboBox7.Items.Add("60");
            comboBox7.Items.Add("80");
            comboBox7.Items.Add("120");
            comboBox7.Items.Add("160");
            comboBox7.Items.Add("255");
        }
Example #13
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (textBox1.Text == "")
     {
         MessageBox.Show("请输入要添加的数据");
     }
     else
     {
         MyMeans.SQLstr = "Insert into changyongch values('" + textBox1.Text + "')";
         MyMeans.ExecuteSql(MyMeans.SQLstr);
         listBox1.Items.Add(textBox1.Text);
         textBox1.Text = "";
     }
 }
Example #14
0
        private void Form3_Load(object sender, EventArgs e)
        {
            int Temple_BH = 1;

            MyMeans.SQLstr = "select* from mlmoban";
            SqlDataReader Sdr = MyMeans.GgtDataReader(MyMeans.SQLstr);

            while (Sdr.Read())
            {
                if (int.Parse(Sdr[0].ToString()) > Temple_BH)
                {
                    Temple_BH = int.Parse(Sdr[0].ToString());
                }
            }
            Temple_BH++;
            textBox1.Text = Temple_BH.ToString();
            textBox2.Focus();
        }
Example #15
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (a + b + c + d + f == 5)    //判断a、b、c、d、f的和是否等于5,若为5表示5个文本框都为非空;
     {
         try
         {
             MyMeans.SQLstr = "Select * from yonghu where WorkNumber =" + int.Parse(textBox1.Text.Trim());
             SqlDataReader read = MyMeans.GgtDataReader(MyMeans.SQLstr);
             //判断对应输入的工号是否查询到用户数据,如果查询到继续执行命令;
             if (read.Read())
             {
                 //判断对应输入工号的用户名和密码是否输入正确;
                 if (textBox2.Text.Trim() == read[0].ToString().Trim() & textBox3.Text.Trim() == read[2].ToString().Trim())
                 {
                     //判断两次新密码输入是否一致;
                     if (textBox4.Text == textBox5.Text)
                     {
                         MyMeans.SQLstr = "Update yonghu Set Password="******"where WorkNumber=" + int.Parse(textBox1.Text.Trim());
                         MyMeans.ExecuteSql(MyMeans.SQLstr);
                         MessageBox.Show("修改成功");
                     }
                     else
                     {
                         MessageBox.Show("新密码输入不一致");
                     }
                 }
                 else
                 {
                     MessageBox.Show("用户信息输入错误");
                 }
             }
             //如果根据输入的“工号”没有查询到用户信息,则显示“用户信息输入错误”;
             else
             {
                 MessageBox.Show("用户信息输入错误");
             }
         }
         catch { }
     }
     else
     {
         MessageBox.Show("请将信息输入完整");
     }
 }
Example #16
0
        private void  达ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            byte[] sendByts = new byte[1024];
            //发送调度命令给服务器
            string sendStr = dataGridView1.SelectedCells[0].Value.ToString().Trim() + "#" + dataGridView1.SelectedCells[1].Value.ToString().Trim() + "#" + dataGridView1.SelectedCells[3].Value.ToString().Trim() + "#" + dateTimePicker1.Text.Trim() + "#" + dataGridView1.SelectedCells[5].Value.ToString().Trim();

            sendByts = Encoding.UTF8.GetBytes(sendStr);
            socket.Send(sendByts, sendByts.Length, 0);
            //发送受令车站信息给服务器;
            string SC_ml = dataGridView1.SelectedCells[0].Value.ToString().Trim();

            MyMeans.SQLstr = "select*from 受令车站对应表 where 命令编号=" + int.Parse(SC_ml);
            SqlDataReader read      = MyMeans.GgtDataReader(MyMeans.SQLstr);
            string        SLchezhan = null;

            while (read.Read())
            {
                SLchezhan += (read[1].ToString().Trim() + "#");
            }
            sendByts = Encoding.UTF8.GetBytes(SLchezhan);
            socket.Send(sendByts, sendByts.Length, 0);
            MessageBox.Show("命令发送成功");

            DataSet ds;

            MyMeans.SQLstr = "Insert into fasongml(命令编号,命令类型,调度员姓名,发令单位,发令时间,命令内容,当前状态)values(" + int.Parse(SC_ml) + ",'" + dataGridView1.SelectedCells[1].Value.ToString().Trim() + "','" + dataGridView1.SelectedCells[2].Value.ToString().Trim() + "','" + dataGridView1.SelectedCells[3].Value.ToString().Trim() + "','" + dateTimePicker1.Text.Trim() + "','" + dataGridView1.SelectedCells[5].Value.ToString().Trim() + "','已发送')";// 注意圆括号中的 , 用英文形式
            MyMeans.ExecuteSql(MyMeans.SQLstr);
            ds = MyMeans.GetDataSet("Select*from fasongml");
            dataGridView2.DataSource = ds.Tables[0];
            MyMeans.Close();


            MyMeans.SQLstr = "Delete from daifaml where 命令编号=" + int.Parse(SC_ml);
            MyMeans.ExecuteSql(MyMeans.SQLstr);
            MyMeans.SQLstr           = "Select*from daifaml";
            ds                       = MyMeans.GetDataSet(MyMeans.SQLstr);
            dataGridView1.DataSource = ds.Tables[0];
        }
Example #17
0
        private void button1_Click(object sender, EventArgs e)
        {   //得到现在限速系统的文本,赋给变量XSXT;
            string XSXT = null;

            if (checkBox1.CheckState == CheckState.Checked)
            {
                XSXT = "列控中心";
            }
            if (checkBox2.CheckState == CheckState.Checked)
            {
                XSXT += " RBC";
            }
            //逐一比较指定限速命令的各个信息与现在编辑的信息是否一致;
            if (Form4.mlbh == textBox6.Text.Trim())
            {
                a = true;
            }
            else
            {
                a = false;
            }
            if (Form4.mllx == comboBox1.Text.Trim())
            {
                b = true;
            }
            else
            {
                b = false;
            }
            if (Form4.slcz == comboBox2.Text.Trim())
            {
                c = true;
            }
            else
            {
                c = false;
            }
            if (Form4.xl == comboBox3.Text.Trim())
            {
                d = true;
            }
            else
            {
                d = false;
            }
            if (Form4.qsz == comboBox4.Text.Trim())
            {
                f = true;
            }
            else
            {
                f = false;
            }
            if (Form4.jsz == comboBox5.Text.Trim())
            {
                g = true;
            }
            else
            {
                g = false;
            }
            if (Form4.xsqd == textBox1.Text.Trim() + "km" + textBox2.Text.Trim() + "m")
            {
                h = true;
            }
            else
            {
                h = false;
            }
            if (Form4.xszd == textBox3.Text.Trim() + "km" + textBox4.Text.Trim() + "m")
            {
                i = true;
            }
            else
            {
                i = false;
            }
            if (Form4.xsyy == textBox5.Text.Trim())
            {
                j = true;
            }
            else
            {
                j = false;
            }
            if (Form4.xsxt == XSXT)
            {
                k = true;
            }
            else
            {
                k = false;
            }
            if (Form4.kssj == dateTimePicker1.Text)
            {
                l = true;
            }
            else
            {
                l = false;
            }
            if (Form4.jssj == dateTimePicker2.Text)
            {
                m = true;
            }
            else
            {
                m = false;
            }
            if (Form4.xsnr == comboBox7.Text.Trim())
            {
                n = true;
            }
            else
            {
                n = false;
            }
            if (a == true & b == true & c == true & d == true & f == true & g == true & h == true & i == true & j == true & k == true & n == true)
            {
                MyMeans.SQLstr = "Update 临时限速命令 Set 是否检验='检验通过' where 命令编号='" + int.Parse(Form4.mlbh) + "'";
                MyMeans.ExecuteSql(MyMeans.SQLstr);
                MessageBox.Show("检验通过");
            }
        }
Example #18
0
        //接受车站发来的签收状态
        public void RecMsg()
        {
            int i = 0;  //0表示某条调度命令所有受令车站均已签收,1表示存在受令车站没有签收;

            while (true)
            {
                byte[]   Msg        = new byte[1024];
                int      Bytes      = 1;
                string   receiveMsg = null;
                char[]   fenge      = { '#' };
                string[] msg;
                try
                {
                    Bytes = socket.Receive(Msg, Msg.Length, 0);
                    if (Bytes == 0)
                    {
                        label7.Text = "通信断开";
                        socket.Close();
                        //在调用Abort()方法的线程上引发ThreadAbortException异常,以开始终止线程。
                        //即调用此方法会自动引发一个异常,程序便运行到catch语句块
                        Thread.CurrentThread.Abort();
                    }
                }
                catch (Exception ex)
                {
                    //GetType()获取当前实例的运行类型
                    //typeof()活动类型声明的泛型类型
                    if (ex.GetType() == typeof(ThreadAbortException))    //如果捕捉到的异常为ThreadAbortException异常,则什么都不做
                    {
                    }
                    else
                    {
                        label7.Text = "通信断开";
                        socket.Close();
                        Thread.CurrentThread.Abort();
                    }
                }

                receiveMsg = Encoding.UTF8.GetString(Msg, 0, Bytes);
                msg        = receiveMsg.Split(fenge);
                if (msg[0] == "断开")    //如果服务器发来的是断开通信连接的信息,则终止线程;
                {
                    label7.Text = "通信断开";
                    socket.Close();
                    Thread.CurrentThread.Abort(); //获取当前正在运行的线程,并将其终止;
                }
                else
                {
                    //根据命令编号和受令单位更新 调度命令的相应车站的签收状态
                    MyMeans.SQLstr = "Update 受令车站对应表 Set 签收状态='签收',签收人='" + msg[2] + "',签收时间='" + msg[3] + "',签收结果='" + msg[4] + "'where 命令编号=" + int.Parse(msg[0]) + "and 受令单位='" + msg[1] + "'";
                    MyMeans.ExecuteSql(MyMeans.SQLstr);
                    MyMeans.SQLstr = "select*from 受令车站对应表 where 命令编号=" + int.Parse(msg[0]);
                    SqlDataReader Sdr = MyMeans.GgtDataReader(MyMeans.SQLstr);
                    while (Sdr.Read())
                    {
                        //如果有受令车站没有签收,将i置为1;
                        if (Sdr[2].ToString().Trim() == "")
                        {
                            i = 1;
                        }
                    }
                    if (i == 0)  //i=0表示所有车站均已签收;
                    {
                        MyMeans.SQLstr = "select*from fasongml where 命令编号=" + int.Parse(msg[0]);
                        SqlDataReader read = MyMeans.GgtDataReader(MyMeans.SQLstr);
                        read.Read();
                        MyMeans.SQLstr = "Insert into yifaml(命令编号,命令类型,调度员姓名,发令单位,发令时间,命令内容,签收状态)values(" + int.Parse(read[0].ToString().Trim()) + ",'" + read[1].ToString().Trim() + "','" + read[2].ToString().Trim() + "','" + read[3].ToString().Trim() + "','" + read[4].ToString().Trim() + "','" + read[5].ToString().Trim() + "','全部签收')";
                        MyMeans.ExecuteSql(MyMeans.SQLstr);
                        MyMeans.SQLstr = "Delete from fasongml where 命令编号=" + int.Parse(msg[0]);
                        MyMeans.ExecuteSql(MyMeans.SQLstr);
                    }
                    DataSet ds;

                    ds = MyMeans.GetDataSet("Select*from fasongml");
                    dataGridView2.DataSource = ds.Tables[0];
                    MyMeans.Close();
                    ds = MyMeans.GetDataSet("Select*from yifaml");
                    dataGridView3.DataSource = ds.Tables[0];
                    MyMeans.Close();
                }
            }
        }
Example #19
0
        private void button4_Click(object sender, EventArgs e)            //“保存”按钮,点击将当前调度命令保存到待发箱
        {
            int    a = 0, b = 0, c = 0, d = 0, f = 0, g = 0, h = 0;
            string SLchezhan = null;

            for (int i = 0; i < dataGridView4.Rows.Count; i++)
            {
                DataGridViewCheckBoxCell dgvCheckBoxCell = dataGridView4.Rows[i].Cells[0] as DataGridViewCheckBoxCell; //获取DataGridViewCheckBoxCell对象;

                if (dgvCheckBoxCell.Value == "1")                                                                      //判断该DataGridViewCheckBoxCell是否选中;
                {
                    SLchezhan += (dataGridView4.Rows[i].Cells[1].Value.ToString().Trim() + "#");
                }
            }
            if (textBox2.Text.Trim() != "")
            {
                a = 1;
            }
            if (comboBox1.Text.Trim() != "")
            {
                b = 1;
            }
            if (textBox4.Text.Trim() != "")
            {
                c = 1;
            }
            if (textBox5.Text.Trim() != "")
            {
                d = 1;
            }
            if (dateTimePicker1.Text != "")
            {
                f = 1;
            }
            if (richTextBox1.Text.Trim() != "")
            {
                g = 1;
            }
            if (SLchezhan != "")
            {
                h = 1;
            }
            if (a == 1 & b == 1 & c == 1 & d == 1 & f == 1 & g == 1 & h == 1)
            {
                if (isChongxinBj == 0)
                {
                    MyMeans.SQLstr = "Insert into daifaml(命令编号,命令类型,调度员姓名,发令单位,起草时间,命令内容,当前状态)values(" + int.Parse(textBox2.Text.Trim()) + ",'" + comboBox1.Text.Trim() + "','" + textBox4.Text.Trim() + "','" + textBox5.Text.Trim() + "','" + dateTimePicker1.Text + "','" + richTextBox1.Text.Trim() + "','未发送')";// 注意圆括号中的 , 用英文形式
                    MyMeans.ExecuteSql(MyMeans.SQLstr);

                    for (int i = 0; i < dataGridView4.Rows.Count; i++)
                    {
                        DataGridViewCheckBoxCell dgvCheckBoxCell = dataGridView4.Rows[i].Cells[0] as DataGridViewCheckBoxCell; //获取DataGridViewCheckBoxCell对象;

                        if (dgvCheckBoxCell.Value == "1")                                                                      //判断该DataGridViewCheckBoxCell是否选中;
                        {
                            MyMeans.SQLstr = "Insert into 受令车站对应表(命令编号,受令单位)values(" + int.Parse(textBox2.Text.Trim()) + ",'" + dataGridView4.Rows[i].Cells[1].Value.ToString().Trim() + "')";
                            MyMeans.ExecuteSql(MyMeans.SQLstr);
                        }
                    }
                    DataSet ds = MyMeans.GetDataSet("Select*from daifaml");
                    dataGridView1.DataSource = ds.Tables[0];
                    textBox2.Text            = "";
                    textBox4.Text            = "";
                    textBox5.Text            = "";
                    comboBox1.Text           = "";
                    richTextBox1.Text        = "";
                    for (int i = 0; i < dataGridView4.Rows.Count; i++)
                    {
                        dataGridView4.Rows[i].Cells[0].Value = "0";
                    }
                }
                else
                {
                    MyMeans.SQLstr = "delete from 受令车站对应表 where 命令编号=" + int.Parse(textBox2.Text.Trim());
                    MyMeans.ExecuteSql(MyMeans.SQLstr);     //删除该条调度命令原来的受令车站信息;
                    MyMeans.SQLstr = "update daifaml set 命令类型='" + comboBox1.Text.Trim() + "',调度员姓名='" + textBox4.Text.Trim() + "',起草时间='" + dateTimePicker1.Text.Trim() + "',命令内容='" + richTextBox1.Text.Trim() + "'where 命令编号=" + int.Parse(textBox2.Text.Trim());
                    MyMeans.ExecuteSql(MyMeans.SQLstr);

                    for (int i = 0; i < dataGridView4.Rows.Count; i++)
                    {
                        DataGridViewCheckBoxCell dgvCheckBoxCell = dataGridView4.Rows[i].Cells[0] as DataGridViewCheckBoxCell; //获取DataGridViewCheckBoxCell对象;

                        if (dgvCheckBoxCell.Value == "1")                                                                      //判断该DataGridViewCheckBoxCell是否选中;
                        {
                            SLchezhan     += (dataGridView4.Rows[i].Cells[1].Value.ToString().Trim() + "#");
                            MyMeans.SQLstr = "Insert into 受令车站对应表(命令编号,受令单位)values(" + int.Parse(textBox2.Text.Trim()) + ",'" + dataGridView4.Rows[i].Cells[1].Value.ToString().Trim() + "')";
                            MyMeans.ExecuteSql(MyMeans.SQLstr);
                        }
                    }
                    DataSet ds = MyMeans.GetDataSet("Select*from daifaml");
                    dataGridView1.DataSource = ds.Tables[0];
                    textBox2.Text            = "";
                    textBox4.Text            = "";
                    textBox5.Text            = "";
                    comboBox1.Text           = "";
                    richTextBox1.Text        = "";
                    for (int i = 0; i < dataGridView4.Rows.Count; i++)
                    {
                        dataGridView4.Rows[i].Cells[0].Value = "0";
                    }
                    isChongxinBj = 0; //重新编辑并保存成功之后,将isChongxinBj的值置为0;
                }
            }
            else
            {
                MessageBox.Show("请将命令补充完整");
            }
        }
Example #20
0
        private void button5_Click(object sender, EventArgs e)          //“发送”按钮,点击发送调度命令,同时将调度命令保存在发令箱
        {
            int    a = 0, b = 0, c = 0, d = 0, f = 0, g = 0, h = 0;
            string SLchezhan = null;

            for (int i = 0; i < dataGridView4.Rows.Count; i++)
            {
                DataGridViewCheckBoxCell dgvCheckBoxCell = dataGridView4.Rows[i].Cells[0] as DataGridViewCheckBoxCell; //获取DataGridViewCheckBoxCell对象;

                if (dgvCheckBoxCell.Value == "1")                                                                      //判断该DataGridViewCheckBoxCell是否选中;
                {
                    SLchezhan += (dataGridView4.Rows[i].Cells[1].Value.ToString().Trim() + "#");
                }
            }
            if (textBox2.Text.Trim() != "")
            {
                a = 1;
            }
            if (comboBox1.Text.Trim() != "")
            {
                b = 1;
            }
            if (textBox4.Text.Trim() != "")
            {
                c = 1;
            }
            if (textBox5.Text.Trim() != "")
            {
                d = 1;
            }
            if (dateTimePicker1.Text != "")
            {
                f = 1;
            }
            if (richTextBox1.Text.Trim() != "")
            {
                g = 1;
            }
            if (SLchezhan != "")
            {
                h = 1;
            }
            if (a == 1 & b == 1 & c == 1 & d == 1 & f == 1 & g == 1 & h == 1)
            {
                try
                {
                    byte[] sendByts = new byte[1024];
                    //发送调度命令给服务器
                    string sendStr = textBox2.Text.Trim() + "#" + comboBox1.Text.Trim() + "#" + textBox5.Text.Trim() + "#" + dateTimePicker1.Text + "#" + richTextBox1.Text.Trim();
                    sendByts = Encoding.UTF8.GetBytes(sendStr);
                    socket.Send(sendByts, sendByts.Length, 0);
                    //发送受令车站信息给服务;
                    sendByts = Encoding.UTF8.GetBytes(SLchezhan);
                    socket.Send(sendByts, sendByts.Length, 0);
                    MessageBox.Show("命令发送成功");
                    // 将已发送的调度命令存储到发送命令列表
                    MyMeans.SQLstr = "Insert into fasongml(命令编号,命令类型,调度员姓名,发令单位,发令时间,命令内容,当前状态)values(" + int.Parse(textBox2.Text.Trim()) + ",'" + comboBox1.Text.Trim() + "','" + textBox4.Text.Trim() + "','" + textBox5.Text.Trim() + "','" + dateTimePicker1.Text.Trim() + "','" + richTextBox1.Text.Trim() + "','已发送')";// 注意圆括号中的 , 用英文形式
                    MyMeans.ExecuteSql(MyMeans.SQLstr);
                    //将调度命令的受令车站信息加入到“受令车站对应表”中;
                    for (int i = 0; i < dataGridView4.Rows.Count; i++)
                    {
                        DataGridViewCheckBoxCell dgvCheckBoxCell = dataGridView4.Rows[i].Cells[0] as DataGridViewCheckBoxCell; //获取DataGridViewCheckBoxCell对象;

                        if (dgvCheckBoxCell.Value == "1")                                                                      //判断该DataGridViewCheckBoxCell是否选中;
                        {
                            MyMeans.SQLstr = "Insert into 受令车站对应表(命令编号,受令单位)values(" + int.Parse(textBox2.Text.Trim()) + ",'" + dataGridView4.Rows[i].Cells[1].Value.ToString().Trim() + "')";
                            MyMeans.ExecuteSql(MyMeans.SQLstr);
                        }
                    }
                    //更新界面显示;
                    DataSet ds;
                    ds = MyMeans.GetDataSet("Select*from fasongml");
                    dataGridView2.DataSource = ds.Tables[0];
                }
                catch
                {
                    MessageBox.Show("命令发送失败");
                    // 将调度命令存储到待发命令列表;
                    MyMeans.SQLstr = "Insert into daifaml(命令编号,命令类型,调度员姓名,发令单位,起草时间,命令内容,当前状态)values(" + int.Parse(textBox2.Text.Trim()) + ",'" + comboBox1.Text.Trim() + "','" + textBox4.Text.Trim() + "','" + textBox5.Text.Trim() + "','" + dateTimePicker1.Text.Trim() + "','" + richTextBox1.Text.Trim() + "','已发送')";// 注意圆括号中的 , 用英文形式
                    MyMeans.ExecuteSql(MyMeans.SQLstr);
                    //将调度命令的受令车站信息加入到“受令车站对应表”中;
                    for (int i = 0; i < dataGridView4.Rows.Count; i++)
                    {
                        DataGridViewCheckBoxCell dgvCheckBoxCell = dataGridView4.Rows[i].Cells[0] as DataGridViewCheckBoxCell; //获取DataGridViewCheckBoxCell对象;

                        if (dgvCheckBoxCell.Value == "1")                                                                      //判断该DataGridViewCheckBoxCell是否选中;
                        {
                            MyMeans.SQLstr = "Insert into 受令车站对应表(命令编号,受令单位)values(" + int.Parse(textBox2.Text.Trim()) + ",'" + dataGridView4.Rows[i].Cells[1].Value.ToString().Trim() + "')";
                            MyMeans.ExecuteSql(MyMeans.SQLstr);
                        }
                    }
                    //更新界面显示;
                    DataSet ds;
                    ds = MyMeans.GetDataSet("Select*from daifaml");
                    dataGridView1.DataSource = ds.Tables[0];
                }

                textBox2.Text     = "";
                textBox4.Text     = "";
                textBox5.Text     = "";
                comboBox1.Text    = "";
                richTextBox1.Text = "";
                for (int i = 0; i < dataGridView4.Rows.Count; i++)
                {
                    dataGridView4.Rows[i].Cells[0].Value = "0";
                }
            }
            else
            {
                MessageBox.Show("请将命令补充完整");
            }
        }