/// <summary> /// 追溯查询 按钮点击回调 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button_RetrosQuery_Click(object sender, EventArgs e) { //获取查询条件参数 string sbId = Convert.ToString(this.comboBox5.SelectedValue); //所选物品名称(设备)ID string strDateStart = this.dateTimePicker_RqDateStart.Value.ToString("yyyy-MM-dd"); //开始日期 string strDateEnd = this.dateTimePicker_RqDateEnd.Value.ToString("yyyy-MM-dd"); //结束日期 DateTime DateStart = Convert.ToDateTime(strDateStart); DateTime DateEnd = Convert.ToDateTime(strDateEnd).AddDays(1); //因为筛选时是小于,所以加上一天 if (String.IsNullOrEmpty(sbId)) { listView4.Items.Clear(); //从集合中移除所有项 //MessageBox.Show("请选择物品后查询", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); //return; } //耗时操作,单启线程 Thread thread = new Thread(() => { DealDataGridViewQueryBLL bll = new DealDataGridViewQueryBLL(); //获取datagridView数据源DataTable DataTable dt = bll.GetRetrosQueryDataTable(sbId, DateStart, DateEnd); BindZscxDataGridData(dt); //获取设备相关信息 if (!String.IsNullOrEmpty(sbId)) { FIXED_MatetialInfo info = bll.GetMaterialInfoById(sbId); BindSbXqListViewData(info); //数据绑定 } }); //新建线程 thread.IsBackground = true; thread.Start(); }
private void FormDeviceShow_Load(object sender, EventArgs e) { int CangKuID = Convert.ToInt32(dgvr.Cells[1].Value); //启线程 Thread thread = new Thread(() => { DealDataGridViewQueryBLL bll = new DealDataGridViewQueryBLL(); DataTable dt = bll.GetIOTDeviceDataTable(CangKuID); //获取数据源---耗时操作,单启线程 BindDataGridData(dt); }); //新建线程 thread.IsBackground = true; thread.Start(); }
/// <summary> /// 物品名称Combobox5 获取数据源并绑定 /// </summary> private void BindWpmcCombobox5() { List <ComboboxInfo> infoList = new List <ComboboxInfo>(); //启线程 Thread thread = new Thread(() => { DealDataGridViewQueryBLL bll = new DealDataGridViewQueryBLL(); infoList = bll.GetWpmcComboboxList(); //获取对象名称combobox数据---耗时操作,单启线程 BindComboboxData(comboBox5, infoList); //追溯查询tabpage页 物品名称combobox绑定数据源 WpmcTotalList = infoList; //add20200401 plq 存放物品名称下拉列表初始化数据 }); //新建线程 thread.IsBackground = true; thread.Start(); }
/// <summary> /// 仓库物联列表tabpage页 查询按钮点击回调 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button_GetStorageList_Click(object sender, EventArgs e) { string CangKuMingCheng = this.textBox_CangKuMingCheng.Text; //DealDataGridViewQueryBLL bll = new DealDataGridViewQueryBLL(); //DataTable dt = bll.GetStorageIOTDataTable(CangKuMingCheng); //获取数据源DataTable //this.dataGridView2.DataSource = dt; //启线程 Thread thread = new Thread(() => { DealDataGridViewQueryBLL bll = new DealDataGridViewQueryBLL(); DataTable dt = bll.GetStorageIOTDataTable(CangKuMingCheng); //获取数据源DataTable---耗时操作,单启线程 BindWllbDataGridData(dt); }); //新建线程 thread.IsBackground = true; thread.Start(); }
//查询按钮点击事件回调 private void button_AlarmQuery_Click(object sender, EventArgs e) { //获取查询条件参数--用户输入 string ckId = Convert.ToString(this.comboBox2.SelectedValue); //所选对象名称(仓库)ID string gjId = Convert.ToString(this.comboBox3.SelectedValue); //所选告警类型ID string strDateStart = this.dateTimePicker_AqDateStart.Value.ToString("yyyy-MM-dd"); //开始日期 string strDateEnd = this.dateTimePicker_AqDateEnd.Value.ToString("yyyy-MM-dd"); //结束日期 DateTime DateStart = Convert.ToDateTime(strDateStart); DateTime DateEnd = Convert.ToDateTime(strDateEnd).AddDays(1); //因为筛选时是小于,所以加上一天 //启线程 Thread thread = new Thread(() => { DealDataGridViewQueryBLL bll = new DealDataGridViewQueryBLL(); DataTable dt = bll.GetAlarmQueryDataTable(ckId, gjId, DateStart, DateEnd); //获取数据源DataTable---耗时操作,单启线程 BindGjcxDataGridData(dt); }); //新建线程 thread.IsBackground = true; thread.Start(); }
// private void button_GetCarList_Click(object sender, EventArgs e) //{ // this.dataGridView1.Rows.Clear();//清空datagridView // string ChePaiHao = this.textBox_ChePaiHao.Text; //获取输入的车牌号 // DealDataGridViewQueryBLL bll = new DealDataGridViewQueryBLL(); // List<RfidStorage_AmbulanceInfo> list = bll.GetCarIOTList(ChePaiHao); //获取数据源List // for (int i = 0; i < list.Count; i++) // { // AddCllbDataGridRow(i + 1, list[i].CangKuID, list[i].ChePaiHao, list[i].DuXieQiID); // } //} //private delegate void AddCllbDataGridRowDelegate(int count, string carID, string carNum, string DuXieQiID); //public void AddCllbDataGridRow(int count, string carID, string carNum, string DuXieQiID) //{ // if (dataGridView1.InvokeRequired) // { // AddCllbDataGridRowDelegate c = new AddCllbDataGridRowDelegate(AddCllbDataGridRow); // this.Invoke(c, new object[] { count, carID, carNum, DuXieQiID }); // } // else // { // DataGridViewRow dgvr = new DataGridViewRow(); // foreach (DataGridViewColumn c in this.dataGridView1.Columns) // { // dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell); //给行添加单元格 // } // dgvr.Cells[0].Value = count; // dgvr.Cells[1].Value = carID; // dgvr.Cells[2].Value = carNum; // dgvr.Cells[3].Value = DuXieQiID; // this.dataGridView1.Rows.Add(dgvr); // //Thread.Sleep(10000); // } //} /// <summary> /// 车辆物联列表tabpage页 查询按钮点击回调 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button_GetCarList_Click(object sender, EventArgs e) { this.dataGridView1.Rows.Clear(); this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; //调整列宽 string ChePaiHao = this.textBox_ChePaiHao.Text; //这两行代码放在这里不会报错 //启线程 Thread thread = new Thread(() => { //this.dataGridView1.Rows.Clear(); //string ChePaiHao = this.textBox_ChePaiHao.Text; //放在这里会报错 因为涉及到跨线程访问控件 分别放开注释debug调试下 DealDataGridViewQueryBLL bll = new DealDataGridViewQueryBLL(); List <RfidStorage_AmbulanceInfo> list = bll.GetCarIOTList(ChePaiHao); //获取数据源List for (int i = 0; i < list.Count; i++) { AddCllbDataGridRow(i + 1, list[i].CangKuID, list[i].ChePaiHao, list[i].DuXieQiID); } }); //新建线程 thread.IsBackground = true; thread.Start(); }