/// <summary> /// 月份文本更改,加载DataGridView的内容 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn_IssueMonth_TextChanged(object sender, EventArgs e) { if ((int)cb_IssueType.SelectedValue != 0 && btn_IssueMonth.Text != TextEmpty) { var issueType = (EIssueType)Enum.Parse(typeof(EIssueType), cb_IssueType.SelectedValue.ToString()); var yearMonth = DateTime.Parse(btn_IssueMonth.Text); var year = yearMonth.Year; var month = yearMonth.Month; var dayLists = new List <DateTime>(); var tempDate = new DateTime(year, month, 1, 0, 0, 0, DateTimeKind.Local); while (tempDate.Month == month) { dayLists.Add(tempDate); tempDate = tempDate.AddDays(1); } //根据类型和月份加载列表数据 var loadedLists = Facade.GetLists(issueType, new DateTime(year, month, 1)); //构建完整列表 CurrentLists = dayLists.Select(c => new TList(issueType, c)).ToList(); foreach (var loadedList in loadedLists) { var list = CurrentLists.First(c => c.IssueDate == loadedList.IssueDate); list.DataCount = loadedList.DataCount; } dgv.DataSource = null; dgv.DataSource = CurrentLists; } else { dgv.DataSource = null; } }
private void ListForm_Shown(object sender, EventArgs e) { switch (ShowDialogType) { case ShowDialogType.Idle: SubFormType = SubFormType.None; break; case ShowDialogType.AddElements: case ShowDialogType.DeleleElements: case ShowDialogType.ViewElementsBySelectedNodes: case ShowDialogType.ViewElementsByAllNodes: case ShowDialogType.ViewCurrentMaxByRed: case ShowDialogType.ViewCurrentMaxByAll: case ShowDialogType.ViewTotalMaxByRed: case ShowDialogType.ViewTotalMaxByAll: case ShowDialogType.ViewCloseWarn: case ShowDialogType.ViewOverWarn: switch (SubFormType) { case SubFormType.Subsidence: DisplaySubForm(SubFormForSubsidence); if (SubFormForSubsidence.Model != null && SubFormForSubsidence.Model.MemorableData != null) { CurrentLists.FirstOrDefault(c => c.IssueDate == SubFormForSubsidence.Model.MemorableData.Data.List.IssueDate).Datas = SubFormForSubsidence.Model.MemorableData.Data.List.Datas; } dgv.DataSource = null; dgv.DataSource = CurrentLists; break; case SubFormType.SkewBack: DisplaySubForm(SubFormForSkewBack); if (SubFormForSkewBack.Model != null && SubFormForSkewBack.Model.MemorableData != null) { CurrentLists.FirstOrDefault(c => c.IssueDate == SubFormForSkewBack.Model.MemorableData.Data.List.IssueDate).Datas = SubFormForSkewBack.Model.MemorableData.Data.List.Datas; } dgv.DataSource = null; dgv.DataSource = CurrentLists; break; } break; default: throw new NotImplementedException("暂未支持该类型"); } //ShowDialogType = ShowDialogType.Idle; }