private void buttonEdit_Click(object sender, EventArgs e) { DataRowView view = this.BindingContext[adaWorkSystemDataSet1, "Schedule.FK_Activity_Schedule"].Current as DataRowView; ADAWorkSystemDataSet.ActivityRow row = view.Row as ADAWorkSystemDataSet.ActivityRow; ActivityDetailForm f = new ActivityDetailForm(); f.WorkSystemDataSet.Merge(adaWorkSystemDataSet1); f.WorkSystemDataSet.DefaultViewManager.DataViewSettings["Activity"].RowFilter = "ActivityId=" + row.ActivityId; if (f.ShowDialog() == DialogResult.OK) { adaWorkSystemDataSet1.Merge(f.WorkSystemDataSet); } }
private void buttonAddActivity_Click(object sender, EventArgs e) { ActivityDetailForm f = new ActivityDetailForm(); f.WorkSystemDataSet.Merge(adaWorkSystemDataSet1); DataRowView view = this.BindingContext[adaWorkSystemDataSet1, "Schedule"].Current as DataRowView; ADAWorkSystemDataSet.ScheduleRow currentScheduleRow = view.Row as ADAWorkSystemDataSet.ScheduleRow; int sequenceMax = 0; ADAWorkSystemDataSet.ActivityRow lastActivityRow = null; foreach (ADAWorkSystemDataSet.ActivityRow activityRow in currentScheduleRow.GetActivityRows()) { if (sequenceMax < activityRow.Sequence) { sequenceMax = activityRow.Sequence; lastActivityRow = activityRow; } } ADAWorkSystemDataSet.ActivityRow currentActivityRow = f.WorkSystemDataSet.Activity.NewActivityRow(); currentActivityRow.ScheduleId = currentScheduleRow.ScheduleId; currentActivityRow.Sequence = sequenceMax + 1; currentActivityRow.Name = string.Format("Step {0}", currentActivityRow.Sequence); if (lastActivityRow != null && !lastActivityRow.IsSymbolIdNull()) { currentActivityRow.SymbolId = lastActivityRow.SymbolId; currentActivityRow.Image = lastActivityRow.Image; } f.WorkSystemDataSet.Activity.AddActivityRow(currentActivityRow); f.WorkSystemDataSet.DefaultViewManager.DataViewSettings["Activity"].RowFilter = "ActivityId=" + currentActivityRow.ActivityId; if (f.ShowDialog() == DialogResult.OK) { adaWorkSystemDataSet1.Merge(f.WorkSystemDataSet); } }