public SystemSetup() { InitializeComponent(); treeView1.ExpandAll(); //获取录像设备选择列表 Thread th1 = new Thread(new ThreadStart(ListView1Init)); th1.IsBackground = true; th1.Start(); //显示录像设置信息 DataSet ds = AutoRecInfoClass.SelectAll(); dataGridView1.DataSource = ds.Tables["AutoRecInfoList"]; //显示开关量设置信息 DataSet ds2 = SwitchDateClass.SelectAll(); dataGridView2.DataSource = ds2.Tables["SwitchDateList"]; //显示其他设置的磁盘信息 LocalDisk(); //获取开关量列表(服务器数据库) Thread th2 = new Thread(new ThreadStart(ListView2Init)); th2.IsBackground = true; th2.Start(); //获取用户列表(服务器数据库) Thread th3 = new Thread(new ThreadStart(dataGridView3Init)); th3.IsBackground = true; th3.Start(); }
private void SystemSetup_Load(object sender, EventArgs e) { string errorInfo = ""; //1、初始化通信类(服务器) bool result1 = CommunicationClass.Init(); if (!result1) { MessageBox.Show("连接服务器失败!"); return; } treeView1.ExpandAll(); //2、初始化设备数据(服务器数据库) Class1 class1 = new Class1(); class1.Init(); ManualRec.LogIn(); //获取录像设备选择列表 Thread th1 = new Thread(new ThreadStart(ListView1Init)); th1.IsBackground = true; th1.Start(); //显示录像设置信息 Thread th4 = new Thread(new ThreadStart(GetRecInfo)); th4.IsBackground = true; th4.Start(); //显示开关量设置信息 DataSet ds2 = SwitchDateClass.SelectAll(ref errorInfo); if (ds2 == null) { MessageBox.Show(errorInfo + "获取开关量设置信息失败!"); } else { dataGridView2.DataSource = ds2.Tables["SwitchDateList"]; } //显示其他设置的磁盘信息 LocalDisk(); //显示红外保护信息(服务器数据库) Thread th5 = new Thread(new ThreadStart(GetLensProtection)); th5.IsBackground = true; th5.Start(); lensProtection.Camera_DeviceID = Guid.NewGuid(); //获取开关量列表(服务器数据库) Thread th2 = new Thread(new ThreadStart(ListView2Init)); th2.IsBackground = true; th2.Start(); //获取用户列表(服务器数据库) Thread th3 = new Thread(new ThreadStart(dataGridView3Init)); th3.IsBackground = true; th3.Start(); }
private void button8_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show("确定删除选中项?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dr == DialogResult.OK) { foreach (DataGridViewRow dgvr in dataGridView2.SelectedRows) { //删除数据库 SwitchDateClass.Delete(int.Parse(dgvr.Cells[0].Value.ToString())); //移除列表 dataGridView2.Rows.Remove(dgvr); } } }
/// <summary> /// 保存开关量设置信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button9_Click(object sender, EventArgs e) { string errorInfo = ""; //时间类型 string timeType = "1"; for (int i = 0; i < 4; i++) { if (radioButton8.Checked) { timeType = "1"; break; } else if (radioButton7.Checked) { timeType = "2"; break; } else if (radioButton6.Checked) { timeType = "3"; break; } else if (radioButton5.Checked) { timeType = "4"; break; } } //起始日期 string startDate = dateTimePicker5.Value.ToString("yyyy-MM-dd"); //结束日期 string endDate = dateTimePicker6.Value.ToString("yyyy-MM-dd"); //开始星期 string startWeek = dateTimePicker5.Value.DayOfWeek.ToString(); //结束星期 string endWeek = dateTimePicker6.Value.DayOfWeek.ToString(); //开始时间 string startTime = dateTimePicker7.Text; //结束时间 string endTime = dateTimePicker8.Text; foreach (ListViewItem lvi in listView2.SelectedItems) { SwitchDateList switchDateList = new SwitchDateList(); TimeSpan ts = DateTime.Now.ToUniversalTime() - new DateTime(1970, 1, 1); switchDateList.DateID = ts.TotalMilliseconds.ToString(); switchDateList.DeviceID = lvi.Tag.ToString(); switchDateList.StartDate = startDate; switchDateList.StartWeek = startWeek; switchDateList.StartTime = startTime; switchDateList.EndDate = endDate; switchDateList.EndWeek = endWeek; switchDateList.EndTime = endTime; switchDateList.TimeType = timeType; if (!SwitchDateClass.Add(switchDateList, ref errorInfo)) { MessageBox.Show(errorInfo); break; } } //显示录像设置信息 DataSet ds = SwitchDateClass.SelectAll(ref errorInfo); if (ds == null) { MessageBox.Show(errorInfo); } dataGridView2.DataSource = ds.Tables["SwitchDateList"]; }