예제 #1
0
 private void dgvDoorCamera_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         if (e.ColumnIndex == 3)//删除
         {
             if (MessageBox.Show("确定删除该关联关系?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
             {
                 DoorCamera  dc      = (DoorCamera)dgvDoorCamera.Rows[e.RowIndex].Tag;
                 CtrlWaiting waiting = new CtrlWaiting(() =>
                 {
                     try
                     {
                         Maticsoft.BLL.SMT_DOOR_CAMERA dcBll = new Maticsoft.BLL.SMT_DOOR_CAMERA();
                         dcBll.Delete(dc.DOOR_ID, dc.CAMERA_ID);
                         this.Invoke(new Action(() =>
                         {
                             dgvDoorCamera.Rows.Remove(dgvDoorCamera.Rows[e.RowIndex]);
                         }));
                     }
                     catch (Exception ex)
                     {
                         log.Error("删除门禁相机关系异常:", ex);
                         WinInfoHelper.ShowInfoWindow(this, "删除门禁相机关系异常:" + ex.Message);
                     }
                 });
                 waiting.Show(this);
             }
         }
     }
 }
예제 #2
0
 private void dgvDoorCamera_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         if (e.ColumnIndex == 2)
         {
             bool        enable  = (bool)dgvDoorCamera.Rows[e.RowIndex].Cells[2].Value;
             DoorCamera  dc      = (DoorCamera)dgvDoorCamera.Rows[e.RowIndex].Tag;
             CtrlWaiting waiting = new CtrlWaiting(() =>
             {
                 try
                 {
                     Maticsoft.BLL.SMT_DOOR_CAMERA dcBll     = new Maticsoft.BLL.SMT_DOOR_CAMERA();
                     Maticsoft.Model.SMT_DOOR_CAMERA dcModel = new Maticsoft.Model.SMT_DOOR_CAMERA()
                     {
                         DOOR_ID    = dc.DOOR_ID,
                         CAMERA_ID  = dc.CAMERA_ID,
                         ENABLE_CAP = !enable
                     };
                     dcBll.Update(dcModel);
                     this.Invoke(new Action(() =>
                     {
                         dgvDoorCamera.Rows[e.RowIndex].Cells[2].Value = dcModel.ENABLE_CAP;
                     }));
                 }
                 catch (System.Exception ex)
                 {
                     log.Error("更新门禁相机关系异常:", ex);
                     WinInfoHelper.ShowInfoWindow(this, "更新门禁相机关系异常:" + ex.Message);
                 }
             });
             waiting.Show(this);
         }
     }
 }
예제 #3
0
        private void biAddDoorCamera_Click(object sender, EventArgs e)
        {
            var node = this.doorTree.Tree.SelectedNode;

            if (node == null)
            {
                WinInfoHelper.ShowInfoWindow(this, "请选择门禁!");
                return;
            }
            if (node.Tag is Maticsoft.Model.SMT_DOOR_INFO)
            {
                Maticsoft.Model.SMT_DOOR_INFO door = (Maticsoft.Model.SMT_DOOR_INFO)node.Tag;
                var rows = dgvCamera.SelectedRows;
                if (rows.Count == 0)
                {
                    WinInfoHelper.ShowInfoWindow(this, "请选择摄像头!");
                    return;
                }
                List <Maticsoft.Model.SMT_CAMERA_INFO> cameras = new List <Maticsoft.Model.SMT_CAMERA_INFO>();
                foreach (DataGridViewRow row in rows)
                {
                    Maticsoft.Model.SMT_CAMERA_INFO cameraInfo = (Maticsoft.Model.SMT_CAMERA_INFO)row.Tag;
                    cameras.Add(cameraInfo);
                }
                CtrlWaiting waiting = new CtrlWaiting(() =>
                {
                    try
                    {
                        foreach (var camera in cameras)
                        {
                            Maticsoft.BLL.SMT_DOOR_CAMERA dcBll = new Maticsoft.BLL.SMT_DOOR_CAMERA();
                            var dcModel = dcBll.GetModel(door.ID, camera.ID);
                            if (dcModel == null)
                            {
                                dcModel            = new Maticsoft.Model.SMT_DOOR_CAMERA();
                                dcModel.DOOR_ID    = door.ID;
                                dcModel.CAMERA_ID  = camera.ID;
                                dcModel.ENABLE_CAP = cbEnableCap.Checked;
                                dcBll.Add(dcModel);
                                this.Invoke(new Action(() =>
                                {
                                    AddToGridDoorCamera(door, camera, dcModel.ENABLE_CAP);
                                }));
                            }
                            else
                            {
                                if (dcModel.ENABLE_CAP != cbEnableCap.Checked)
                                {
                                    dcModel.ENABLE_CAP = cbEnableCap.Checked;
                                    dcBll.Update(dcModel);
                                    this.Invoke(new Action(() =>
                                    {
                                        foreach (DataGridViewRow row in this.dgvDoorCamera.Rows)
                                        {
                                            DoorCamera dc = (DoorCamera)row.Tag;
                                            if (dc.DOOR_ID == door.ID && dc.CAMERA_ID == camera.ID)
                                            {
                                                row.Cells[2].Value = dcModel.ENABLE_CAP;
                                                break;
                                            }
                                        }
                                    }));
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("添加关系异常:", ex);
                        WinInfoHelper.ShowInfoWindow(this, "添加门禁相机关系异常:" + ex.Message);
                    }
                });
                waiting.Show(this);
            }
            else
            {
                WinInfoHelper.ShowInfoWindow(this, "请选择门禁节点!");
            }
        }