Пример #1
0
  }//public static void ContactBrowse()

  /// <summary>ContactDetail</summary>
  public static void ContactDetail
  (
       string      databaseConnectionString,
   ref string      exceptionMessage,
   ref DataSet     dataSetContact,
   ref int         sequenceOrderId,
   ref Contact     contact,
   ref DataSet[]   dataSetMultiple
  )
  {  

   String  firstName                 =  null;
   String  lastName                  =  null;
   String  otherName                 =  null;
   String  company                   =  null;
   String  prefix                    =  null;
   String  suffix                    =  null;
   String  commentary                =  null;
   String  scriptureReference        =  null;

   StringBuilder  sb                 =  null;
   
   sb = new StringBuilder();
   sb.AppendFormat
   ( 
    SQLSelectContactDetail,
    sequenceOrderId
   );

   UtilityDatabase.DatabaseQuery
   (
        databaseConnectionString,
    ref exceptionMessage,
    ref dataSetContact,
        sb.ToString(),
        CommandType.Text   
   );
   
   //UtilityDatabase.PrintValues( dataSet );
   
   try
   {
    firstName = System.Convert.ToString
    (
     UtilityDatabase.DataSetTableRowColumn
     ( 
      dataSetContact,
      "Table",
      0,
      "FirstName"
     )
    ); 

    lastName = System.Convert.ToString
    (
     UtilityDatabase.DataSetTableRowColumn
     ( 
      dataSetContact,
      "Table",
      0,
      "LastName"
     )
    ); 

    otherName = System.Convert.ToString
    (
     UtilityDatabase.DataSetTableRowColumn
     ( 
      dataSetContact,
      "Table",
      0,
      "OtherName"
     )
    ); 

    company = System.Convert.ToString
    (
     UtilityDatabase.DataSetTableRowColumn
     ( 
      dataSetContact,
      "Table",
      0,
      "Company"
     )
    );

    prefix = System.Convert.ToString
    (
     UtilityDatabase.DataSetTableRowColumn
     ( 
      dataSetContact,
      "Table",
      0,
      "Prefix"
     )
    );

    suffix = System.Convert.ToString
    (
     UtilityDatabase.DataSetTableRowColumn
     ( 
      dataSetContact,
      "Table",
      0,
      "Suffix"
     )
    );

    commentary = System.Convert.ToString
    (
     UtilityDatabase.DataSetTableRowColumn
     ( 
      dataSetContact,
      "Table",
      0,
      "Commentary"
     )
    );

    scriptureReference = System.Convert.ToString
    (
     UtilityDatabase.DataSetTableRowColumn
     ( 
      dataSetContact,
      "Table",
      0,
      "ScriptureReference"
     )
    );
    
    contact = new Contact
    (
     sequenceOrderId,
     firstName,
     lastName,
     otherName,
     company,
     prefix,
     suffix,
     commentary,
     scriptureReference
    );    
    
   }//try
   catch ( Exception exception )
   {
   	exceptionMessage = exception.Message;
   }	 

   for( int dataSetIndex = 0; dataSetIndex < dataSetMultiple.Length; ++dataSetIndex )
   {
    sb = new StringBuilder();  

    sb.AppendFormat
    ( 
     SQLSelectContactDetailGridView[dataSetIndex],
     contact.sequenceOrderId
    );

    UtilityDatabase.DatabaseQuery
    (
          databaseConnectionString,
     ref  exceptionMessage,
     ref  dataSetMultiple[dataSetIndex],
          sb.ToString(),
          CommandType.Text
    );

   }//for( int dataSetIndex = 0; dataSetIndex <= dataSet.Length; ++dataSetIndex )
   
  }//public static void ContactDetail()
  }//public static void Main.

  ///<summary>ImportExport.</summary>
  ///<param name="filenameImport">The filename import.</param>
  ///<param name="filenameExport">The filename export.</param>
  ///<param name="scriptureReferenceAssociates">The alphabet sequence associates.</param>
  public static void ImportExport
  (
   string filenameImport,
   string filenameExport,
   string scriptureReferenceAssociates
  )
  {

   int[]                                 alphabetSequenceIndex              = null;
   int                                   dataRowIndex                       = -1;

   string exceptionMessage                                                  = null;
   string fileNameWithoutExtension                                          = null;
   string record                                                            = null;
   string[]                              word                               = null;

   System.Data.DataColumn                dataColumn                         = null;
   System.Data.DataColumn                dataColumnForeignKey               = null;
   System.Data.DataColumn                dataColumnPrimaryKey               = null;

   System.Data.DataRelation              dataRelation                       = null;
   System.Data.DataRow                   dataRow                            = null;
   System.Data.DataSet                   dataSet                            = null;

   System.Data.DataTable                 dataTableAlphabetSequence          = null;
   System.Data.DataTable                 dataTableTheWord                   = null;

   StreamReader                          streamReader                       = null;

   ScriptureReferenceAlphabetSequence[]  scriptureReferenceAlphabetSequence = null;

   StringBuilder                         sbTitle                            = null;

   sbTitle = new StringBuilder();

   try
   {
    if (!File.Exists(filenameImport))
    {
     System.Console.WriteLine("File not found: {0}", filenameImport); 
     return;
    }
    fileNameWithoutExtension = Path.GetFileNameWithoutExtension( filenameImport ); 
    dataSet = new DataSet();
    dataSet.DataSetName = TheWord.NodeRoot;
    // Create an instance of StreamReader to read from a file.
    // The using statement also closes the StreamReader.
     
    streamReader = new StreamReader(filenameImport); 

    // Create a new DataTable.
    dataTableTheWord = new DataTable(DataTableNameTheWord);

    dataColumn                =  new DataColumn();
    dataColumn.ColumnName     =  "SequenceOrderId";
    dataColumn.DataType       =  System.Type.GetType("System.Int32");
    dataColumn.DefaultValue   =  null;
    dataTableTheWord.Columns.Add( dataColumn );
    dataColumnPrimaryKey      = dataTableTheWord.Columns["SequenceOrderId"];

    dataColumn                = new DataColumn();
    dataColumn.ColumnName     = "Dated";
    dataColumn.DataType       = System.Type.GetType("System.DateTime");
    dataTableTheWord.Columns.Add( dataColumn );

    dataColumn                = new DataColumn();
    dataColumn.ColumnName     = "ScriptureReference";
    dataColumn.DataType       = System.Type.GetType("System.String");
    dataTableTheWord.Columns.Add( dataColumn );

    dataColumn                = new DataColumn();
    dataColumn.ColumnName     = "Title";
    dataColumn.DataType       = System.Type.GetType("System.String");
    dataTableTheWord.Columns.Add( dataColumn );

    dataSet.Tables.Add( dataTableTheWord );

    dataRow                   = dataTableTheWord.NewRow();
    dataRow["Dated"]          = System.DateTime.Today;

    dataTableTheWord.Rows.Add( dataRow );

    // Create a new DataTable.
    dataTableAlphabetSequence = new DataTable(DataTableNameAlphabetSequence);

    dataColumn = new DataColumn();
    dataColumn.ColumnName    = "TheWordId";
    dataColumn.DataType      = System.Type.GetType("System.Int32");
    dataColumn.DefaultValue  = null;
    dataTableAlphabetSequence.Columns.Add( dataColumn );
    dataColumnForeignKey     = dataTableAlphabetSequence.Columns["TheWordId"];

    dataColumn               = new DataColumn();
    dataColumn.ColumnName    = "SequenceOrderId";
    dataColumn.DataType      = System.Type.GetType("System.Int32");
    dataTableAlphabetSequence.Columns.Add( dataColumn );

    dataColumn               = new DataColumn();
    dataColumn.ColumnName    = "Word";
    dataColumn.DataType      = System.Type.GetType("System.String");
    dataTableAlphabetSequence.Columns.Add( dataColumn );

    dataColumn               = new DataColumn();
    dataColumn.ColumnName    = "AlphabetSequenceIndex";
    dataColumn.DataType      = System.Type.GetType("System.Int32");
    dataTableAlphabetSequence.Columns.Add( dataColumn );

    dataColumn               = new DataColumn();
    dataColumn.ColumnName    = "Commentary";
    dataColumn.DataType      = System.Type.GetType("System.String");
    dataColumn.DefaultValue  = null;
    dataTableAlphabetSequence.Columns.Add( dataColumn );

    dataColumn               = new DataColumn();
    dataColumn.ColumnName    = "ScriptureReference";
    dataColumn.DataType      = System.Type.GetType("System.String");
    dataTableAlphabetSequence.Columns.Add( dataColumn );

    dataSet.Tables.Add( dataTableAlphabetSequence );

    #if (DEBUG)   
     System.Console.WriteLine("Data Column Primary Key: {0}", dataColumnPrimaryKey);
     System.Console.WriteLine("Data Column Foreign Key: {0}", dataColumnForeignKey);
    #endif 
    
    dataRelation = new DataRelation
    (
      DataRelationNameAlphabetSequence, 
      dataColumnPrimaryKey,
      dataColumnForeignKey
    );

    dataRelation.Nested = true;
    dataSet.Relations.Add( dataRelation );

    // Read and display lines from the file until the end of 
    // the file is reached.
      
    while ( true ) 
    {
     record = streamReader.ReadLine();

     if ( record == null )
     {
      break;
     }

     dataRow = dataTableAlphabetSequence.NewRow();
     dataRow["Word"] = record;
     sbTitle.Append( record );
     sbTitle.Append( Environment.NewLine );
     dataTableAlphabetSequence.Rows.Add( dataRow );
    }//while ( true ) 

    alphabetSequenceIndex              = new int[dataTableAlphabetSequence.Rows.Count];
    scriptureReferenceAlphabetSequence = new ScriptureReferenceAlphabetSequence[dataTableAlphabetSequence.Rows.Count];
    word                               = new String[dataTableAlphabetSequence.Rows.Count];

    dataRowIndex = 0;
    foreach ( DataRow dataRowCurrent in dataTableAlphabetSequence.Rows )
    {
     word[dataRowIndex]                = ( string ) dataRowCurrent["Word"];
     System.Console.WriteLine( dataRowCurrent["Word"] );
     ++dataRowIndex;
    }//foreach ( DataRow dataRowCurrent in dataTableAlphabetSequence.Rows )

    UtilityDatabase.DataSetTableRowColumn
    (
     dataSet,
     "TheWord",
     0,
     "Title",
     sbTitle.ToString()
    );

    AlphabetSequence.AlphabetSequenceQuery
    (
     ref  DatabaseConnectionString,
     ref  exceptionMessage,
     ref  word,
          scriptureReferenceAssociates,
     ref  alphabetSequenceIndex,
     ref  scriptureReferenceAlphabetSequence
    );

    for ( dataRowIndex = 0; dataRowIndex < dataTableAlphabetSequence.Rows.Count; ++dataRowIndex )
    {

     UtilityDatabase.DataSetTableRowColumn
     (
      dataSet,
      DataTableNameAlphabetSequence,
      dataRowIndex,
      "AlphabetSequenceIndex",
      scriptureReferenceAlphabetSequence[ dataRowIndex ].AlphabetSequence
     );

     UtilityDatabase.DataSetTableRowColumn
     (
      dataSet,
      DataTableNameAlphabetSequence,
      dataRowIndex,
      "ScriptureReference",
      scriptureReferenceAlphabetSequence[ dataRowIndex ].ScriptureReferenceCurrent
     );

     UtilityDatabase.DataSetTableRowColumn
     (
      dataSet,
      DataTableNameAlphabetSequence,
      dataRowIndex,
      "SequenceOrderId",
      scriptureReferenceAlphabetSequence[ dataRowIndex ].SequenceOrderId
     );

    }//foreach ( DataRow dataRowCurrent in dataTableAlphabetSequence.Rows )

    ScriptureReference.ScriptureReferenceURI
    (
         TheWord.DatabaseConnectionString,
         TheWord.FilenameConfigurationXml,
     ref exceptionMessage,
     ref dataSet
    );//ScriptureReference.ScriptureReferenceURI

    UtilityXml.WriteXml
    (
         dataSet,
     ref exceptionMessage,
     ref filenameExport,
     ref TheWord.FilenameXslt
    );
   }//try
   catch (Exception exception)
   {
    System.Console.WriteLine("Exception: ", exception.Message);
   }//catch (Exception exception)
   finally
   {
   }//finally
  }//public static void ImportExport