Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)//登陆
        {
            if (cbUser.Text == "")
            {
                MessageBox.Show("用户名不能为空!");
                return;
            }
            if (tbPwd.Text == "")
            {
                MessageBox.Show("没有密码就想登陆吗?");
            }
            string          constr = "Server=127.0.0.1;Database=tonghua;User Id=root;Password=5120154230;";
            MySqlConnection mycon  = new MySqlConnection(constr);

            mycon.Open();                                                //打开连接
            string           check = "select user,password from information where user='******'and password='******'";
            MySqlDataAdapter da    = new MySqlDataAdapter(check, mycon); //创建适配器
            DataSet          ds    = new DataSet();                      //创建数据集

            if (da.Fill(ds, "information") != 0)                         //判断同名
            {
                MessageBox.Show("恭喜你,登陆成功!");                            //输出信息
                this.Hide();
                Socket_Server server = new Socket_Server();
                server.StartPosition = FormStartPosition.CenterScreen;
                server.Show();
            }
            else
            {
                MessageBox.Show("用户名或密码错误!");
                return;
            }
        }
Beispiel #2
0
        private void button5_Click(object sender, EventArgs e)//返回
        {
            this.Hide();
            Socket_Server socket_Server = new Socket_Server();

            socket_Server.StartPosition = FormStartPosition.CenterScreen;
            socket_Server.Show();
        }
Beispiel #3
0
        private void button1_Click(object sender, EventArgs e)//查询
        {
            Socket_Server   socket_Server = new Socket_Server();
            string          constr        = "Server=127.0.0.1;Database=tonghua;User Id=root;Password=5120154230;";
            MySqlConnection mycon         = new MySqlConnection(constr);

            mycon.Open();//打开连接
            if (comboBox1.Text == "聊天日志")
            {
                dataGridView1.Columns[1].HeaderText = "源IP地址"; //改列名称
                dataGridView1.Columns[2].HeaderText = "目的IP地址";
                dataGridView1.Columns[3].HeaderText = "时间";    //改列名称
                dataGridView1.Columns[4].HeaderText = "聊天信息";
                dataGridView1.Columns[5].HeaderText = "视频格式";
                string start_time = dateTimePicker1.Text.ToString();
                string end_time   = dateTimePicker2.Text.ToString();
                Console.WriteLine("start_time={0}     end_time={1}", start_time, end_time);
                string check = "select * from recording where datetime between '" + start_time + "' and'" + end_time + "' order by id asc";
                //string check = "select * from recording order by id asc";
                MySqlDataAdapter da = new MySqlDataAdapter(check, mycon); //创建适配器
                DataSet          ds = new DataSet();                      //创建数据集
                da.Fill(ds, "recording");                                 //填充数据集
                //dataGridView1.DataSource = ds;
                //dataGridView1.DataMember = "recording";
                dtSource    = ds.Tables[0];
                recordCount = dtSource.Rows.Count;
                if (recordCount == 0)
                {
                    MessageBox.Show("查询时间段无记录!");
                    mycon.Close();
                    mycon.Dispose();
                    return;
                }
                pageCount = (recordCount / pageSize);
                if ((recordCount % pageSize) > 0)
                {
                    pageCount++;
                }
                currentPage = 1;//默认第一页
                LoadPage();
                mycon.Close();
                mycon.Dispose();
            }
            if (comboBox1.Text == "动作日志")
            {
                dataGridView1.Columns[1].HeaderText = "源IP地址"; //改列名称
                dataGridView1.Columns[2].HeaderText = "目的IP地址";
                dataGridView1.Columns[3].HeaderText = "时间";    //改列名称
                dataGridView1.Columns[4].HeaderText = "设备参数";
                dataGridView1.Columns[5].HeaderText = "调试参数";
                string start_time = dateTimePicker1.Text.ToString();
                string end_time   = dateTimePicker2.Text.ToString();
                string check      = "select * from debug_data where datetime between '" + start_time + "' and'" + end_time + "' order by id asc";
                //string check = "select * from recording order by id asc";
                MySqlDataAdapter da = new MySqlDataAdapter(check, mycon); //创建适配器
                DataSet          ds = new DataSet();                      //创建数据集
                da.Fill(ds, "debug_data");                                //填充数据集
                dtSource    = ds.Tables[0];
                recordCount = dtSource.Rows.Count;
                if (recordCount == 0)
                {
                    MessageBox.Show("查询时间段无记录!");
                    mycon.Close();
                    mycon.Dispose();
                    return;
                }
                pageCount = (recordCount / pageSize);
                if ((recordCount % pageSize) > 0)
                {
                    pageCount++;
                }
                currentPage = 1;//默认第一页
                LoadPage();
                mycon.Close();
                mycon.Dispose();
            }
            //dataGridView1.Columns[1].DataPropertyName = ds.Tables[0].Columns[2].ToString();//前台第1列,显示数据库第2列的内容
            //dataGridView1.Columns[2].DataPropertyName = ds.Tables[0].Columns[1].ToString();//前台第2列,显示数据库第1列的内容
            //int count = dataGridView1.RowCount; //总行数
            //for (int i = 0; i < count - 1; i++)
            //{
            //Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            //id列显示成序列号,从1开始
            // }
        }