private void beDelete_ButtonClick(object sender, ButtonPressedEventArgs e) { if (!Alert.Confirm("确认删除数据?")) { return; } switch (_typeFlag) { case FlagManangingMineName: // 矿井名称管理 DeleteInfo <Mine>(); gridControl1.DataSource = CollectionHelper.ConvertTo(Mine.FindAll()); break; case FlagManangingHorizontal: // 水平名称管理 DeleteInfo <Horizontal>(); gridControl1.DataSource = CollectionHelper.ConvertTo(Horizontal.FindAll()); break; case FlagManangingMiningArea: // 采区名称管理 DeleteInfo <MiningArea>(); gridControl1.DataSource = CollectionHelper.ConvertTo(MiningArea.FindAll()); break; case FlagManangingWorkingFace: // 工作面名称管理 DeleteInfo <Workingface>(); gridControl1.DataSource = CollectionHelper.ConvertTo(Workingface.FindAll()); break; } }
/// <summary> /// 带参数的构造方法 /// </summary> /// <params name="typeFlag"></params> /// <params name="id"></params> public CommonManagement(int typeFlag, int id) { InitializeComponent(); Id = id; _typeFlag = typeFlag; switch (typeFlag) { case FlagManangingMineName: { // 窗口标题 Text = @"矿井名称管理"; AddIdColumn("编号", "id"); // 矿井名称 gridView1.Columns.Add(new GridColumn { Caption = @"矿井名称", FieldName = "name", VisibleIndex = gridView1.Columns.Count }); AddDeleteButton(); gridControl1.DataSource = CollectionHelper.ConvertTo(Mine.FindAll()); } break; case FlagManangingHorizontal: { Text = @"水平名称管理"; AddIdColumn("编号", "id"); // 矿井名称 gridView1.Columns.Add(new GridColumn { Caption = @"水平名称", FieldName = "name", VisibleIndex = gridView1.Columns.Count }); gridView1.Columns.Add(new GridColumn { Caption = @"所在矿区", FieldName = "mine", ColumnEdit = lueMine, VisibleIndex = gridView1.Columns.Count, FilterMode = ColumnFilterMode.DisplayText }); AddDeleteButton(); lueMine.DataSource = Mine.FindAll(); gridControl1.DataSource = CollectionHelper.ConvertTo(Horizontal.FindAll()); } break; case FlagManangingMiningArea: { Text = @"采区名称管理"; AddIdColumn("编号", "id"); // 矿井名称 gridView1.Columns.Add(new GridColumn { Caption = @"采区名称", FieldName = "name", VisibleIndex = gridView1.Columns.Count }); // 所属水平 gridView1.Columns.Add(new GridColumn { Caption = @"所在水平", FieldName = "horizontal", ColumnEdit = lueHorizontal, VisibleIndex = gridView1.Columns.Count, FilterMode = ColumnFilterMode.DisplayText }); AddDeleteButton(); lueHorizontal.DataSource = Horizontal.FindAll(); gridControl1.DataSource = CollectionHelper.ConvertTo(MiningArea.FindAll()); } break; case FlagManangingWorkingFace: { Text = @"工作面名称管理"; AddIdColumn("编号", "id"); // 矿井名称 gridView1.Columns.Add(new GridColumn { Caption = @"工作面名称", FieldName = "name", VisibleIndex = gridView1.Columns.Count }); gridView1.Columns.Add(new GridColumn { Caption = @"所在采区", FieldName = "mining_area", ColumnEdit = lueMiningArea, VisibleIndex = gridView1.Columns.Count, FilterMode = ColumnFilterMode.DisplayText }); AddDeleteButton(); lueMiningArea.DataSource = MiningArea.FindAll(); gridControl1.DataSource = CollectionHelper.ConvertTo(Workingface.FindAll()); } break; } }