Esempio n. 1
0
        private void lstFarm_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.lstFarm.SelectedItems.Count > 0)
            {
                if (this.lstFarm.SelectedItems[0].Tag is Farm)
                {
                    this.farmId = (this.lstFarm.SelectedItems[0].Tag as Farm).ID;
                    //this.txtID.Text = (this.lstFarm.SelectedItems[0].Tag as Farm).ID.ToString();
                    this.txtCode1.Text            = this.lstFarm.SelectedItems[0].SubItems[1].Text;
                    this.txtCode2.Text            = this.lstFarm.SelectedItems[0].SubItems[2].Text;
                    this.txtCode3.Text            = this.lstFarm.SelectedItems[0].SubItems[3].Text;
                    this.txtName.Text             = this.lstFarm.SelectedItems[0].SubItems[4].Text;
                    this.txtCompanySerialNum.Text = this.lstFarm.SelectedItems[0].SubItems[5].Text;
                    this.txtAddress.Text          = this.lstFarm.SelectedItems[0].SubItems[6].Text;
                    //this.pbPhotoUrl.Text = this.lstFarm.SelectedItems[0].SubItems[7].Text;
                    this.txtLotitude.Text      = this.lstFarm.SelectedItems[0].SubItems[8].Text;
                    this.txtLatitude.Text      = this.lstFarm.SelectedItems[0].SubItems[9].Text;
                    this.txtArea.Text          = this.lstFarm.SelectedItems[0].SubItems[10].Text;
                    this.txtContactMan.Text    = this.lstFarm.SelectedItems[0].SubItems[11].Text;
                    this.txtContactPhone.Text  = this.lstFarm.SelectedItems[0].SubItems[12].Text;
                    this.txtContactMobile.Text = this.lstFarm.SelectedItems[0].SubItems[13].Text;
                    //this.cbStatus.Text = this.lstFarm.SelectedItems[0].SubItems[14].Text;
                    this.rbtOnlineStatus.Checked = Convert.ToBoolean(this.lstFarm.SelectedItems[0].SubItems[14].Text);
                    //if (this.rbtOnlineStatus.Checked == true)
                    //{
                    //    this.rbtOnlineStatus1.Checked = false;
                    //}
                    //else
                    //{
                    //    this.rbtOnlineStatus1.Checked = true;
                    //}
                    //this.dtCreateTime.Value =Convert.ToDateTime(this.lstFarm.SelectedItems[0].SubItems[15].Text);
                    //this.txtUpdateTime.Text = this.lstFarm.SelectedItems[0].SubItems[16].Text;
                    this.txtAPIKey.Text = this.lstFarm.SelectedItems[0].SubItems[17].Text;
                    //this.cbUpLoad.Text = this.lstFarm.SelectedItems[0].SubItems[18].Text;
                    //this.rbtUpLoad.Checked = Convert.ToBoolean(this.lstFarm.SelectedItems[0].SubItems[18].Text);
                    //if (this.rbtUpLoad.Checked == true)
                    //{
                    //    this.rbtUpLoad1.Checked = false;
                    //}
                    //else
                    //{
                    //    this.rbtUpLoad1.Checked = true;
                    ////}
                    //this.txtVersion.Text = this.lstFarm.SelectedItems[0].SubItems[19].Text;
                    ////this.lstIntroduce.Text = this.lstFarm.SelectedItems[0].SubItems[20].Text;
                    this.txtPwd.Text = this.lstFarm.SelectedItems[0].SubItems[21].Text;

                    //设施列表的改变事件
                    List <Facility> facilityList =
                        Facility.FindAllByFarmID((this.lstFarm.SelectedItems[0].Tag as Farm).ID);
                    //foreach (Facility f in facilityList)
                    //{
                    if (facilityList == null || facilityList.Count == 0)
                    {
                        foreach (ListViewItem item in this.lstFacility.Items)
                        {
                            item.Checked = false;
                        }

                        //return;
                    }
                    else
                    {
                        foreach (ListViewItem item in this.lstFacility.Items)
                        {
                            var isExists = false;
                            foreach (var fac in facilityList)
                            {
                                var facility = item.Tag as Facility;
                                if (facility != null)
                                {
                                    if (facility.ID == fac.ID)
                                    {
                                        isExists = true;
                                    }
                                }
                            }

                            item.Checked = isExists;
                        }
                    }
                    //}
                }
            }
        }
