<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
    主站蜘蛛池模板: 久久午夜伦鲁片免费无码| 特级毛片aaaa级毛片免费| 午夜老司机永久免费看片| 久久亚洲国产中v天仙www| jizz在线免费播放| 国产AⅤ无码专区亚洲AV| 久久精品无码免费不卡| 亚洲人成网77777色在线播放| 中国在线观看免费的www| 日本亚洲视频在线| 一级毛片在线免费看| 亚洲国产精品成人综合久久久| 国产免费丝袜调教视频| 亚洲一卡二卡三卡| 午夜dj在线观看免费视频| 亚洲αⅴ无码乱码在线观看性色| 国产成人一区二区三区免费视频| 国产天堂亚洲国产碰碰| 在线观看亚洲av每日更新 | 免费人成网站永久| 亚洲中文久久精品无码| 国产白丝无码免费视频| 精品亚洲国产成人| 一本久久综合亚洲鲁鲁五月天| 久久av免费天堂小草播放| 亚洲成人在线电影| 天天摸夜夜摸成人免费视频 | 久青草视频97国内免费影视| 亚洲第一福利网站| 成年私人影院免费视频网站| 香港经典a毛片免费观看看| 亚洲va中文字幕无码久久| 男人的好免费观看在线视频| 免费国产va在线观看| 久久精品国产亚洲77777| 日韩黄色免费观看| 免费日本一区二区| 日韩国产精品亚洲а∨天堂免| 亚洲精品制服丝袜四区| 在线精品免费视频| 久久久久国色av免费看|