private void LoadDesign()
        {
            this.BackColor             = _queueStateDesign.BackColor;
            flowLayoutPanel1.BackColor = Color.Transparent;

            float     fontSize = 0;
            FontStyle fs       = FontStyle.Regular;

            try
            {
                fontSize = _queueStateDesign.FontSize;
            }
            catch { }
            if (fontSize <= 0)
            {
                fontSize = this.Font.Size;
            }

            if (_queueStateDesign.FontBold)
            {
                fs = fs | FontStyle.Bold;
            }
            if (_queueStateDesign.FontItalic)
            {
                fs = fs | FontStyle.Italic;
            }

            Font font = new Font(_queueStateDesign.FontName, fontSize, fs);

            this.Font = font;



            _queueItems.Clear();
            if (_queueStateDesign.QueueItems.Count > 0)
            {
                _queueItems = new List <QueueItem>(_queueStateDesign.QueueItems);
            }
            else
            {
                //查询科室包含的队列
                DataTable dtQueueData = QueueModel.GetQueueInfoByDeptId(_stationInfo.DepartmentId);

                if (_queueStateDesign.UseRoomQueueReleation && string.IsNullOrEmpty(_stationInfo.RoomId) == false)
                {
                    foreach (DataRow drQueue in dtQueueData.Rows)
                    {
                        QueueData queData = new QueueData();
                        queData.BindRowData(drQueue);

                        if (queData.包含房间.房间明细.FindIndex(T => T.房间ID == _stationInfo.RoomId) >= 0)
                        {
                            QueueItem qi = new QueueItem();

                            qi.QueueName = drQueue["队列名称"].ToString();
                            qi.QueueId   = drQueue["队列ID"].ToString();
                            qi.BusyCount = _queueStateDesign.DefaultBusyCount;

                            _queueItems.Add(qi);
                        }
                    }
                }
                else
                {
                    foreach (DataRow drQueue in dtQueueData.Rows)
                    {
                        QueueItem qi = new QueueItem();

                        qi.QueueName = drQueue["队列名称"].ToString();
                        qi.QueueId   = drQueue["队列ID"].ToString();
                        qi.BusyCount = _queueStateDesign.DefaultBusyCount;

                        _queueItems.Add(qi);
                    }
                }
            }
        }
        private void BindQueueState()
        {
            if (_queueItems.Count <= 0)
            {
                return;
            }

            DataTable dtQueueState = QueueModel.GetLineupCountByDepartmentId(_stationInfo.DepartmentId);

            if (dtQueueState == null || dtQueueState.Rows.Count <= 0)
            {
                flowLayoutPanel1.Controls.Clear();
                return;
            }


            if (flowLayoutPanel1.Controls.Count > 0)
            {
                foreach (Control lab in flowLayoutPanel1.Controls)
                {
                    Label labQueue = lab as Label;
                    if (labQueue == null)
                    {
                        continue;
                    }

                    QueueItem qi = labQueue.Tag as QueueItem;

                    DataRow[] drQueue = dtQueueState.Select("队列ID='" + qi.QueueId + "'");

                    if (drQueue.Length <= 0)
                    {
                        labQueue.Text      = "";
                        labQueue.BackColor = GetQueueStateColor(qi.QueueId, 0);

                        continue;
                    }

                    int count = Convert.ToInt32(drQueue[0]["数量"].ToString());

                    string context = drQueue[0]["队列名称"].ToString() + "\r----\r(" + count + ")人";
                    labQueue.Text = context;

                    labQueue.BackColor = GetQueueStateColor(qi.QueueId, count);
                }
            }
            else
            {
                foreach (DataRow drQueue in dtQueueState.Rows)
                {
                    Label labQueue = new Label();

                    int    count   = Convert.ToInt32(drQueue["数量"].ToString());
                    string queueId = drQueue["队列ID"].ToString();

                    if (_queueItems.FindIndex(T => T.QueueId == queueId) < 0)
                    {
                        continue;
                    }

                    QueueItem qi = new QueueItem();
                    qi.QueueId   = queueId;
                    qi.QueueName = drQueue["队列名称"].ToString();

                    labQueue.Tag = qi;

                    string context = qi.QueueName + "\r----\r(" + count + ")人";
                    labQueue.Text = context;


                    labQueue.AutoSize  = false;
                    labQueue.Size      = new Size(65, 65);
                    labQueue.Font      = this.Font;
                    labQueue.TextAlign = ContentAlignment.MiddleCenter;
                    labQueue.ForeColor = _queueStateDesign.ForeColor;
                    labQueue.Margin    = new Padding(2);

                    labQueue.Click       += LabClick;
                    labQueue.DoubleClick += LabDblClick;


                    labQueue.BackColor = GetQueueStateColor(qi.QueueId, count);

                    flowLayoutPanel1.Controls.Add(labQueue);
                }
            }
        }
        private void frmQueueStateModuleDesign_Load(object sender, EventArgs e)
        {
            try
            {
                InitQueueList();

                ceBackColor.Color = _queueStateDesign.BackColor;
                ceForeColor.Color = _queueStateDesign.ForeColor;
                ceBusyColor.Color = _queueStateDesign.BusyColor;
                ceWorkColor.Color = _queueStateDesign.WorkColor;
                ceFreeColor.Color = _queueStateDesign.FreeColor;

                txtFixRow.Text    = Convert.ToString(_queueStateDesign.FixRow);
                txtFixColumn.Text = Convert.ToString(_queueStateDesign.FixColumn);

                txtDefaultBusyCount.Text = Convert.ToString(_queueStateDesign.DefaultBusyCount);

                float     fontSize = 0;
                FontStyle fs       = FontStyle.Regular;

                try
                {
                    fontSize = _queueStateDesign.FontSize;
                }
                catch { }
                if (fontSize <= 0)
                {
                    fontSize = this.Font.Size;
                }

                if (_queueStateDesign.FontBold)
                {
                    fs = fs | FontStyle.Bold;
                }
                if (_queueStateDesign.FontItalic)
                {
                    fs = fs | FontStyle.Italic;
                }

                Font font = new Font(_queueStateDesign.FontName, fontSize, fs);
                feFontStyle.Value = font;

                chkUseRoomReleation.Checked = _queueStateDesign.UseRoomQueueReleation;

                listView1.Items.Clear();

                DataTable dtQueueData = _qm.GetQueueInfoByDeptId(_departmentId);

                foreach (DataRow drQueue in dtQueueData.Rows)
                {
                    QueueData queInfo = new QueueData();
                    queInfo.BindRowData(drQueue);

                    ListViewItem lvi = new ListViewItem(new string[] { queInfo.队列名称, "0" });

                    if (_queueStateDesign.QueueItems.Count > 0)
                    {
                        int index = _queueStateDesign.QueueItems.FindIndex(T => T.QueueId == queInfo.队列ID);

                        if (index >= 0)
                        {
                            QueueItem qi = _queueStateDesign.QueueItems[index];

                            lvi.SubItems[1].Text = Convert.ToString(qi.BusyCount);
                            lvi.Checked          = true;
                        }
                    }

                    lvi.Name = queInfo.队列名称;

                    lvi.Tag = queInfo;

                    listView1.Items.Add(lvi);
                }

                listView1.View = View.Details;
            }
            catch (Exception ex)
            {
                MsgBox.ShowException(ex, this);
            }
        }