Exemplo n.º 1
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;
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
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;
                    }
                }
            }
        }
Exemplo n.º 4
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;
        }
Exemplo n.º 5
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();
            }
        }
Exemplo n.º 6
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();
        }
Exemplo n.º 7
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("请将信息输入完整");
     }
 }
Exemplo n.º 8
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];
        }
Exemplo n.º 9
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();
                }
            }
        }