Main Program

Posted by imomins on March 29, 2011 at 12:44 AM

using System;

using System.Collections.Generic;

using System.Linq;

using System.Windows.Forms;

using System.Data;

using System.IO;

using net.ERP.Constants;

using net.ERP.Utility;

using net.ERP.DatabaseSchema.TableSchema;

using net.ERP.DatabaseSchema.DBExistanceChecking;

using net.ERP.DatabaseSchema.DefaultDataConfiguration;

 

namespace net.ERP.MainEntryPoint

{

    static class MainProgram

    {

        /// <summary>

        /// The main entry point for the application.

        /// </summary>

        [STAThread]

 

        static void Main()

        {

            try

            {

                Application.EnableVisualStyles();

                Application.SetCompatibleTextRenderingDefault(false);

 

                try

                {

                    //Create an instance of StreamReader to read from a file and the using statement also closes the StreamReader.

                    using (StreamReader sr = new StreamReader("Server.txt"))

                    {

                        string lstrFileText = null;

                        //Read and display lines from the file until the end of the file is reached.

                        while ((lstrFileText = sr.ReadLine()) != null)

                        {

                            CommonConstants.gmpubstastrServerName = lstrFileText;

                        }

                    }

                }

                catch (Exception pexpServerSearch)

                {

                    //Let the user know what went wrong.

                    MessageBox.Show(pexpServerSearch.Message);

                }

 

                DatabaseConnector databaseConnector = new DatabaseConnector();

                databaseConnector.mpubvConnectDatabase(CommonConstants.gmpubstastrServerName);

 

                if (DatabaseConnector.gmpubstasqlconnSQLConnection != null)

                {

                    DatabaseExistanceChecking databaseExistanceChecking = new DatabaseExistanceChecking();

                    if (databaseExistanceChecking.mpubbIsDatabaseExists(CommonConstants.gmpubstastrServerName) == false)

                    {

                        Application.Run(new frmNewCompanyInstallation());

                        MessageBox.Show("Database created successfully. 'Software Support Team' suggests you to close the application and continue from the second time for processing.", CommonConstants.gmpubcstrUserConfirmation, MessageBoxButtons.OK, MessageBoxIcon.Information);

                        Application.Run(new mdiNetERP());

                    }

                    else

                    {

                        Application.Run(new mdiNetERP());

                    }

                }

            }

            catch (Exception ae)

            {

                MessageBox.Show(ae .Message .ToString ());

            }

            finally

            {

                if (DatabaseConnector.gmpubstasqlconnSQLConnection.State == ConnectionState.Open)

                {

                    DatabaseConnector.gmpubstasqlconnSQLConnection.Close();

                }

            }

        }

    }

}

 


Categories: C#, Personal

Post a Comment

Oops!

Oops, you forgot something.

Oops!

The words you entered did not match the given text. Please try again.

You must be a member to comment on this page. Sign In or Register

0 Comments