Ejemplo n.º 1
0
 private void frmRoomEdit_Load(object sender, EventArgs e)
 {
     InitDeviceCount();
     if (this.Tag.ToString() == "添加")
     {
         if (roomInfo == null)
         {
             roomInfo = new TbRoominfo();
         }
         this.Text = "添加房间设备信息";
     }
     else if (this.Tag.ToString() == "修改")
     {
         this.Text = "修改房间设备信息";
         LoadRoomInfo();
         //tbName.Text = strName;
         //tbWsd2.Text = strWsd2;
         //tbFire2.Text = strFire2;
         //tbWsd1.Text = strWsd1;
         //tbFire1.Text = strFire1;
         //tbRelayAddr.Text = strRelay;
         //tbAirAddr.Text = strAir;
         //cbbAirFactory.Text = strFactory;
         //tbAirAddr2.Text = strAir2;
         //cbbAirFactory2.Text = strFactory2;
         //chbCSJ.Checked = IsExistCsj;
         //chbJRQ.Checked = IsExistJrq;
         //chbXF.Checked = IsExistXf;
     }
 }
Ejemplo n.º 2
0
 private void LoadAndUpShow()
 {
     //string strSql = "select ID,RoomName,IsSingle,WsdAddr1,WsdAddr2,FireAddr1,FireAddr2,RelayAddr,AirAddr,AirFactory,AirAddr2,AirFactory2,IsExistCsj,IsExistJrq,IsExistXf from tb_RoomInfo ";
     //gridControl1.DataSource = datalogic.GetDataTable(strSql);
     listRoomInfo            = TbRoominfo.FindAll("", "Id ASC", "", 0, 0);
     gridControl1.DataSource = listRoomInfo;
 }
Ejemplo n.º 3
0
        private void LoadRoomDeviceInfo(int roomid)
        {
            TbRoominfo roominfo = TbRoominfo.Find("ID=" + roomid);

            if (roominfo != null)
            {//查找到对应的房间
                //温湿度
                if (roominfo.WSDCount > 0)
                {
                    gcWSD1.Visible = roominfo.WSDCount > 0 ? true : false;
                    gcWSD2.Visible = roominfo.WSDCount >= 2 ? true : false;
                }
                else
                {
                    gcWSD1.Visible = gcWSD2.Visible = false;
                }
                //烟感
                if (roominfo.YGCount > 0)
                {
                    pnlYG.Visible = true;
                }
                else
                {
                    pnlYG.Visible = false;
                }
                //控制设备
                gbCSJ.Visible = roominfo.IsExistCsj == DeviceUsing.启用.ToString() ? true : false;
                gbJRQ.Visible = roominfo.IsExistJrq == DeviceUsing.启用.ToString() ? true : false;
                gbXF.Visible  = roominfo.IsExistXf == DeviceUsing.启用.ToString() ? true : false;
                //空调
                if (roominfo.KTCount > 0)
                {
                    gbKT.Visible = true;
                }
                else
                {
                    gbKT.Visible = false;
                }
            }
        }
Ejemplo n.º 4
0
 private void sbtnAlter_Click(object sender, EventArgs e)
 {
     int[] rows = gridView1.GetSelectedRows(); //选中多行
     if (rows.Length > 0)
     {
         int        ID       = Convert.ToInt16(gridView1.GetRowCellDisplayText(rows[0], "ID"));
         TbRoominfo roomInfo = listRoomInfo.Find(p => p.ID == ID);
         if (roomInfo != null)
         {
             frmRoomEdit frm = new frmRoomEdit(roomInfo);
             frm.Tag = "修改";
             frm.ShowDialog(this);
             frm.Dispose();
             LoadAndUpShow();
         }
         //frm.Tag = "修改";
         //frm.strID = gridView1.GetRowCellDisplayText(rows[0], "ID").ToString();
         //frm.strName = gridView1.GetRowCellDisplayText(rows[0], "RoomName").ToString();
         //frm.strWsd1 = gridView1.GetRowCellDisplayText(rows[0], "WsdAddr1").ToString();
         //frm.strFire1 = gridView1.GetRowCellDisplayText(rows[0], "FireAddr1").ToString();
         //frm.strRelay = gridView1.GetRowCellDisplayText(rows[0], "RelayAddr").ToString();
         //frm.strWsd2 = gridView1.GetRowCellDisplayText(rows[0], "WsdAddr2").ToString();
         //frm.strFire2 = gridView1.GetRowCellDisplayText(rows[0], "FireAddr2").ToString();
         //frm.strAir = gridView1.GetRowCellDisplayText(rows[0], "AirAddr").ToString();
         //frm.strFactory = gridView1.GetRowCellDisplayText(rows[0], "AirFactory").ToString();
         //frm.strAir2 = gridView1.GetRowCellDisplayText(rows[0], "AirAddr2").ToString();
         //frm.strFactory2 = gridView1.GetRowCellDisplayText(rows[0], "AirFactory2").ToString();
         //frm.IsExistCsj = gridView1.GetRowCellDisplayText(rows[0], "IsExistCsj").ToString() == DeviceUsing.启用.ToString() ? true : false;
         //frm.IsExistJrq = gridView1.GetRowCellDisplayText(rows[0], "IsExistJrq").ToString() == DeviceUsing.启用.ToString() ? true : false;
         //frm.IsExistXf = gridView1.GetRowCellDisplayText(rows[0], "IsExistXf").ToString() == DeviceUsing.启用.ToString() ? true : false;
         //frm.ShowDialog(this);
         //frm.Dispose();
         //LoadAndUpShow();
     }
     else
     {
         MessageUtil.ShowTips("无选中的房间");
     }
 }
