public static void UpdateRegistry(string DBServerName, string Port, string NetworkLibrary,
                                          string DatabaseName, string DatabaseUserID, string DatabasePwd)
        {
            ModifyRegistry reg = new ModifyRegistry();

            if (DBServerName != null)
            {
                reg.Write("DBServerName", DBServerName);
            }
            if (DBServerName != null)
            {
                reg.Write("Port", Port);
            }
            if (DBServerName != null)
            {
                reg.Write("NetworkLibrary", NetworkLibrary);
            }
            if (DBServerName != null)
            {
                reg.Write("DatabaseName", DatabaseName);
            }
            if (DBServerName != null)
            {
                reg.Write("DatabaseUserID", DatabaseUserID);
            }
            if (DBServerName != null)
            {
                reg.Write("DatabasePwd", DatabasePwd);
            }
        }
 public static void UpdateRegistry(string DBServerName, string Port, string NetworkLibrary,
     string DatabaseName, string DatabaseUserID, string DatabasePwd)
 {
     ModifyRegistry reg = new ModifyRegistry();
     if (DBServerName != null)
     {
         reg.Write("DBServerName", DBServerName);
     }
     if (DBServerName != null)
     {
         reg.Write("Port", Port);
     }
     if (DBServerName != null)
     {
         reg.Write("NetworkLibrary", NetworkLibrary);
     }
     if (DBServerName != null)
     {
         reg.Write("DatabaseName", DatabaseName);
     }
     if (DBServerName != null)
     {
         reg.Write("DatabaseUserID", DatabaseUserID);
     }
     if (DBServerName != null)
     {
         reg.Write("DatabasePwd", DatabasePwd);
     }
 }
 public static void CheckRegistry()
 {
     //RemoveRegistry();
     ModifyRegistry reg = new ModifyRegistry();
     if(string.IsNullOrEmpty(reg.Read("DBServerName")))
         UpdateRegistry(Constant.INIT_IP, Constant.INIT_PORT, Constant.INIT_NETWORK_LIBRARY,
             Constant.INIT_DATABASE_NAME, Constant.INIT_USER_ID, Constant.INIT_PW);
 }
        public static void CheckRegistry()
        {
            //RemoveRegistry();
            ModifyRegistry reg = new ModifyRegistry();

            if (string.IsNullOrEmpty(reg.Read("DBServerName")))
            {
                UpdateRegistry(Constant.INIT_IP, Constant.INIT_PORT, Constant.INIT_NETWORK_LIBRARY,
                               Constant.INIT_DATABASE_NAME, Constant.INIT_USER_ID, Constant.INIT_PW);
            }
        }
        public static string BuildStringConnection()
        {
            ModifyRegistry             reg     = new ModifyRegistry();
            SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();

            builder.NetworkLibrary = reg.Read("NetworkLibrary");
            builder.DataSource     = reg.Read("DBServerName") + "," + reg.Read("Port");
            builder.InitialCatalog = reg.Read("DatabaseName");
            if (!string.IsNullOrEmpty(reg.Read("DatabaseUserID")) &&
                !string.IsNullOrEmpty(reg.Read("DatabasePwd")))
            {
                builder.UserID   = reg.Read("DatabaseUserID");
                builder.Password = reg.Read("DatabasePwd");
            }
            //MessageBox.Show(builder.ConnectionString);
            return(builder.ConnectionString);
        }
        public static string BuildStringConnection()
        {
            ModifyRegistry reg = new ModifyRegistry();
            SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();

            builder.NetworkLibrary = reg.Read("NetworkLibrary");
            builder.DataSource = reg.Read("DBServerName") +"," + reg.Read("Port");
            builder.InitialCatalog = reg.Read("DatabaseName");
            if (!string.IsNullOrEmpty(reg.Read("DatabaseUserID")) && 
                !string.IsNullOrEmpty(reg.Read("DatabasePwd")))
            {
                builder.UserID = reg.Read("DatabaseUserID");
                builder.Password = reg.Read("DatabasePwd");
            }
            //MessageBox.Show(builder.ConnectionString);
            return builder.ConnectionString;
        }
        private static void RemoveRegistry()
        {
            ModifyRegistry reg = new ModifyRegistry();

            reg.DeleteSubKeyTree();
        }
        private void DBConfiguration_Load(object sender, EventArgs e)
        {
            ModifyRegistry reg = new ModifyRegistry();

            txtIP.Text = String.IsNullOrEmpty(reg.Read("DBServerName")) ? BHConstant.INIT_IP : reg.Read("DBServerName");
            txtPort.Text = String.IsNullOrEmpty(reg.Read("Port")) ? BHConstant.INIT_PORT : reg.Read("Port");
            txtNet.Text = String.IsNullOrEmpty(reg.Read("NetworkLibrary")) ? BHConstant.INIT_NETWORK_LIBRARY : reg.Read("NetworkLibrary");
            txtDataName.Text = String.IsNullOrEmpty(reg.Read("DatabaseName")) ? BHConstant.INIT_DATABASE_NAME : reg.Read("DatabaseName");
            txtUsername.Text = String.IsNullOrEmpty(reg.Read("DatabaseUserID")) ? BHConstant.INIT_USER_ID : reg.Read("DatabaseUserID");
            txtPass.Text = String.IsNullOrEmpty(reg.Read("DatabasePwd")) ? BHConstant.INIT_PW : reg.Read("DatabasePwd");
        }
 private static void RemoveRegistry()
 {
     ModifyRegistry reg = new ModifyRegistry();
     reg.DeleteSubKeyTree();
 }