<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
    主站蜘蛛池模板: 成人性生交大片免费看无遮挡| 亚洲成人黄色在线| 免费VA在线观看无码| 四虎免费影院ww4164h| 亚洲天堂视频在线观看| a级毛片免费播放| 亚洲午夜一区二区电影院| 国偷自产一区二区免费视频| 亚洲丰满熟女一区二区v| 59pao成国产成视频永久免费 | 亚洲av午夜福利精品一区| 久久久久久av无码免费看大片| 亚洲中文字幕第一页在线| 男人天堂免费视频| 亚洲国产一区在线| 免费成人福利视频| 亚洲精品V天堂中文字幕| 免费在线观看亚洲| 丰满人妻一区二区三区免费视频| 亚洲人成人一区二区三区| tom影院亚洲国产一区二区| 中国在线观看免费国语版| 亚洲自偷自偷在线成人网站传媒| 国产又黄又爽又刺激的免费网址| 污视频网站免费观看| 亚洲AV无码专区亚洲AV伊甸园| 中国人xxxxx69免费视频| 亚洲а∨精品天堂在线| 国产黄色一级毛片亚洲黄片大全| 丁香花在线观看免费观看图片| 久久精品国产亚洲av水果派| 西西大胆无码视频免费| MM1313亚洲精品无码久久| 国产成人综合亚洲AV第一页| 亚洲网站在线免费观看| 亚洲狠狠婷婷综合久久| 伊人婷婷综合缴情亚洲五月| 91香蕉成人免费网站| 一级毛片在线完整免费观看| 亚洲一二成人精品区| 国产大片91精品免费看3|