/// <summary> /// This function determines the current PartnerKey /// /// </summary> /// <returns>void</returns> public Int64 DeterminePartnerKeyFromRowNumber(System.Int32 ARowNumber) { System.Data.DataRowView mRowView; System.Data.DataRow mRow; System.Object mObject; // TLogging.Log('Begin of DeterminePartnerKeyFromRowNumber: ' + ARowNumber.ToString, [TLoggingType.ToLogfile]); // Grid starts counting with 1 mRowView = (DataRowView)this.FDataGrid.Rows.IndexToDataSourceRow(ARowNumber + 1); mRow = mRowView.Row; mObject = mRow[PartnerEditTDSFamilyMembersTable.GetPartnerKeyDBName()]; return((System.Int64)(mObject)); // TLogging.Log('PartnerKey: ' + Result.ToString, [TLoggingType.ToLogfile]); // TLogging.Log('End of DeterminePartnerKeyFromRowNumber: ' + ARowNumber.ToString, [TLoggingType.ToLogfile]); }
/// <summary> /// returns Arraylist that has FamilyID and PartnerID pairs. For testing purposes. /// </summary> /// <returns>void</returns> public ArrayList PrintOrder() { Int32 i; ArrayList List; List = new ArrayList(); // Goes through the FamilyMembers, and list FamilyID and PartnerKey for (i = 0; i <= (GetNumberOfRows() - 1); i += 1) { List.Add(Convert.ToString(FFamilyMembersDV[i].Row[PartnerEditTDSFamilyMembersTable.GetPartnerKeyDBName()]) + ':' + Convert.ToString(FFamilyMembersDV[i].Row[PartnerEditTDSFamilyMembersTable.GetFamilyIdDBName()])); } return(List); }
/// <summary> /// Sets the order of colums /// </summary> /// <returns>void</returns> public void CreateColumns() { SourceGrid.Cells.Editors.TextBoxUITypeEditor l_editorDt2; Ict.Common.TypeConverter.TDateConverter DateTypeConverter; FFamilyMembersDT = FMainDS.FamilyMembers; // Editor for Date of Birth column (Petra Date format) l_editorDt2 = new SourceGrid.Cells.Editors.TextBoxUITypeEditor(typeof(DateTime)); l_editorDt2.EditableMode = EditableMode.None; DateTypeConverter = new Ict.Common.TypeConverter.TDateConverter(); // DateTypeConverter. l_editorDt2.TypeConverter = DateTypeConverter; try { this.FDataGrid.AddTextColumn("Person Name", FFamilyMembersDT.Columns[PartnerEditTDSFamilyMembersTable.GetPartnerShortNameDBName()], -1, FSpecialCellController, null, null, null); this.FDataGrid.AddTextColumn("Gender", FFamilyMembersDT.Columns[PartnerEditTDSFamilyMembersTable.GetGenderDBName()], -1, FSpecialCellController, null, null, null); this.FDataGrid.AddTextColumn("Date of Birth", FFamilyMembersDT.Columns[PartnerEditTDSFamilyMembersTable.GetDateOfBirthDBName()], -1, FSpecialCellController, l_editorDt2, null, null); this.FDataGrid.AddTextColumn("Partner Key", FFamilyMembersDT.Columns[PartnerEditTDSFamilyMembersTable.GetPartnerKeyDBName()], -1, FSpecialCellController, null, null, null); FamilyIDDropDownValues = new Int32[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }; FFamilyIDEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(Int32), FamilyIDDropDownValues, false); this.FDataGrid.AddTextColumn("Family ID", FFamilyMembersDT.Columns[PartnerEditTDSFamilyMembersTable.GetFamilyIdDBName()], 80, FFamilyIDEditor); DisableEditing(); FFamilyIDEditor.EnableEdit = false; FFamilyIDEditor.Control.Validating += new CancelEventHandler(this.FamilyID_Validating); // DevAge.ComponentModel.Validator.ValueMapping FamilyIDDropDownMapping = new DevAge.ComponentModel.Validator.ValueMapping(); } catch (System.NullReferenceException) { } // to do if no lines. }
/// <summary> /// Finds out the number of row, and it's Partnerkey in datagrid that's selected. /// </summary> /// <returns>void</returns> public void GetRowSelected(out Int32 ARowNumber, out Int64 ASiteKey) { System.Int32 CurrentRow; DataView AGridDataView; AGridDataView = ((DevAge.ComponentModel.BoundDataView)FDataGrid.DataSource).DataView; ARowNumber = 0; ASiteKey = Convert.ToInt64(((DataRowView)FDataGrid.SelectedDataRows[0]).Row[PartnerEditTDSFamilyMembersTable.GetPartnerKeyDBName()]); // goes throuhg the FamilyID:s in datagrid, break when comes to selected. for (CurrentRow = 0; CurrentRow <= AGridDataView.Count - 1; CurrentRow += 1) { ARowNumber = ARowNumber + 1; if (Convert.ToInt64(AGridDataView[CurrentRow].Row[PartnerEditTDSFamilyMembersTable.GetPartnerKeyDBName()]) == ASiteKey) { break; } } }
/// <summary> /// This function determines the current PartnerKey /// /// </summary> /// <returns>void</returns> public Int64 DetermineCurrentFamilyMemberPartnerKey(TSgrdDataGrid AGrid) { DataRowView[] TheDataRowViewArray; Int64 PersonPartnerKey; // MessageBox.Show(ARow.ToString); TheDataRowViewArray = AGrid.SelectedDataRowsAsDataRowView; // get PartnerKey of current DataRow try { PersonPartnerKey = Convert.ToInt64(TheDataRowViewArray[0].Row[PartnerEditTDSFamilyMembersTable.GetPartnerKeyDBName()]); } catch (Exception) { throw; } // MessageBox.Show(PersonPartnerKey.ToString); return(PersonPartnerKey); }
/// <summary> /// This procedure initializes this System.Object. /// /// </summary> /// <returns>void</returns> public void InitialisePartnerTypeFamilyMembers(PartnerEditTDSFamilyMembersTable AFamilyMembersDT) { // Create the result table if (FFamilyMembersResultDT == null) { FFamilyMembersResultDT = new PartnerEditTDSPartnerTypeChangeFamilyMembersPromotionTable(); } // Logger := new Ict.Common.Logging.TLogging('U:\delphi.net\ICT\Petra\Client\_bin\Debug\Propagation.log'); // Set the column names for the FFamilyMembersResultDT table. this.FResultPartnerKeyName = PartnerEditTDSPartnerTypeChangeFamilyMembersPromotionTable.GetPartnerKeyDBName(); this.FResultTypeCodeName = PartnerEditTDSPartnerTypeChangeFamilyMembersPromotionTable.GetTypeCodeDBName(); this.FResultAddTypeCodeName = PartnerEditTDSPartnerTypeChangeFamilyMembersPromotionTable.GetAddTypeCodeDBName(); this.FResultRemoveTypeCodeName = PartnerEditTDSPartnerTypeChangeFamilyMembersPromotionTable.GetRemoveTypeCodeDBName(); // Set the column names for the FFamilyMembersDT table. this.FFamilyMembersDT = AFamilyMembersDT; this.FTypeCodeModifyName = PartnerEditTDSFamilyMembersTable.GetTypeCodeModifyDBName(); this.FTypeCodePresentName = PartnerEditTDSFamilyMembersTable.GetTypeCodePresentDBName(); this.FPartnerKeyName = PartnerEditTDSFamilyMembersTable.GetPartnerKeyDBName(); }
/// <summary> /// This procedure creates the colums of the DataGrid displayed /// /// </summary> /// <returns>void</returns> public void CreateColumns(TSgrdDataGrid AGrid, System.Data.DataTable ASourceTable, String AAction) { String FAddRemoveHeaderText; SourceGrid.Cells.Editors.TextBoxUITypeEditor l_editor; Ict.Common.TypeConverter.TBooleanToYesNoConverter BooleanToYesNoConverter; l_editor = new SourceGrid.Cells.Editors.TextBoxUITypeEditor(typeof(Boolean)); l_editor.EditableMode = EditableMode.None; BooleanToYesNoConverter = new Ict.Common.TypeConverter.TBooleanToYesNoConverter(); // PetraDtConverter. l_editor.TypeConverter = BooleanToYesNoConverter; this.DataGrid = AGrid; // Assemble column heading if (AAction == "ADD") { FAddRemoveHeaderText = "Add?"; this.FAction = "ADD"; } else { FAddRemoveHeaderText = "Remove?"; this.FAction = "REMOVE"; } // TLogging.Log('Hello Test Markusm: ', [TLoggingType.ToLogfile]); this.FDataGrid.AddCheckBoxColumn(FAddRemoveHeaderText, ASourceTable.Columns[PartnerEditTDSFamilyMembersTable.GetTypeCodeModifyDBName()]); this.FDataGrid.AddTextColumn("Currently assigned", ASourceTable.Columns[PartnerEditTDSFamilyMembersTable.GetTypeCodePresentDBName()], -1, FSpecialCellController, l_editor, null, null); this.FDataGrid.AddTextColumn("Person Name", ASourceTable.Columns[PartnerEditTDSFamilyMembersTable.GetPartnerShortNameDBName()]); this.FDataGrid.AddTextColumn("Person PartnerKey", ASourceTable.Columns[PartnerEditTDSFamilyMembersTable.GetPartnerKeyDBName()]); this.FDataGrid.AddTextColumn("Family ID", ASourceTable.Columns[PartnerEditTDSFamilyMembersTable.GetFamilyIdDBName()]); // Add controller to each line // mNumberRows := AGrid.Rows.Count; // messagebox.show('Number of rows in the grid: ' + mNumberRows.ToString); }
/// <summary> /// Demotes selected ID (and promotes the FamilyID next (lower) to selected FamilyID /// </summary> /// <returns>void</returns> public void DemoteFamilyID() { Int32 Buttonvalue = -1; Int32 NumberOfRows; Int32 Counter; Int32 CounterToMax; Int32 FamilyIDint; System.Object PartnerKey; System.Object FamilyID = -1; System.Object PreviousFamilyID = -1; System.Object PersonName1 = ""; System.Object PersonName2 = ""; Boolean MemberFind; MessageBoxButtons Button; // Get the PartnerKey of the selected Row PartnerKey = ((DataRowView)FDataGrid.SelectedDataRows[0]).Row[PartnerEditTDSFamilyMembersTable.GetPartnerKeyDBName()]; NumberOfRows = GetNumberOfRows(); // for loop to get the selected partners ID for (Counter = 0; Counter <= (NumberOfRows - 1); Counter += 1) { if (FFamilyMembersDV[Counter].Row[PartnerEditTDSFamilyMembersTable.GetPartnerKeyDBName()].ToString() == PartnerKey.ToString()) { FamilyID = FFamilyMembersDV[Counter].Row[PartnerEditTDSFamilyMembersTable.GetFamilyIdDBName()]; PersonName1 = FFamilyMembersDV[Counter].Row[PartnerEditTDSFamilyMembersTable.GetPartnerShortNameDBName()]; break; } } if ((this.IsMinimum()) && (Convert.ToInt32(FamilyID) > 0)) { FFamilyMembersDV[Counter].Row[PartnerEditTDSFamilyMembersTable.GetFamilyIdDBName()] = (object)0; Buttonvalue = 1; FamilyID = (object)0; } // loop to find the nearest smaller FamilyID compared to selected FamilyID. // sets the previous FamilyID to correct. MemberFind = true; FamilyIDint = Convert.ToInt32(FamilyID); // If Family ID is 2, or A parent is to be replaced with child, gives warning. if (FamilyIDint == 2) { Button = MessageBoxButtons.YesNo; if (MessageBox.Show("Parents should be Family ID 0 or 1" + "\r\nAre you sure you want to change this Family ID?", "Family ID Change", Button) == DialogResult.No) { Buttonvalue = 1; } } // if FamilyID to be demoted is 2 and cancel is selected from warnind messagebox, does nothing. otherwice goes through the for loop if (Buttonvalue != 1) { // Goes through the FamilyID:s from 1 to selected FamilyID for (CounterToMax = 1; CounterToMax <= FamilyIDint; CounterToMax += 1) { // Goes through all the FamilyID:s for (Counter = 0; Counter <= (NumberOfRows - 1); Counter += 1) { // when finds FamilyID next to selected (below), Sets the found Family ID to selected if (Convert.ToInt32(FFamilyMembersDV[Counter].Row[PartnerEditTDSFamilyMembersTable.GetFamilyIdDBName()].ToString()) == (FamilyIDint - CounterToMax)) { // saves the found FamilyID PreviousFamilyID = FFamilyMembersDV[Counter].Row[PartnerEditTDSFamilyMembersTable.GetFamilyIdDBName()]; FFamilyMembersDV[Counter].Row[PartnerEditTDSFamilyMembersTable.GetFamilyIdDBName()] = (object)(Convert.ToInt32(PreviousFamilyID) + 1); PersonName2 = FFamilyMembersDV[Counter].Row[PartnerEditTDSFamilyMembersTable.GetPartnerShortNameDBName()]; if (PersonName2 == PersonName1) { PersonName1 = PreviousPartnerMemory; } MemberFind = false; break; } } if (!MemberFind) { break; } } // loop to set the selected FamilyID to the PreviousFamilyID for (Counter = 0; Counter <= (NumberOfRows - 1); Counter += 1) { if (FFamilyMembersDV[Counter].Row[PartnerEditTDSFamilyMembersTable.GetPartnerKeyDBName()].ToString() == PartnerKey.ToString()) { FFamilyMembersDV[Counter].Row[PartnerEditTDSFamilyMembersTable.GetFamilyIdDBName()] = PreviousFamilyID; break; } } MessageBox.Show(String.Format(StrFamilyIDChangeDone, PersonName1, FamilyID, PreviousFamilyID, PersonName2, PreviousFamilyID, (Convert.ToInt32(PreviousFamilyID) + 1)), StrFamilyIDChangeDoneTitle); PreviousPartnerMemory = PersonName1; } else { } }
/// <summary> /// todoComment /// </summary> /// <returns></returns> public Int64 GetPartnerKeySelected() { return(Convert.ToInt64(((DataRowView)FDataGrid.SelectedDataRows[0]).Row[PartnerEditTDSFamilyMembersTable.GetPartnerKeyDBName()])); }
/// <summary> /// Promotes selected ID (and demotes the FamilyID next (up) to selected FamilyID /// </summary> /// <returns>void</returns> public void PromoteFamilyID() { Int32 buttonvalue = -1; Int32 Counter1; Int32 NumberOfRows; Int32 Counter2; Int32 Counter2ToMax; Int32 FamilyIDint; System.Object PartnerKey; System.Object FamilyID = -1; System.Object PersonName1 = ""; System.Object PersonName2 = ""; System.Object NextFamilyID = ""; Boolean MemberFind; MessageBoxButtons Button; // Get the PartnerKey of the selected Row PartnerKey = ((DataRowView)FDataGrid.SelectedDataRows[0]).Row[PartnerEditTDSFamilyMembersTable.GetPartnerKeyDBName()]; NumberOfRows = GetNumberOfRows(); // for loop to get the selected partners ID for (Counter2 = 0; Counter2 <= (NumberOfRows - 1); Counter2 += 1) { if (FFamilyMembersDV[Counter2].Row[PartnerEditTDSFamilyMembersTable.GetPartnerKeyDBName()].ToString() == PartnerKey.ToString()) { FamilyID = FFamilyMembersDV[Counter2].Row[PartnerEditTDSFamilyMembersTable.GetFamilyIdDBName()]; PersonName1 = FFamilyMembersDV[Counter2].Row[PartnerEditTDSFamilyMembersTable.GetPartnerShortNameDBName()]; break; } } // loop to find the nearest FamilyID compared to selected FamilyID. // sets the next FamilyID to correct. MemberFind = true; FamilyIDint = Convert.ToInt32(FamilyID); // If Family ID 1 (parent) is about to be promoted if (FamilyIDint == 1) { Button = MessageBoxButtons.YesNo; buttonvalue = 0; // if pressed No to question below, does nothing. if (MessageBox.Show("Parents should be Family ID 0 or 1" + "\r\nAre you sure you want to change this Family ID?", "Family ID Change", Button) == DialogResult.No) { buttonvalue = 1; } } // Executes this loop, if Family ID to be promoted is not 1. if (buttonvalue != 1) { Counter2ToMax = 100; // goes through all values from selected +1 to 100+selected. for (Counter1 = 1; Counter1 <= Counter2ToMax; Counter1 += 1) { // goes through all FamilyID:s for (Counter2 = 0; Counter2 <= (NumberOfRows - 1); Counter2 += 1) { // When finds FamilyID that's next (above) to selected FamilyID, Replaces the Found Family members ID with selected ID if (Convert.ToInt32(FFamilyMembersDV[Counter2].Row[PartnerEditTDSFamilyMembersTable.GetFamilyIdDBName()].ToString()) == FamilyIDint + Counter1) { // saves the FamilyIF just found NextFamilyID = FFamilyMembersDV[Counter2].Row[PartnerEditTDSFamilyMembersTable.GetFamilyIdDBName()]; FFamilyMembersDV[Counter2].Row[PartnerEditTDSFamilyMembersTable.GetFamilyIdDBName()] = FamilyID; PersonName2 = FFamilyMembersDV[Counter2].Row[PartnerEditTDSFamilyMembersTable.GetPartnerShortNameDBName()]; MemberFind = false; break; } } if (!MemberFind) { break; } } // end; // loop to set the selected FamilyID to the PreviousFamilyID for (Counter2 = 0; Counter2 <= (NumberOfRows - 1); Counter2 += 1) { if (FFamilyMembersDV[Counter2].Row[PartnerEditTDSFamilyMembersTable.GetPartnerKeyDBName()].ToString() == PartnerKey.ToString()) { FFamilyMembersDV[Counter2].Row[PartnerEditTDSFamilyMembersTable.GetFamilyIdDBName()] = (object)(FamilyIDint + 1); break; } } // button := MessageBoxButtons.OK; MessageBox.Show(String.Format(StrFamilyIDChangeDone, PersonName1, FamilyID, (FamilyIDint + 1), PersonName2, NextFamilyID, FamilyID), StrFamilyIDChangeDoneTitle); } else { } }