/// <summary> /// 更新Section /// </summary> private void UpdateSection() { if (dgvEBContent.SelectedRows.Count > 0) { string EBM_ID = cbBoxEBMId.SelectedValue.ToString(); EBMContentSectionInfo form = new EBMContentSectionInfo(Enums.OperateType.Update, EBM_ID, SelectEBContent_List[dgvEBContent.SelectedRows[0].Index]); DialogResult result = form.ShowDialog(); if (result == DialogResult.OK && form.ContentAllData != null) { SelectEBContent_List[dgvEBContent.SelectedRows[0].Index] = form.ContentAllData; string guid = SelectEBContent_List[dgvEBContent.SelectedRows[0].Index].Guid; EBContent_AllData TobeDel = new EBContent_AllData(); foreach (var item in EBContent_List_AllData) { if (item.Guid == guid) { TobeDel = item; } } if (TobeDel != null) { EBContent_List_AllData.Remove(TobeDel); EBContent_List_AllData.Add(SelectEBContent_List[dgvEBContent.SelectedRows[0].Index]); } } form.Dispose(); } else { MessageBox.Show("未选中任何索引"); } }
/// <summary> /// 增加Section /// </summary> private void AddSection() { try { if (cbBoxEBMId.SelectedValue != null) { if (dgvEBContent.Rows.Count == 0) { string EBM_ID = cbBoxEBMId.SelectedValue.ToString(); EBMContentSectionInfo form = new EBMContentSectionInfo(Enums.OperateType.Add, EBM_ID); DialogResult result = form.ShowDialog(); if (result == DialogResult.OK && form.ContentAllData != null) { SelectEBContent_List.Add(form.ContentAllData); EBContent_List_AllData.Add(form.ContentAllData);//同步到全局数据 } form.Dispose(); } else { MessageBox.Show("已添加过一条数据,不能再添加!"); } } else { MessageBox.Show("未发现可用EBM_ID"); } } catch (Exception) { throw; } }