Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
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();
            }
        }