<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Data.SqlClient;
    using System.Data.OleDb;

    namespace CSL.Nouka.Library.Presentation
    {
        
    //-------------------------------------------------------------------------
        /// <summary>
        
    /// FrmKihonSetting
        
    /// </summary>
        //-------------------------------------------------------------------------
        public partial class FrmKihonSetting : Form
        {
            
    private string connStr = "";
            
    private OleDbConnection mySqlConnection; 

            
    //-------------------------------------------------------------------------
            /// <summary>
            
    /// init FrmKihonSetting
            
    /// </summary>
            //-------------------------------------------------------------------------
            public FrmKihonSetting()
            {
                InitializeComponent();

                
    this.txtServerName.Text = CSL.Nouka.Library.Properties.Settings.Default.DBSettingServerName;
                
    this.cmbCertification.SelectedIndex = Convert.ToInt32(CSL.Nouka.Library.Properties.Settings.Default.DBSettingCmbCertificationSelectedIndex);
                
    this.txtUserName.Text   = CSL.Nouka.Library.Properties.Settings.Default.DBSettingTxtUserName;
                
    this.txtPswd.Text       = CSL.Nouka.Library.Properties.Settings.Default.DBSettingTxtPswd;
            }

            
    //-------------------------------------------------------------------------
            /// <summary>
            
    /// Windows    認証 ----- 0
            
    /// SQL Server 認証 ----- 1
            
    /// </summary>
            
    /// <param name="sender"></param>
            
    /// <param name="e"></param>
            //-------------------------------------------------------------------------
            private void cmbCertification_SelectedIndexChanged(object sender, EventArgs e)
            {
                
    if (cmbCertification.SelectedIndex.ToString() == "0")
                {
                    
    this.labelUserName.Enabled = false;
                    
    this.labelPswd.Enabled     = false;
                    
    this.txtUserName.Enabled   = false;
                    
    this.txtPswd.Enabled       = false;
                }
                
    else if (cmbCertification.SelectedIndex.ToString() == "1")
                {
                    
    this.labelUserName.Enabled = true;
                    
    this.labelPswd.Enabled     = true;
                    
    this.txtUserName.Enabled   = true;
                    
    this.txtPswd.Enabled       = true;
                }
            }

            
    //-------------------------------------------------------------------------
            /// <summary>
            
    /// OK
            
    /// </summary>
            
    /// <param name="sender"></param>
            
    /// <param name="e"></param>
            //-------------------------------------------------------------------------
            private void btnOK_Click(object sender, EventArgs e)
            {
                
    if (cmbCertification.SelectedIndex.ToString() == "0")
                {
                    connStr 
    = "Provider=SQLOLEDB;Server=" + this.txtServerName.Text + ";Trusted_Connection=Yes;Database=Nouka";
                }
                
    else
                {
                    connStr 
    = "Provider=SQLOLEDB;Server=" + this.txtServerName.Text + ";uid=" + this.txtUserName.Text + ";pwd=" + this.txtPswd.Text + ";Database=Nouka";
                    CSL.Nouka.Library.Properties.Settings.Default.DBSettingTxtUserName 
    = this.txtUserName.Text;
                    CSL.Nouka.Library.Properties.Settings.Default.DBSettingTxtPswd 
    = this.txtPswd.Text;
                }
                CSL.Nouka.Library.Properties.Settings.Default.ConnStr 
    = connStr;
                CSL.Nouka.Library.Properties.Settings.Default.DBSettingCmbCertificationSelectedIndex 
    = cmbCertification.SelectedIndex.ToString();
                CSL.Nouka.Library.Properties.Settings.Default.DBSettingServerName 
    = this.txtServerName.Text;
                
    if (isConnectSucceed(connStr))
                {
                    CSL.Nouka.Library.Properties.Settings.Default.Save();
                    MessageBox.Show(
    "データベースに接続しました。""接続", MessageBoxButtons.OK);
                    
    this.Close();
                }
                
    else
                {
                    MessageBox.Show(
    "接続失敗しました。""接続", MessageBoxButtons.OK);
                }
            }

            
    //-------------------------------------------------------------------------
            /// <summary>
            
    /// Cancel
            
    /// </summary>
            
    /// <param name="sender"></param>
            
    /// <param name="e"></param>
            //-------------------------------------------------------------------------
            private void btnCancel_Click(object sender, EventArgs e)
            {
                
    this.Close();
            }

            
    //-------------------------------------------------------------------------
            /// <summary>
            
    /// Test Connection
            
    /// </summary>
            
    /// <param name="connStr"></param>
            
    /// <returns></returns>
            //-------------------------------------------------------------------------
            private bool isConnectSucceed(string connStr)
            {
                
    bool isSucceed = false;
                
    try
                {
                    mySqlConnection 
    = new OleDbConnection(connStr);
                    mySqlConnection.Open();
                    isSucceed 
    = true;
                }
                
    catch
                {
                    isSucceed 
    = false;
                }
                
    finally
                {
                    mySqlConnection.Close();
                }
                
    return isSucceed;
            }
        }
    }








    posted on 2010-11-24 16:13 Ying-er 閱讀(268) 評論(0)  編輯  收藏 所屬分類: .Net
    主站蜘蛛池模板: 24小时在线免费视频| 国产真人无码作爱视频免费| 免费看国产精品3a黄的视频 | 免费看国产一级片| 亚洲最大的成人网| 女人18毛片a级毛片免费| 亚洲资源最新版在线观看| 免费精品国产日韩热久久| 久久乐国产综合亚洲精品| 在线免费一区二区| 色多多免费视频观看区一区| 亚洲国产精品无码久久青草| 久久久久免费视频| 亚洲av中文无码乱人伦在线r▽| 一级毛片**不卡免费播| 亚洲综合在线成人一区| 成人在线免费观看| 日本永久免费a∨在线视频| 夜夜春亚洲嫩草影院| 久久久久免费精品国产小说| 亚洲啪啪免费视频| 破了亲妺妺的处免费视频国产 | 亚洲gv白嫩小受在线观看| **实干一级毛片aa免费| 亚洲欧洲无码一区二区三区| 亚洲高清成人一区二区三区| a级在线免费观看| 亚洲综合一区二区三区四区五区| 亚洲国产精品第一区二区三区| 大地资源在线资源免费观看| 亚洲区精品久久一区二区三区| 国产又大又黑又粗免费视频| 搜日本一区二区三区免费高清视频 | 亚洲国模精品一区| 特级无码毛片免费视频尤物 | 国产成人不卡亚洲精品91 | 亚洲人成在线中文字幕| 高清在线亚洲精品国产二区| 精品免费视在线观看| 亚洲精品天堂无码中文字幕| 国产亚洲美日韩AV中文字幕无码成人|