<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 閱讀(264) 評論(0)  編輯  收藏 所屬分類: .Net
    主站蜘蛛池模板: 国产精品va无码免费麻豆| 国产色婷婷精品免费视频| 免费无码又爽又刺激高潮 | 久久精品视频亚洲| 天堂亚洲国产中文在线| kk4kk免费视频毛片| 日韩欧毛片免费视频| 国产亚洲精品AA片在线观看不加载| 亚洲午夜精品久久久久久人妖| 亚洲av无码成人精品区一本二本| 少妇性饥渴无码A区免费| 妞干网在线免费视频| 亚洲AV综合色区无码一区| 久久精品国产亚洲AV电影网| 久久久久久久久久国产精品免费| 免费乱理伦在线播放| 亚洲女人初试黑人巨高清| 国产精品青草视频免费播放| 青春禁区视频在线观看直播免费| 亚洲国产精华液网站w| 色偷偷亚洲第一综合网| 1000部羞羞禁止免费观看视频| 亚洲国产精品一区二区三区久久| 亚洲剧情在线观看| 99精品视频在线观看免费| 日韩视频免费一区二区三区| 久久久无码精品亚洲日韩按摩 | 91在线手机精品免费观看| aa级女人大片喷水视频免费| 成人人免费夜夜视频观看| 亚洲人成依人成综合网| h在线看免费视频网站男男| 四虎成人免费观看在线网址 | 1024免费福利永久观看网站| 伊人亚洲综合青草青草久热| 亚洲精品色播一区二区 | 亚洲熟妇无码另类久久久| 国产成人高清亚洲一区久久 | 亚洲图片激情小说| 嫩草影院在线播放www免费观看| 亚洲av无码成人精品区在线播放 |