private void LoadInf()
        {
            List <Jc_DefInfo> temp = DEFServiceModel.QueryPointByDevpropertIDCache(0).ToList();

            try
            {
                temp = temp.OrderBy(item => item.Fzh).ToList();
                temp.ForEach(a =>
                {
                    a.Wz = a.Point + ":" + a.Wz + "[" + a.DevName + "]";//增加测点号,安装位置,设备类型三个值显示  20170716
                });
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }
            if (null == temp)
            {
                return;
            }
            var dtTemp = ListToDataTable(temp);

            CgleStaionAdress.Properties.View.BestFitColumns();
            CgleStaionAdress.Properties.DisplayMember = "Wz";
            CgleStaionAdress.Properties.ValueMember   = "Point";
            if (null != dtTemp)
            {
                CgleStaionAdress.Properties.DataSource = dtTemp;
            }
            if (!string.IsNullOrEmpty(_Station))
            {
                CgleStaionAdress.EditValue = _Station;
            }

            AddColumnInf();
            IList <Jc_JcsdkzInfo> tempControl = JCSDKZServiceModel.QueryJCSDKZsCache();

            EvaluateControleDataSource(tempControl);
            if (null != GridSource.GridControlSource)
            {
                CGridControl.DataSource = GridSource.GridControlSource;
                CGridControl.RefreshDataSource();
            }

            barStaticItem2.Caption = "就绪";
        }
        private void barButtonItem1_ItemClick(object sender, ItemClickEventArgs e)
        {
            try
            {
                if (null == CgleStaionAdress.EditValue)
                {
                    XtraMessageBox.Show("请选择分站", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                SaveControl(CgleStaionAdress.EditValue.ToString(), 13);

                IList <Jc_JcsdkzInfo> tempControl = JCSDKZServiceModel.QueryJCSDKZsCache();
                EvaluateControleDataSource(tempControl);
                if (null != GridSource.GridControlSource)
                {
                    CGridControl.RefreshDataSource();
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }
        }
        /// <summary>
        ///     保存数据
        /// </summary>
        private void SaveControl(string Station, int type)
        {
            if (string.IsNullOrEmpty(Station))
            {
                return;
            }
            var fzh = 0;

            if (Station.Length > 0)
            {
                fzh = Convert.ToInt32(Station.Substring(0, 3));
            }
            if (fzh <= 0)
            {
                return;
            }
            if (windowsUIButtonPanel2.Buttons.Count <= 0)
            {
                return;
            }
            IList <Jc_JcsdkzInfo> temp;
            Jc_JcsdkzInfo tempControl;

            Jc_DefInfo tempStation;

            tempStation = DEFServiceModel.QueryPointByCodeCache(Station);
            if (null == tempStation)
            {
                return;
            }

            var DelJckzList = new List <Jc_JcsdkzInfo>();
            var AddJckzList = new List <Jc_JcsdkzInfo>();

            for (var i = 0; i < windowsUIButtonPanel2.Buttons.Count; i++)
            {
                temp = new List <Jc_JcsdkzInfo>();

                if (tempStation.Devid == "228")
                {
                    if (null != windowsUIButtonPanel2.Buttons[i].Properties.Tag)
                    {
                        temp = JCSDKZServiceModel.QueryJCSDKZbyInf(6666,
                                                                   "3015|" + windowsUIButtonPanel2.Buttons[i].Properties.Tag + "=FF");
                    }
                }
                else
                {
                    temp = JCSDKZServiceModel.QueryJCSDKZbyInf(type, windowsUIButtonPanel2.Buttons[i].Properties.Caption);
                }

                if (null == temp)
                {
                    continue;
                }

                if (temp.Count > 0)                                          //原来有控制
                {
                    if (windowsUIButtonPanel2.Buttons[i].Properties.Checked) //现在没有控制
                    {
                        foreach (var item in temp)
                        {
                            DelJckzList.Add(item); //添加到交叉控制删除列表中   20170323
                            //Basic.CBF.Common.Util.OperateLogHelper.InsertOperateLog(4, "取消控制:主控【" + item.ZkPoint + "】-【" + item.Bkpoint + "】", "");
                            OperateLogHelper.InsertOperateLog(4, "取消控制:主控【" + item.ZkPoint + "】-【" + item.Bkpoint + "】",
                                                              "");
                        }
                    }
                }
                else //原来没有控制
                {
                    if (!windowsUIButtonPanel2.Buttons[i].Properties.Checked) //现在有控制
                    {
                        tempControl = new Jc_JcsdkzInfo();
                        //tempControl.ID = Basic.Framework.Utils.Date.DateTimeUtil.GetDateTimeNowToInt64();//ID
                        tempControl.ID = IdHelper.CreateLongId().ToString(); //ID
                        if (type == 13)
                        {
                            if (windowsUIButtonPanel1.Buttons[i].Properties.Checked)
                            {
                                continue;                                             //只有在设备被控制时,才能进行强制解除控制操作
                            }
                            tempControl.Type = (short)ControlType.RemoveLocalControl; //强制解控
                        }
                        else
                        {
                            tempControl.Type = (short)ControlType.LocalControl;                      //手动控制
                        }
                        tempControl.ZkPoint   = "0000000";                                           //主控测点
                        tempControl.Bkpoint   = windowsUIButtonPanel2.Buttons[i].Properties.Caption; //被控测点
                        tempControl.InfoState = InfoState.AddNew;
                        //Model.JCSDKZServiceModel.AddJC_JCSDKZCache(tempControl);

                        AddJckzList.Add(tempControl); //添加到交叉控制添加列表中   20170323

                        OperateLogHelper.InsertOperateLog(4,
                                                          "添加控制:主控【" + tempControl.ZkPoint + "】-【" + tempControl.Bkpoint + "】", "");
                    }
                }
            }
            //在最后统一调用服务端进行处理  20170323
            // 20170623
            try
            {
                if (DelJckzList.Count > 0)
                {
                    JCSDKZServiceModel.DoDoJCSDKZ(DelJckzList);
                }
                if (AddJckzList.Count > 0)
                {
                    JCSDKZServiceModel.AddJC_JCSDKZsCache(AddJckzList);
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            //JCSDKZServiceModel.SaveData(); //执行控制
            barStaticItem2.Caption = "执行成功";
        }
 /// <summary>
 ///     刷新控制实施值
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void SetControlCurrent(string Station)
 {
     try
     {
         if (string.IsNullOrEmpty(Station))
         {
             return;
         }
         var fzh = 0;
         if (Station.Length > 3)
         {
             fzh = Convert.ToInt32(Station.Substring(0, 3));
         }
         if (fzh <= 0)
         {
             return;
         }
         // 20170629
         //已设置成风机口的控制口不允许控制
         var lisDef = DEFServiceModel.QueryPointByFzh(fzh.ToString());
         foreach (IBaseButton item in windowsUIButtonPanel2.Buttons)
         {
             var def = lisDef.FirstOrDefault(a => a.Point == item.Properties.Caption);
             if (def == null)
             {
                 continue;
             }
             var ifUse = RelateUpdate.ControlPointLegal(def);
             if (ifUse)//如果未定义成甲烷风电闭锁口,则允许进行控制  20170923
             {
                 item.Properties.Enabled = true;
             }
             else//如果是甲烷风电闭锁口,则不允许进行控制  20170923
             {
                 item.Properties.Enabled = false;
             }
         }
         IList <Jc_JcsdkzInfo> temp = JCSDKZServiceModel.QueryJCSDKZbyFzhOnlyHCtrlCache(fzh);
         if (null == temp)
         {
             return;
         }
         for (var i = 0; i < temp.Count; i++)
         {
             for (var j = 0; j < windowsUIButtonPanel2.Buttons.Count; j++)
             {
                 if (windowsUIButtonPanel2.Buttons[j].Properties.Caption == temp[i].Bkpoint)
                 {
                     if (temp[i].Type == 0)
                     {
                         windowsUIButtonPanel2.Buttons[j].Properties.Checked = false; //表示当前有控制
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         LogHelper.Error(ex);
     }
 }