private void ButtonEditClick(object sender, EventArgs e) { if (listViewCompliance.SelectedItems.Count == 0 || listViewCompliance.SelectedItems[0].Tag is MaintenanceDirective) { return; } DirectiveComplianceDialog dlg; DirectiveRecord record; if (listViewCompliance.SelectedItems[0].Tag is DirectiveRecord) { record = (DirectiveRecord)listViewCompliance.SelectedItems[0].Tag; IDirective directive = record.Parent; if (directive is MaintenanceDirective) { MaintenanceDirective parentDirective = (MaintenanceDirective)directive; dlg = new DirectiveComplianceDialog(record.Parent, record) { Text = "Edit exist compliance for " + parentDirective.WorkType }; dlg.ShowDialog(); if (dlg.DialogResult == DialogResult.OK) { InvokeComplianceAdded(null); } } else if (directive is ComponentDirective) { ComponentDirective parentDirective = (ComponentDirective)directive; dlg = new DirectiveComplianceDialog(record.Parent, record) { Text = "Edit exist compliance for " + parentDirective.DirectiveType + " of " + parentDirective.ParentComponent.Description }; dlg.ShowDialog(); if (dlg.DialogResult == DialogResult.OK) { InvokeComplianceAdded(null); } } } else { return; } }
private void AddPerformance() { if (listViewCompliance.SelectedItems.Count == 0) { return; } ActualStateDialog actualStateDialog; DirectiveComplianceDialog detailDirectiveDlg; ComponentChangeLLPCategoryRecordForm changeLLPCategoryDlg; ComponentLLPCategoryChangeRecord componentLLPCategoryChangeRecord; ActualStateRecord actualStateRecord; Component component; DirectiveRecord record; ComponentDirective directive; if (listViewCompliance.SelectedItems[0].Tag is NextPerformance) { var np = (NextPerformance)listViewCompliance.SelectedItems[0].Tag; //if (np.Condition != ConditionState.Overdue || np.PerformanceDate > DateTime.Now) //{ // MessageBox.Show("You can not enter a record for not delayed performance", // (string)new GlobalTermsProvider()["SystemName"], // MessageBoxButtons.OK, // MessageBoxIcon.Warning, // MessageBoxDefaultButton.Button1); // return; //} if (np.BlockedByPackage != null) { MessageBox.Show("Perform of the task:" + listViewCompliance.SelectedItems[0].Text + "\nblocked by Work Package:" + "\n" + np.BlockedByPackage.Title, (string)new GlobalTermsProvider()["SystemName"], MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); return; } detailDirectiveDlg = new DirectiveComplianceDialog(np.Parent, np) { Text = "Add new compliance for " + np.WorkType }; detailDirectiveDlg.ShowDialog(); if (detailDirectiveDlg.DialogResult == DialogResult.OK) { InvokeComplianceAdded(null); } } else if (listViewCompliance.SelectedItems[0].Tag is DirectiveRecord) { record = (DirectiveRecord)listViewCompliance.SelectedItems[0].Tag; //if (record.DirectivePackage != null) //{ // MessageBox.Show("Perform of the task:" + listViewCompliance.SelectedItems[0].Text + // "\nadded by Work Package:" + // "\n" + record.DirectivePackage.Title + // "\nTo remove a performance of task, you need to exclude task from this work package," + // "\nor delete the work package ", // (string)new GlobalTermsProvider()["SystemName"], // MessageBoxButtons.OK, // MessageBoxIcon.Warning, // MessageBoxDefaultButton.Button1); // return; //} directive = (ComponentDirective)record.Parent; detailDirectiveDlg = new DirectiveComplianceDialog(directive, record); detailDirectiveDlg.Text = "Edit exist compliance for " + directive.DirectiveType; detailDirectiveDlg.ShowDialog(); if (detailDirectiveDlg.DialogResult == DialogResult.OK) { InvokeComplianceAdded(null); } } else if (listViewCompliance.SelectedItems[0].Tag is ComponentLLPCategoryChangeRecord) { componentLLPCategoryChangeRecord = (ComponentLLPCategoryChangeRecord)listViewCompliance.SelectedItems[0].Tag; component = componentLLPCategoryChangeRecord.ParentComponent; if (component == null) { component = _currentComponent; } changeLLPCategoryDlg = new ComponentChangeLLPCategoryRecordForm(component, componentLLPCategoryChangeRecord); changeLLPCategoryDlg.Text = "Edit exist Change LLP Category record"; changeLLPCategoryDlg.ShowDialog(); if (changeLLPCategoryDlg.DialogResult == DialogResult.OK) { InvokeComplianceAdded(null); } } else if (listViewCompliance.SelectedItems[0].Tag is ActualStateRecord) { actualStateRecord = (ActualStateRecord)listViewCompliance.SelectedItems[0].Tag; actualStateDialog = new ActualStateDialog(actualStateRecord); actualStateDialog.Text = "Edit exist Actual state record"; actualStateDialog.ShowDialog(); if (actualStateDialog.DialogResult == DialogResult.OK) { InvokeComplianceAdded(null); } } else { return; } }
private void AddPerformance() { if (listViewCompliance.SelectedItems.Count == 0) { return; } DirectiveComplianceDialog dlg; DirectiveRecord record; NextPerformance np; if (listViewCompliance.SelectedItems[0].Tag is NextPerformance) { //if (_currentDirective.MaintenanceCheck != null) //{ // MessageBox.Show("This MPD is binded to maintenance check '" + _currentDirective.MaintenanceCheck.Name + "'." + // "\nPerformance for this item introduced by performance of maintenance check.", // (string)new GlobalTermsProvider()["SystemName"], // MessageBoxButtons.OK, // MessageBoxIcon.Warning, // MessageBoxDefaultButton.Button1); // return; //} np = (NextPerformance)listViewCompliance.SelectedItems[0].Tag; //if (np.Condition != ConditionState.Overdue || np.PerformanceDate > DateTime.Now) //{ // MessageBox.Show("You can not enter a record for not delayed performance", // (string)new GlobalTermsProvider()["SystemName"], // MessageBoxButtons.OK, // MessageBoxIcon.Warning, // MessageBoxDefaultButton.Button1); // return; //} if (np.BlockedByPackage != null) { MessageBox.Show("Perform of the task:" + listViewCompliance.SelectedItems[0].Text + "\nblocked by Work Package:" + "\n" + np.BlockedByPackage.Title, (string)new GlobalTermsProvider()["SystemName"], MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); return; } dlg = new DirectiveComplianceDialog(np.Parent, np) { Text = "Add new compliance for " + np.WorkType }; dlg.ShowDialog(); if (dlg.DialogResult == DialogResult.OK) { InvokeComplianceAdded(null); } } else if (listViewCompliance.SelectedItems[0].Tag is DirectiveRecord) { record = (DirectiveRecord)listViewCompliance.SelectedItems[0].Tag; IDirective directive = record.Parent; if (directive is MaintenanceDirective) { MaintenanceDirective parentDirective = (MaintenanceDirective)directive; dlg = new DirectiveComplianceDialog(record.Parent, record) { Text = "Edit exist compliance for " + parentDirective.WorkType }; dlg.ShowDialog(); if (dlg.DialogResult == DialogResult.OK) { InvokeComplianceAdded(null); } } else if (directive is ComponentDirective) { ComponentDirective parentDirective = (ComponentDirective)directive; dlg = new DirectiveComplianceDialog(record.Parent, record) { Text = "Edit exist compliance for " + parentDirective.DirectiveType + " of " + parentDirective.ParentComponent.Description }; dlg.ShowDialog(); if (dlg.DialogResult == DialogResult.OK) { InvokeComplianceAdded(null); } } } else { return; } }