Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="AGridCombo"></param>
        /// <param name="AAnalysisAttribute"></param>
        /// <param name="AAnalysisCode"></param>
        /// <param name="AAnalysisAttributeValue"></param>
        /// <returns></returns>
        public static bool AnalysisAttributeValueIsActive(ref SourceGrid.Cells.Editors.ComboBox AGridCombo, AFreeformAnalysisTable AAnalysisAttribute,
                                                          String AAnalysisCode = "", String AAnalysisAttributeValue = "")
        {
            bool retVal = true;

            if ((AAnalysisCode == string.Empty) || (AAnalysisAttributeValue == string.Empty))
            {
                return(retVal);
            }

            DataView dv = new DataView(AAnalysisAttribute);

            dv.RowFilter = String.Format("{0}='{1}' AND {2}='{3}' AND {4}=true",
                                         AFreeformAnalysisTable.GetAnalysisTypeCodeDBName(),
                                         AAnalysisCode,
                                         AFreeformAnalysisTable.GetAnalysisValueDBName(),
                                         AAnalysisAttributeValue,
                                         AFreeformAnalysisTable.GetActiveDBName());

            retVal = (dv.Count > 0);

            //Make sure the grid combobox has right font else it will adopt strikeout
            // for all items in the list.
            AGridCombo.Control.Font = new Font(FontFamily.GenericSansSerif, 8);

            return(retVal);
        }
        private void AnalysisAttributesGrid_RowSelected(System.Object sender, RangeRegionChangedEventArgs e)
        {
            if (grdAnalAttributes.Selection.ActivePosition.IsEmpty() || (grdAnalAttributes.Selection.ActivePosition.Column == 0))
            {
                return;
            }

            if ((GetSelectedAttributeRow() == null) || (FPSAttributesRow == GetSelectedAttributeRow()))
            {
                return;
            }

            FPSAttributesRow = GetSelectedAttributeRow();

            FMainDS.AFreeformAnalysis.DefaultView.RowFilter = String.Format("{0}='{1}' AND {2}=true",
                                                                            AFreeformAnalysisTable.GetAnalysisTypeCodeDBName(),
                                                                            FPSAttributesRow.AnalysisTypeCode,
                                                                            AFreeformAnalysisTable.GetActiveDBName());

            //Refresh the combo values
            int analTypeCodeValuesCount = FMainDS.AFreeformAnalysis.DefaultView.Count;

            if (analTypeCodeValuesCount == 0)
            {
                MessageBox.Show(Catalog.GetString(
                                    "No attribute values are defined!"), FPSAttributesRow.AnalysisTypeCode, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            string[] analTypeValues = new string[analTypeCodeValuesCount];

            FMainDS.AFreeformAnalysis.DefaultView.Sort = AFreeformAnalysisTable.GetAnalysisValueDBName();
            int counter = 0;

            foreach (DataRowView dvr in FMainDS.AFreeformAnalysis.DefaultView)
            {
                AFreeformAnalysisRow faRow = (AFreeformAnalysisRow)dvr.Row;
                analTypeValues[counter++] = faRow.AnalysisValue;
            }

            cmbAnalAttribValues.StandardValuesExclusive = true;
            cmbAnalAttribValues.StandardValues          = analTypeValues;
        }
        private bool AnalysisAttributeValueIsActive(String AAnalysisCode = "", String AAnalysisAttributeValue = "")
        {
            bool retVal = true;

            if ((AAnalysisCode == string.Empty) || (AAnalysisAttributeValue == string.Empty))
            {
                return(retVal);
            }

            DataView dv = new DataView(FCacheDS.AFreeformAnalysis);

            dv.RowFilter = String.Format("{0}='{1}' AND {2}='{3}' AND {4}=true",
                                         AFreeformAnalysisTable.GetAnalysisTypeCodeDBName(),
                                         AAnalysisCode,
                                         AFreeformAnalysisTable.GetAnalysisValueDBName(),
                                         AAnalysisAttributeValue,
                                         AFreeformAnalysisTable.GetActiveDBName());

            retVal = (dv.Count > 0);

            return(retVal);
        }
        /// <summary>
        /// Performs checks to determine whether a deletion of the current row is permissable
        /// </summary>
        /// <param name="ARowToDelete">the currently selected row to be deleted</param>
        /// <param name="ADeletionQuestion">can be changed to a context-sensitive deletion confirmation question</param>
        /// <returns>true if user is permitted and able to delete the current row</returns>
        private bool PreDeleteManual(AAnalysisTypeRow ARowToDelete, ref string ADeletionQuestion)
        {
            /*Code to execute before the delete can take place*/
            DataView DependentRecordsDV = new DataView(FMainDS.AFreeformAnalysis);

            DependentRecordsDV.RowStateFilter = DataViewRowState.CurrentRows;
            DependentRecordsDV.RowFilter      = String.Format("{0} = '{1}'",
                                                              AFreeformAnalysisTable.GetAnalysisTypeCodeDBName(),
                                                              ARowToDelete.AnalysisTypeCode);

            if (DependentRecordsDV.Count > 0)
            {
                // Tell the user that we cannot allow deletion if any rows exist in the DataView
                TMessages.MsgRecordCannotBeDeletedDueToDependantRecordsError(
                    "Analysis Type", "an Analysis Type", "Analysis Types", "Analysis Value", "an Analysis Value",
                    "Analysis Values", ARowToDelete.AnalysisTypeCode, DependentRecordsDV.Count);

                return(false);
            }

            return(true);
        }
        private void AnalysisAttributesGrid_RowSelected(System.Object sender, RangeRegionChangedEventArgs e)
        {
            TSgrdDataGridPaged Grid = sender as TSgrdDataGridPaged;

            if (Grid == null)
            {
                Grid = (TSgrdDataGridPaged)((SourceGrid.Selection.RowSelection)sender).Grid;
            }

            if (Grid.Selection.ActivePosition.IsEmpty() || (Grid.Selection.ActivePosition.Column == 0))
            {
                return;
            }

            if ((TAnalysisAttributes.GetSelectedAttributeRow(Grid) == null) || (FPSAttributesRow == TAnalysisAttributes.GetSelectedAttributeRow(Grid)))
            {
                return;
            }

            FPSAttributesRow = TAnalysisAttributes.GetSelectedAttributeRow(Grid);

            string currentAnalTypeCode = FPSAttributesRow.AnalysisTypeCode;

            FCacheDS.AFreeformAnalysis.DefaultView.RowFilter = String.Format("{0}='{1}' AND {2}=true",
                                                                             AFreeformAnalysisTable.GetAnalysisTypeCodeDBName(),
                                                                             currentAnalTypeCode,
                                                                             AFreeformAnalysisTable.GetActiveDBName());

            int analTypeCodeValuesCount = FCacheDS.AFreeformAnalysis.DefaultView.Count;

            if (analTypeCodeValuesCount == 0)
            {
                MessageBox.Show(Catalog.GetString(
                                    "No attribute values are defined!"), currentAnalTypeCode, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            string[] analTypeValues = new string[analTypeCodeValuesCount];

            FCacheDS.AFreeformAnalysis.DefaultView.Sort = AFreeformAnalysisTable.GetAnalysisValueDBName();
            int counter = 0;

            foreach (DataRowView dvr in FCacheDS.AFreeformAnalysis.DefaultView)
            {
                AFreeformAnalysisRow faRow = (AFreeformAnalysisRow)dvr.Row;
                analTypeValues[counter] = faRow.AnalysisValue;

                counter++;
            }

            //Refresh the combo values
            if (Grid.Name == grdFromAnalAttributes.Name)
            {
                FcmbFromAnalAttribValues.StandardValuesExclusive = true;
                FcmbFromAnalAttribValues.StandardValues          = analTypeValues;
            }
            else
            {
                FcmbToAnalAttribValues.StandardValuesExclusive = true;
                FcmbToAnalAttribValues.StandardValues          = analTypeValues;
            }
        }