protected override void OnActivate()
 {
     try
     {
         using (ConnectionSetting form = new ConnectionSetting())
         {
             if (DialogResult.OK == form.ShowDialog())
             {
             }
         }
     }
     catch (SystemException e)
     {
         MessageBox.Show(e.Message);
     }
     finally
     {
         Terminate();
     }
 }
Exemple #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            #region Login
            if (txtLoginName.Text == string.Empty)
            {
                MessageBox.Show("请填写用户账号!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (txtPassWord.Text == string.Empty)
            {
                MessageBox.Show("请填写密码!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //获取数据库类型
            string dataVersion = System.Configuration.ConfigurationManager.AppSettings["dataVersion"];
            string ConStr;

            //获取数据库连接字符串,配置信息
            if (dataVersion == "SQL")
            {
                ConStr = Archives.DataAccess.DBUtility.getConStr();//(原)从本地ini文件获取
                //ConStr = System.Configuration.ConfigurationManager.AppSettings["SqlConnect"];
                Archives.DataAccess.DataSql.ConnectType = DB.DBConnectType.SqlServer;
                UIPublicClass.PublicClass.IsSingleClent = false;
            }
            else
            {
                ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + DataFileName;
                Archives.DataAccess.DataSql.ConStr_Pdf  = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + PdfDataFileName;
                Archives.DataAccess.DataSql.ConnectType = DB.DBConnectType.OleDb;
                UIPublicClass.PublicClass.IsSingleClent = true;
            }


            Cursor.Current = Cursors.WaitCursor;
            if (Archives.DataAccess.DBUtility.ConnectionTest(ConStr))
            {
                //验证用户
                bool login = userlogin.checkUserLogin(txtLoginName.Text, txtPassWord.Text);

                if (login)
                {
                    XmlDocument document = new XmlDocument();
                    document.Load("XmlFile.xml");
                    XmlNode node = document.SelectSingleNode("/Root/LoginName");
                    if (node != null)
                    {
                        node.InnerText = this.txtLoginName.Text;
                    }
                    document.Save("XmlFile.xml");

                    UserID           = userlogin.getUserID(txtLoginName.Text);//获取用户ID
                    txtPassWord.Text = "";
                    //this.Text = "全宗选择";
                    SelectDept(UserID);
                }
                else
                {
                    MessageBox.Show("账号或密码不正确!");
                    //txtLoginName.Text = "";
                    txtPassWord.Text = "";
                    txtLoginName.Focus();
                }
            }
            else
            {
                if (dataVersion == "SQL")
                {
                    ConnectionSetting cs = new ConnectionSetting();
                    cs.ShowDialog();
                }
                else
                {
                    MessageBox.Show("数据库连接失败!");
                }
            }
            Cursor.Current = Cursors.Default;
            #endregion
        }