////// 选择日期 /// private void RQTxt_MouseWheel(object sender, MouseWheelEventArgs e) { if (XZQTxt.IsSelectionActive && XZQTxt.Text != null) Math(e.Delta, XZQTxt); } ////// 输入月份更新文本 /// /// 滚轮上翻(正)还是下翻(负) /// 事件发生前的文本值 public void Math(int e, TextBox time) { string text = time.Text; ShowTXT(time, e, text, text.Substring(4, 2), "31", "30"); switch (text.Substring(4, 2)) { case "05": ShowTXT(time, e, text, "05", "31", "30"); break; case "06": ShowTXT(time, e, text, "06", "30", "31"); break; case "07": ShowTXT(time, e, text, "07", "31", "30"); break; case "08": ShowTXT(time, e, text, "08", "31", "31"); break; case "09": ShowTXT(time, e, text, "09", "30", "31"); break; default: break; } } ////// 显示文本 /// /// 滚轮上翻(正)还是下翻(负) /// 事件发生前的文本值 /// 月份 /// 这月的天数 /// 上月的天数 public void ShowTXT(TextBox time, int e, string text, string YF, string ZYS, string SYS) { if (Convert.ToInt32(text.Substring(6, 2)) + (e / 120) > Convert.ToInt32(ZYS) && e > 0) time.Text = text.Substring(0, 4) + "0" + (Convert.ToInt32(YF.Substring(1)) + 1) + "01"; else if ((Convert.ToInt32(text) + (e / 120)).ToString().Substring(6, 2) == "00" && e < 0) time.Text = text.Substring(0, 4) + "0" + (Convert.ToInt32(YF.Substring(1)) - 1) + SYS; else time.Text = (Convert.ToInt32(text) + e / 120).ToString(); }