Ejemplo n.º 1
0
 // These four methods are not used because we do not have a details panel beneath the grid
 // However, they need to be here to get the auto-gen code to compile
 private void NewRowManual(ref PDataLabelUseRow ARow)
 {
     // Dummy use of FIgnoreFocusRowLeaving to make things compile
     if (FIgnoreFocusRowLeaving)
     {
         ShowDetails();
     }
 }
        void FPetraUtilsObject_DataSaved(object Sender, TDataSavedEventArgs e)
        {
            // Do not save anything if the main table did not save correctly
            if (!e.Success)
            {
                return;
            }

            // Ensure we get the current row's information
            if (FPreviouslySelectedDetailRow != null)
            {
                FPreviouslySelectedDetailRow[UsedByColumnOrdinal] = clbUsedBy.GetCheckedStringList();
            }

            // Now we need to save the PDataLabelUse table info using our data from our UsedBy column
            // Go round all the rows, seeing which rows have a new UsedBy value
            foreach (PDataLabelRow labelRow in FMainDS.PDataLabel.Rows)
            {
                if ((labelRow.RowState != DataRowState.Deleted) &&
                    (labelRow[UsedByColumnOrdinal].ToString() != labelRow[UsedByColumnOrdinal - 1].ToString()))
                {
                    // This row's UsedBy column has been edited
                    // Get the key and the list of usedBy's for this row
                    int      key        = labelRow.Key;
                    string   usedByList = labelRow[UsedByColumnOrdinal].ToString();
                    string[] uses       = usedByList.Split(',');

                    // Get the usedBy's that are in the database at the moment
                    DataRow[] UseRows = FExtraDS.PDataLabelUse.Select("p_data_label_key_i=" + key.ToString());

                    // For each current UsedBy, make sure it has a row in the database.
                    // If not, we need to add a new row, using an Idx1 value greater than anything used before
                    foreach (string use in uses)
                    {
                        bool bUseExistsAlready = false;

                        foreach (DataRow r in UseRows)
                        {
                            string tryUse = r.ItemArray[PDataLabelUseTable.ColumnUseId].ToString();

                            if (String.Compare(tryUse, use, true) == 0)
                            {
                                bUseExistsAlready = true;
                                break;
                            }
                        }

                        if (!bUseExistsAlready)
                        {
                            PDataLabelUseRow newRow = FExtraDS.PDataLabelUse.NewRowTyped();
                            newRow.DataLabelKey = key;
                            newRow.Use          = use;
                            newRow.Idx1         = ++MaxIdx1Value;
                            FExtraDS.PDataLabelUse.Rows.Add(newRow);
                        }
                    }

                    // Now go round the other way
                    // Go round each database row and check if its UsedBy is still in our current usedBy List
                    // If we don't find it in the current list we need to delete this row
                    foreach (DataRow r in UseRows)
                    {
                        string tryUse          = r.ItemArray[PDataLabelUseTable.ColumnUseId].ToString();
                        bool   bUseStillExists = false;

                        foreach (string use in uses)
                        {
                            if (String.Compare(tryUse, use, true) == 0)
                            {
                                bUseStillExists = true;
                                break;
                            }
                        }

                        if (!bUseStillExists)
                        {
                            // We no longer need this row for this usedBy/LabelKey
                            r.Delete();
                        }
                    }
                }
            }

            Ict.Common.Data.TTypedDataTable SubmitDT = FExtraDS.PDataLabelUse.GetChangesTyped();

            if (SubmitDT == null)
            {
                return;                                 // nothing to save
            }

            SaveDataLabelUseChanges(SubmitDT);
        }
 private void GetDetailsFromControls(PDataLabelUseRow ARow, bool AIsNewRow = false)
 {
 }
 // These four methods are not used because we do not have a details panel beneath the grid
 // However, they need to be here to get the auto-gen code to compile
 private void NewRowManual(ref PDataLabelUseRow ARow)
 {
 }
Ejemplo n.º 5
0
 private void GetDetailsFromControls(PDataLabelUseRow ARow, bool AIsNewRow = false)
 {
 }
Ejemplo n.º 6
0
 // These four methods are not used because we do not have a details panel beneath the grid
 // However, they need to be here to get the auto-gen code to compile
 private void NewRowManual(ref PDataLabelUseRow ARow)
 {
 }
 // These four methods are not used because we do not have a details panel beneath the grid
 // However, they need to be here to get the auto-gen code to compile
 private void NewRowManual(ref PDataLabelUseRow ARow)
 {
     // Dummy use of FIgnoreFocusRowLeaving to make things compile
     if (FIgnoreFocusRowLeaving)
     {
         ShowDetails();
     }
 }