private void dtpTime_ValueChanged(object sender, EventArgs e) { if (!_bClearForm) { string grade = "4"; if (chkLunar.Checked) { try { ChineseCalendarInfo cCalendar = ChineseCalendarInfo.FromLunarDate(dtpTime.Value, false); tooltipTime.SetToolTip(dtpTime, "对应太阳历:" + cCalendar.SolarDate.ToShortDateString()); grade = BusAdminDaily.CalculateGrade(cCalendar.SolarDate.Add(new TimeSpan(dtpTime.Value.Hour, dtpTime.Value.Minute, dtpTime.Value.Second))); } catch (Exception ex) { MessageHandle.MessageError("错误:" + ex.Message + "!", "错误信息"); dtpTime.Focus(); } } else { grade = BusAdminDaily.CalculateGrade(dtpTime.Value); } cboLevel.SelectedValue = grade; if (grade == "4") { MessageHandle.MessageWarnning("事务时间已过期!", "警告信息"); dtpTime.Focus(); } } }
private void btnAddDaily_Click(object sender, EventArgs e) { if (operType == 1) { if (MessageHandle.MessageAsk("增加将会丢失修改数据,确定要执行增加操作?", "确定增加") == DialogResult.OK) { ClearForm(); cboLevel.Select(); } } else { if (IsValid()) { _dailyEntity = new DailyEntity(); _dailyEntity.D_CONTENT = rtbContent.Text; _dailyEntity.D_REMIND_MUSIC_PATH = txtMusicPath.Text; string grade; if (chkLunar.Checked) { _dailyEntity.D_LUNAR_CALENDAR = dtpTime.Value.ToString(); ChineseCalendarInfo cCalendar = ChineseCalendarInfo.FromLunarDate(dtpTime.Value.Date, false); DateTime solar = cCalendar.SolarDate.Add(new TimeSpan(dtpTime.Value.Hour, dtpTime.Value.Minute, dtpTime.Value.Second)); _dailyEntity.D_SOLAR_CALENDAR = solar.ToString(); grade = BusAdminDaily.CalculateGrade(solar); _dailyEntity.D_LEVEL = grade; } else { _dailyEntity.D_SOLAR_CALENDAR = dtpTime.Value.ToString(); grade = BusAdminDaily.CalculateGrade(dtpTime.Value); _dailyEntity.D_LEVEL = grade; } if (BusAdminDaily.AddDaily(_dailyEntity)) { ClearForm(); _dailyEntity = null; BindAll(); if (MessageHandle.MessageInfo("恭喜,增加成功!", "提示信息") == DialogResult.OK) { BusAdminDaily.InitTodayUnDoDaily(); } } } } }
private void btnModifyDaily_Click(object sender, EventArgs e) { if (IsValid()) { _dailyEntity.D_CONTENT = rtbContent.Text; _dailyEntity.D_LEVEL = cboLevel.SelectedValue.ToString(); _dailyEntity.D_REMIND_MUSIC_PATH = txtMusicPath.Text; string grade; if (chkLunar.Checked) { _dailyEntity.D_LUNAR_CALENDAR = dtpTime.Value.ToString(); ChineseCalendarInfo cCalendar = ChineseCalendarInfo.FromLunarDate(dtpTime.Value.Date, false); DateTime solar = cCalendar.SolarDate.Add(new TimeSpan(dtpTime.Value.Hour, dtpTime.Value.Minute, dtpTime.Value.Second)); _dailyEntity.D_SOLAR_CALENDAR = solar.ToString(); grade = BusAdminDaily.CalculateGrade(solar); _dailyEntity.D_LEVEL = grade; } else { _dailyEntity.D_LUNAR_CALENDAR = ""; _dailyEntity.D_SOLAR_CALENDAR = dtpTime.Value.ToString(); grade = BusAdminDaily.CalculateGrade(dtpTime.Value); _dailyEntity.D_LEVEL = grade; } if (BusAdminDaily.ModifyDaily(_dailyEntity)) { if (MessageHandle.MessageInfo("恭喜,修改成功!", "提示信息") == DialogResult.OK) { BusAdminDaily.UpdateDailyStateBySystem(); } if (mFromWhere == 1) { tbcContainer.SelectedTab = tabPageToday; mFromWhere = 0; foreach (DataGridViewRow dgvRow in dgvToday.SelectedRows) { dgvRow.Selected = false; } foreach (DataGridViewRow dgvRow in dgvToday.Rows) { if (dgvRow.Cells[0].Value.ToString() == _dailyEntity.ID) { dgvRow.Selected = true; break; } } } else { BindAll(); dgvAll.Select(); foreach (DataGridViewRow dgvRow in dgvAll.SelectedRows) { dgvRow.Selected = false; } foreach (DataGridViewRow dgvRow in dgvAll.Rows) { if (dgvRow.Cells[0].Value.ToString() == _dailyEntity.ID) { dgvRow.Selected = true; break; } } } ClearForm(); _dailyEntity = null; } } }