Ejemplo n.º 5
0
        private void LoadRoomName()
        {
            //string strSql = "select RoomName from tb_RoomInfo ";
            //DataTable dt = datalogic.GetDataTable(strSql);
            IList <TbRoominfo> list = TbRoominfo.FindAll("", "ID ASC", "", 0, 0);

            this.cbbRoomName.SelectedIndexChanged -= new System.EventHandler(this.cbbRoomName_SelectedIndexChanged);
            try
            {
                if (list != null && list.Count > 0)
                {
                    cbbRoomName.DataSource    = list;
                    cbbRoomName.DisplayMember = "RoomName";
                    cbbRoomName.ValueMember   = "ID";
                }
                this.cbbRoomName.SelectedIndexChanged += new System.EventHandler(this.cbbRoomName_SelectedIndexChanged);
                if (cbbRoomName.Items.Count > 0)
                {
                    cbbRoomName.SelectedIndex = 0;
                    LoadRoomDeviceInfo(Convert.ToInt16(cbbRoomName.SelectedValue));
                }
                //foreach (DataRow dr in dt.Rows)
                //{
                //    string strName = dr["RoomName"].ToString();
                //    cbbRoomName.Items.Add(strName);
                //}
                //if (cbbRoomName.Items.Count > 0)
                //    cbbRoomName.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                if (frmMain.blDebug)
                {
                    MessageUtil.ShowTips(ex.Message);
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 加载房间设备 一个房间对应的温湿度、烟感、空调控制器地址等
        /// </summary>
        public void LoadRooms()
        {
            clsEnvirControl.listRoom.Clear();
            //string strSql = "select ID,RoomName,WsdAddr1,WsdAddr2,FireAddr1,FireAddr2,RelayAddr,AirAddr,AirFactory,AirAddr2,AirFactory2 from tb_RoomInfo ";
            //DataTable dtRoom = datalogic.GetDataTable(strSql);
            IList <TbRoominfo> list = TbRoominfo.FindAll("", "ID ASC", "", 0, 0);

            if (list != null && list.Count > 0)
            {
                foreach (TbRoominfo roominfo in list)
                {
                    try
                    {
                        int       iWsd1  = 0;
                        int       iWsd2  = 0;
                        int       iAir1  = 0;
                        int       iAir2  = 0;
                        int       iRelay = 0;
                        RoomClass room   = new RoomClass(roominfo.RoomName);
                        room.YGCount    = roominfo.YGCount;
                        room.WSDCount   = roominfo.WSDCount;
                        room.KTCount    = roominfo.KTCount;
                        room.IsExistCSJ = roominfo.IsExistCsj == DeviceUsing.启用.ToString() ? true : false;
                        room.IsExistJDQ = roominfo.IsExistRealy == DeviceUsing.启用.ToString() ? true : false;
                        room.IsExistJRQ = roominfo.IsExistJrq == DeviceUsing.启用.ToString() ? true : false;
                        room.IsExistXF  = roominfo.IsExistXf == DeviceUsing.启用.ToString() ? true : false;
                        //温湿度
                        if (!string.IsNullOrEmpty(roominfo.WsdAddr1))
                        {
                            iWsd1 = Convert.ToInt32(roominfo.WsdAddr1);
                        }
                        if (!string.IsNullOrEmpty(roominfo.WsdAddr2))
                        {
                            iWsd2 = Convert.ToInt32(roominfo.WsdAddr2);
                        }
                        if (roominfo.WSDCount > 0)
                        {
                            if (iWsd1 != 0)
                            {
                                clsWsd wsd = new clsWsd(iWsd1);
                                room.listWsd.Add(wsd);
                            }
                            if (iWsd2 != 0)
                            {
                                clsWsd wsd = new clsWsd(iWsd2);
                                room.listWsd.Add(wsd);
                            }
                        }

                        //烟感
                        if (!string.IsNullOrEmpty(roominfo.FireAddr1))
                        {
                            clsFire fire = new clsFire(roominfo.FireAddr1);
                            room.listFire.Add(fire);
                        }
                        if (!string.IsNullOrEmpty(roominfo.FireAddr2))
                        {
                            clsFire fire = new clsFire(roominfo.FireAddr2);
                            room.listFire.Add(fire);
                        }
                        //空调控制器
                        if (roominfo.KTCount >= 2)
                        {//2个空调
                            if (!string.IsNullOrEmpty(roominfo.AirAddr))
                            {
                                iAir1 = Convert.ToInt32(roominfo.AirAddr);
                            }
                            if (!string.IsNullOrEmpty(roominfo.AirAddr2))
                            {
                                iAir2 = Convert.ToInt32(roominfo.AirAddr2);
                            }
                            if (iAir1 != 0)
                            {
                                AirFactoryType airType = AirFactoryType.大金;
                                if (roominfo.AirFactory != "大金")
                                {
                                    airType = AirFactoryType.其他;
                                }
                                clsAir air = new clsAir(iAir1, airType);
                                room.listAir.Add(air);
                            }
                            if (iAir2 != 0)
                            {
                                AirFactoryType airType = AirFactoryType.大金;
                                if (roominfo.AirFactory2 != "大金")
                                {
                                    airType = AirFactoryType.其他;
                                }
                                clsAir air = new clsAir(iAir2, airType);
                                room.listAir.Add(air);
                            }
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(roominfo.AirAddr))
                            {
                                iAir1 = Convert.ToInt32(roominfo.AirAddr);
                            }
                            if (iAir1 != 0)
                            {
                                AirFactoryType airType = AirFactoryType.大金;
                                if (roominfo.AirFactory != "大金")
                                {
                                    airType = AirFactoryType.其他;
                                }
                                clsAir air = new clsAir(iAir1, airType);
                                room.listAir.Add(air);
                            }
                        }

                        //继电器板
                        if (!string.IsNullOrEmpty(roominfo.RelayAddr))
                        {
                            iRelay = Convert.ToInt32(roominfo.RelayAddr);
                        }
                        if (iRelay != 0)
                        {
                            room.roomRelay = new clsRelay(iRelay);
                        }
                        clsEnvirControl.listRoom.Add(room);
                    }
                    catch (Exception ex)
                    {
                        if (frmMain.blDebug)
                        {
                            MessageUtil.ShowTips(ex.Message);
                        }
                    }
                }
                RoomClass roomrelay = clsEnvirControl.listRoom.Find(p => p.roomRelay != null);
                foreach (RoomClass room in clsEnvirControl.listRoom)
                {
                    if (room.roomRelay == null)
                    {
                        room.roomRelay = roomrelay.roomRelay;
                    }
                }
            }
        }
Ejemplo n.º 7
0
 public frmRoomEdit(TbRoominfo _roomInfo)
 {
     InitializeComponent();
     roomInfo = _roomInfo;
 }
Ejemplo n.º 8
0
        private void sbtnOk_Click(object sender, EventArgs e)
        {
            #region  输入 判断
            if (string.IsNullOrEmpty(tbName.Text.Trim()))
            {
                MessageUtil.ShowTips("房间名称不能为空!");
                return;
            }
            if (cmbWSD.Text == "1" || cmbWSD.Text == "2")
            {
                if (string.IsNullOrEmpty(tbWsd1.Text.Trim()))
                {
                    MessageUtil.ShowTips("请输入1#温湿度地址!");
                    return;
                }
            }
            if (cmbWSD.Text == "2")
            {
                if (string.IsNullOrEmpty(tbWsd2.Text.Trim()))
                {
                    MessageUtil.ShowTips("请输入2#温湿度地址!");
                    return;
                }
            }
            if (cmbYG.Text == "1" || cmbYG.Text == "2")
            {
                if (string.IsNullOrEmpty(tbFire1.Text.Trim()))
                {
                    MessageUtil.ShowTips("请输入1#烟感地址!");
                    return;
                }
            }
            if (cmbYG.Text == "2")
            {
                if (string.IsNullOrEmpty(tbFire2.Text.Trim()))
                {
                    MessageUtil.ShowTips("请输入2#烟感地址!");
                    return;
                }
            }
            if (chbJDQ.Checked)
            {
                if (string.IsNullOrEmpty(tbRelayAddr.Text.Trim()))
                {
                    MessageUtil.ShowTips("请输入控制板地址!");
                    return;
                }
            }
            if (cmbKT.Text == "1" || cmbKT.Text == "2")
            {
                if (string.IsNullOrEmpty(tbAirAddr.Text.Trim()))
                {
                    MessageUtil.ShowTips("请输入1#空调控制器地址!");
                    return;
                }
            }
            if (cmbKT.Text == "1" || cmbKT.Text == "2")
            {
                if (string.IsNullOrEmpty(cbbAirFactory.Text))
                {
                    MessageUtil.ShowTips("请选择1#空调厂家!");
                    return;
                }
            }
            if (cmbKT.Text == "2")
            {
                if (string.IsNullOrEmpty(tbAirAddr2.Text.Trim()))
                {
                    MessageUtil.ShowTips("请输入2#空调控制器地址!");
                    return;
                }
            }
            if (cmbKT.Text == "2")
            {
                if (string.IsNullOrEmpty(cbbAirFactory2.Text))
                {
                    MessageUtil.ShowTips("请选择2#空调厂家!");
                    return;
                }
            }

            if (strFire1.Length < 2)
            {
                strFire1 = "0" + strFire1;
            }
            if (strFire2.Length < 2)
            {
                strFire2 = "0" + strFire2;
            }

            roomInfo.RoomName     = tbName.Text.Trim();
            roomInfo.WsdAddr1     = tbWsd1.Text.Trim();
            roomInfo.FireAddr1    = tbFire1.Text.Trim();
            roomInfo.WsdAddr2     = tbWsd2.Text.Trim();
            roomInfo.FireAddr2    = tbFire2.Text.Trim();
            roomInfo.RelayAddr    = tbRelayAddr.Text.Trim();
            roomInfo.AirAddr      = tbAirAddr.Text.Trim();
            roomInfo.AirFactory   = cbbAirFactory.Text;
            roomInfo.AirAddr2     = tbAirAddr2.Text.Trim();
            roomInfo.AirFactory2  = cbbAirFactory2.Text;
            roomInfo.IsExistCsj   = chbCSJ.Checked ? DeviceUsing.启用.ToString() : DeviceUsing.未启用.ToString();
            roomInfo.IsExistJrq   = chbJRQ.Checked ? DeviceUsing.启用.ToString() : DeviceUsing.未启用.ToString();
            roomInfo.IsExistXf    = chbXF.Checked ? DeviceUsing.启用.ToString() : DeviceUsing.未启用.ToString();
            roomInfo.IsExistRealy = chbJDQ.Checked ? DeviceUsing.启用.ToString() : DeviceUsing.未启用.ToString();
            roomInfo.YGCount      = Convert.ToInt16(cmbYG.Text);
            roomInfo.WSDCount     = Convert.ToInt16(cmbWSD.Text);
            roomInfo.KTCount      = Convert.ToInt16(cmbKT.Text);

            #endregion
            if (this.Text == "添加房间设备信息")//tb_RoomInfo ID,RoomName,IsSingle,WsdAddr1,WsdAddr2,FireAddr1,FireAddr2,RelayAddr
            {
                //string strSql = "insert into tb_RoomInfo (RoomName,WsdAddr1,WsdAddr2,FireAddr1,FireAddr2,RelayAddr,AirAddr,AirFactory"+
                //    ",AirAddr2,AirFactory2)" +
                //"values ('" + strName + "','" + strWsd1 + "','" + strWsd2 + "','" + strFire1 + "','" + strFire2 + "','" + strRelay + "'"+
                //  ",'" + strAir + "','" + strFactory + "','" + strAir2 + "','" + strFactory2 + "')";
                //datalogic.SqlComNonQuery(strSql);
                int count = TbRoominfo.Insert(roomInfo);
                if (count > 0)
                {
                    MessageUtil.ShowTips("添加房间设备信息成功!");
                }
                else
                {
                    MessageUtil.ShowWarning("添加房间设备信息失败!");
                }
            }
            else if (this.Text == "修改房间设备信息")
            {
                //string strSql = "update tb_RoomInfo set RoomName='" + strName + "',WsdAddr1='" + strWsd1 + "',AirAddr='" + strAir + "'," +
                //                "WsdAddr2='" + strWsd2 + "' ,FireAddr1='" + strFire1 + "',FireAddr2='" + strFire2 + "',RelayAddr='" + strRelay + "' " +
                //                ",AirFactory='" + strFactory + "',AirAddr2='" + strAir2 + "',AirFactory2='" + strFactory2 + "' "+
                //                "where ID='" + strID + "' ";
                //datalogic.SqlComNonQuery(strSql);
                int count = TbRoominfo.Update(roomInfo);
                if (count > 0)
                {
                    MessageUtil.ShowTips("修改房间设备信息成功!");
                }
                else
                {
                    MessageUtil.ShowWarning("区域设备没有数据更新!");
                }
            }
            this.Close();
        }