Exemplo n.º 1
0
        /// <summary>
        /// Отобразить рабочие промежутки
        /// </summary>
        private void ShowTimes()
        {
            int selectNumber = TimesList.CurrentRow != null ? TimesList.CurrentRow.Index : 0;

            m_TimesInfos = m_DatabaseTools.GetTimesRows(m_ProjectInfo.ID);
            TimesList.Rows.Clear();
            labelInfo.Text = "";
            foreach (Exchange.TimesInfo timeInfo in m_TimesInfos)
            {
                var param = new object[]
                {
                    timeInfo.DateStart.ToString(),
                                        timeInfo.DateStop != null?timeInfo.DateStop.ToString() : ""
                };
                TimesList.Rows.Add(param);
            }
            TimesList.Focus();

            if (TimesList.Rows.Count > 0)
            {
                if (selectNumber < TimesList.Rows.Count)
                {
                    TimesList.Rows[selectNumber].Cells[0].Selected = true;
                }
                else
                {
                    TimesList.Rows[TimesList.Rows.Count - 1].Cells[0].Selected = true;
                }
            }

            Color col = Color.FromArgb(255, 240, 240, 240);

            for (int i = 0; i < TimesList.Rows.Count; i += 2)
            {
                TimesList.Rows[i].DefaultCellStyle.BackColor = col;
            }

            if (m_TimesInfos.Length > 0 && m_TimesInfos[m_TimesInfos.Length - 1].DateStop == null)
            {
                buttonStart.Enabled = false;
                buttonStop.Enabled  = true;
                timerWork.Enabled   = true;
            }
            else
            {
                buttonStart.Enabled = true;
                buttonStop.Enabled  = false;
                timerWork.Enabled   = false;
            }

            var timesTools = new TimeTools();

            labelInfo.Text = "Общее время работы над проектом: " + timesTools.GetTimeFromSecond(GetAllSeconds(null));
        }