コード例 #1
0
ファイル: Form1.cs プロジェクト: zenitsuga/ZRetailer
        private void Initialization()
        {
            this.BackgroundImageLayout = ImageLayout.Stretch;
            string imagepath = inif.Read("ImageBackground", "System");

            if (!cf.isFileExists(imagepath))
            {
                imagepath = Environment.CurrentDirectory + "\\Resources\\BG_SAMPLE.jpg";
            }
            Image imageBg = Image.FromFile(imagepath);

            this.BackgroundImage = imageBg;
            string Transac = inif.Read("Transactions", "System").ToUpper();

            if (Transac == "ONLINE")
            {
                isOnline = true;
            }
            tssTransaction.Text = Transac == "ONLINE" ? "ONLINE" : "OFFLINE";
            ConnectionType      = inif.Read("ConnectionType", "System").ToUpper();

            //For Local Connection
            if (ConnectionType.ToUpper() == "IP")
            {
                string _Servername   = inif.Read("ServerName", "Local");
                string _Databasename = inif.Read("Databasename", "Local");
                string _Username     = inif.Read("Username", "Local");
                string _Password     = inif.Read("Password", "Local");

                if (cf.checkServerConnection("local", _Servername, _Databasename, _Username, _Password, ref SQLCLient))
                {
                    tssLocalStatus.Text = "LOCAL: Connected";
                }
                else
                {
                    MessageBox.Show("Warning: System Connection Type was " + ConnectionType + ".\nThe status is Disconnected. Please check your settings first.", "Server Connection Failed", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    tssServerStatus.Text = "SERVER: Not Connected";
                    Error2Close          = true;
                    Application.Exit();
                }
            }

            //For Online Connection
            if (Transac == "ONLINE")
            {
                if (!ConnType.Contains(ConnectionType))
                {
                    Error2Close = true;
                    MessageBox.Show("Error: ConnectionType not found \n(Please choose between IP or WebLink).\nConnection Type: " + ConnectionType, "ConnectionType is Invalid", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Application.Exit();
                }
                else
                {
                    if (ConnectionType.ToUpper() == "IP")
                    {
                        string Servername   = inif.Read("ServerName", "Server");
                        string Databasename = inif.Read("Databasename", "Server");
                        string Username     = inif.Read("Username", "Server");
                        string Password     = inif.Read("Password", "Server");

                        if (cf.checkServerConnection("server", Servername, Databasename, Username, Password, ref SQLServer))
                        {
                            tssServerStatus.Text = "SERVER: Connected";
                        }
                        else
                        {
                            MessageBox.Show("Warning: System Connection Type was " + ConnectionType + ".\nThe status is Disconnected. Please check your settings first.", "Server Connection Failed", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            tssServerStatus.Text = "SERVER: Not Connected";
                            Error2Close          = true;
                            Application.Exit();
                        }
                    }
                }
            }
        }