Esempio n. 2
0
        private void InitData()
        {
            var facs = Facility.FindAllByFarmID(_farmId);

            if (facs != null && facs.Count > 0)
            {
                foreach (var fac in facs)
                {
                    var facnode = new DevComponents.AdvTree.Node("设施")
                    {
                        ImageIndex = 0,
                        Tag        = fac,
                        //TagString="Facility",
                        Expanded = true,
                        Name     = fac.Name,
                        Text     = fac.Name
                    };
                    this.advTreeData.Nodes.AddRange(new DevComponents.AdvTree.Node[] { facnode });

                    var collectnode = new DevComponents.AdvTree.Node("采集设备")
                    {
                        ImageIndex = 1, Tag = "SensorDeviceUnit"
                    };
                    var collects = fac.FacilitySensorDeviceUnits;
                    if (collects != null && collects.Count > 0)
                    {
                        foreach (var c in collects)
                        {
                            var cnode = new DevComponents.AdvTree.Node
                            {
                                Expanded = true,
                                Name     = c.SensorDeviceUnit.Name,
                                Text     = c.SensorDeviceUnit.Name,
                                Tag      = c.SensorDeviceUnit,
                                //TagString = "SensorDeviceUnit"
                            };
                            cnode.Cells.Add(new DevComponents.AdvTree.Cell {
                                Text = c.SensorDeviceUnit.ProcessedValue.ToString(), Name = c.SensorDeviceUnit.ProcessedValue.ToString()
                            });
                            cnode.Cells.Add(new DevComponents.AdvTree.Cell {
                                Text = c.SensorDeviceUnit.Sensor.Unit, Name = c.SensorDeviceUnit.Sensor.Unit
                            });
                            cnode.Cells.Add(new DevComponents.AdvTree.Cell {
                                Text = c.SensorDeviceUnit.UpdateTime.ToString(), Name = c.SensorDeviceUnit.UpdateTime.ToString()
                            });
                            cnode.Cells.Add(new DevComponents.AdvTree.Cell {
                                Text = c.Code1, Name = c.Code1
                            });
                            collectnode.Nodes.Add(cnode);
                        }
                    }
                    facnode.Nodes.Add(collectnode);

                    var controlnode = new DevComponents.AdvTree.Node("控制设备")
                    {
                        ImageIndex = 2, Tag = "ControlDeviceUnit"
                    };
                    var fcontrols = fac.FacilityControlDeviceUnits;
                    if (fcontrols != null && fcontrols.Count > 0)
                    {
                        foreach (var fc in fcontrols)
                        {
                            ControlDeviceUnit.FindByGroupNum(fc.ControlDeviceUnitGroupNum).ForEach(control =>
                            {
                                var cnode = new DevComponents.AdvTree.Node
                                {
                                    Expanded = true,
                                    Name     = control.Name,
                                    Text     = control.Name,
                                    Tag      = control,
                                    //TagString = "ControlDeviceUnit"
                                };
                                cnode.Cells.Add(new DevComponents.AdvTree.Cell {
                                    Text = control.ProcessedValue.ToString(), Name = control.ProcessedValue.ToString()
                                });
                                cnode.Cells.Add(new DevComponents.AdvTree.Cell {
                                    Text = " ", Name = " "
                                });
                                cnode.Cells.Add(new DevComponents.AdvTree.Cell {
                                    Text = control.UpdateTime.ToString(), Name = control.UpdateTime.ToString()
                                });
                                cnode.Cells.Add(new DevComponents.AdvTree.Cell {
                                    Text = fc.Code1, Name = fc.Code1
                                });
                                controlnode.Nodes.Add(cnode);
                            });
                        }
                    }
                    facnode.Nodes.Add(controlnode);

                    var cameranode = new DevComponents.AdvTree.Node("视频设备")
                    {
                        ImageIndex = 3, Tag = "Camera"
                    };
                    var cameras = fac.FacilityCameras;
                    if (cameras != null && cameras.Count > 0)
                    {
                        foreach (var c in cameras)
                        {
                            var cnode = new DevComponents.AdvTree.Node
                            {
                                Expanded = true,
                                Name     = c.Camera.Name,
                                Text     = c.Camera.Name,
                                Tag      = c.Camera,
                                //TagString = "Camera"
                            };
                            cnode.Cells.Add(new DevComponents.AdvTree.Cell {
                                Text = "正常", Name = "正常"
                            });
                            cnode.Cells.Add(new DevComponents.AdvTree.Cell {
                                Text = "", Name = ""
                            });
                            cnode.Cells.Add(new DevComponents.AdvTree.Cell {
                                Text = c.UpdateTime.ToString(), Name = c.UpdateTime.ToString()
                            });
                            cnode.Cells.Add(new DevComponents.AdvTree.Cell {
                                Text = c.Code1, Name = c.Code1
                            });
                            cameranode.Nodes.Add(cnode);
                        }
                    }
                    facnode.Nodes.Add(cameranode);

                    var shownode = new DevComponents.AdvTree.Node("展示设备")
                    {
                        ImageIndex = 4, Tag = "ShowDevice"
                    };
                    var shows = ShowDevice.FindAll();
                    if (shows != null && shows.Count > 0)
                    {
                        foreach (var s in shows)
                        {
                            var cnode = new DevComponents.AdvTree.Node
                            {
                                Expanded = true,
                                Name     = s.Name,
                                Text     = s.Name,
                                Tag      = s,
                                //TagString = "ShowDevice"
                            };
                            shownode.Nodes.Add(cnode);
                        }
                    }
                    facnode.Nodes.Add(shownode);
                }
            }
        }