/// <summary> /// 获取时间 /// </summary> /// <param name="isStartTime">if set to <c>true</c> [is start time].</param> /// <returns>DateTime.</returns> private DateTime GetDate(bool isStartTime) { DateTime result = DateTime.MinValue; if (isStartTime) { result = DateTime.Parse(CurrentYear.ToString() + "-" + CurrentMoth.ToString() + "-1"); } else { result = DateTime.Parse(CurrentYear.ToString() + "-" + CurrentMoth.ToString() + "-1").AddMonths(1); } return(result); }
/// <summary> /// 初始化年分控件事件 /// </summary> private void InitControlClick() { foreach (System.Windows.Forms.Control ctrl in panel.Controls) { if (ctrl.Name.Contains("labelM")) { ctrl.Click += new EventHandler(ctrl_Click); ctrl.MouseEnter += ctrl_MouseEnter; ctrl.MouseLeave += ctrl_MouseLeave; } if (ctrl.Name == "labelM" + CurrentMoth.ToString().Trim()) { SetCurrtntMonth(ctrl); } } }
/// <summary> /// 今年月事件 /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void labelCurrentYear_Click(object sender, EventArgs e) { CurrentYear = DateTime.Now.Year; CurrentMoth = DateTime.Now.Month; TempYear = CurrentYear; labelCurrentInfo.Text = TempYear.ToString() + "年"; SetCurrentValue(); foreach (System.Windows.Forms.Control ctrl in panel.Controls) { if (ctrl.Name == "labelM" + CurrentMoth.ToString().Trim()) { this.SetCurrtntMonth(ctrl); break; } } }
/// <summary> /// 根据当前年月设置当前值 /// </summary> private void SetCurrentValue() { popupContainerEdit.Text = CurrentYear.ToString() + "年" + CurrentMoth.ToString() + "月"; }