Esempio n. 1
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     strConnstring = XMLHelper.strGetConnectString().Split(';')[1].ToString().Split('=')[1].ToString();
     strlock       = strConnstring.Substring(0, strConnstring.LastIndexOf("\\") + 1) + "TransferLock";
     if (!File.Exists(strlock))
     {
         try
         {
             string       strTSQL = "select * from SetupConfig";
             AccessHelper ahTSQL  = new AccessHelper();
             DataTable    dtTSQL  = ahTSQL.SelectToDataTable(strTSQL);
             ahTSQL.Close();
             if (txtName.Text.ToLower() == "administrator" || GetComputerName().Substring(0, 3) == "OC1")
             {
                 UpdateDataBase();
             }
             if (strVersion == Application.ProductVersion)
             {
                 LoginProcess();
             }
             else if (strVersion == "" || CompareVersion(Application.ProductVersion, strVersion))
             {
                 if (GetComputerName().Substring(0, 3) == "OC1")
                 {
                     string       strSQL = "update SetupConfig set Version='" + Application.ProductVersion + "' ";
                     AccessHelper ah     = new AccessHelper();
                     ah.ExecuteSQLNonquery(strSQL);
                     ah.Close();
                 }
                 LoginProcess();
             }
             else
             {
                 MessageBox.Show("系统版本过低,请先升级后再重新登录使用!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
         catch (Exception ex)
         {
             if (txtName.Text.ToLower() == "administrator" || GetComputerName().Substring(0, 3) == "OC1")
             {
                 MessageBox.Show("数据库损坏,点击确定后,系统将尝试自动修复,期间请勿操作!::" + ex.Message, "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 string strResult = RepairAccess(strConnstring);
                 if (strResult.Substring(0, 5) != "Error")
                 {
                     MessageBox.Show("数据库修复完成,请关闭系统,并重新登录!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     this.Close();
                 }
                 else
                 {
                     MessageBox.Show("数据库修复失败::" + strResult, "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 }
             }
             else
             {
                 MessageBox.Show("数据库损坏,稍后将由上海办公室修复,请稍后重新登录!::" + ex.Message, "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
     }
     else
     {
         string strRepairUser = File.ReadAllText(strlock);
         MessageBox.Show("登陆失败::数据库正在计算机: " + strRepairUser + " 启用自动修复中,请稍后重新登录!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Esempio n. 2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            strConnstring = XMLHelper.strGetConnectString().Split(';')[1].ToString().Split('=')[1].ToString();
            strlock       = strConnstring.Substring(0, strConnstring.LastIndexOf("\\") + 1) + "PurchaseLock";
            string url = strConnstring.Substring(0, strConnstring.LastIndexOf("\\") + 1) + "DBCache\\";

            if (!Directory.Exists(url))         //如果不存在就创建file文件夹                 
            {
                Directory.CreateDirectory(url); //创建该文件夹 
            }
            strTempDB = url + GetASCII(txtName.Text) + ".accdb";
            CacheHelper.ConnString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + strTempDB;
            if (!File.Exists(strTempDB))
            {
                string strNullDB = ".\\null.accdb";
                if (File.Exists(strNullDB))
                {
                    try
                    {
                        File.Copy(strNullDB, strTempDB, true);
                    }
                    catch
                    {
                        MessageBox.Show("临时文件夹创建失败!数据库目录权限不足!系统运行异常!", "警告!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    MessageBox.Show("系统文件null.accdb丢失!请重新安装!", "警告!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            if (!File.Exists(".\\内购SQLQueue.accdb"))
            {
                MessageBox.Show("系统文件内购SQLQueue.accdb丢失!请重新安装!", "警告!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                try
                {
                    //SqlQueue sq = new SqlQueue();
                    //sq.InsertQuery("select * from ")
                }
                catch
                {
                }
            }
            if (!File.Exists(strlock) && File.Exists(strTempDB))
            {
                try
                {
                    string       strTSQL = "select * from SetupConfig";
                    AccessHelper ahTSQL  = new AccessHelper();
                    DataTable    dtTSQL  = ahTSQL.SelectToDataTable(strTSQL);
                    ahTSQL.Close();
                    if (GetComputerName().Substring(0, 3) == "OC1" || txtName.Text.ToLower() == "administrator")
                    {
                        UpdateDataBase();
                    }
                    if (strVersion == Application.ProductVersion)
                    {
                        LoginProcess();
                    }
                    else if (strVersion == "" || CompareVersion(Application.ProductVersion, strVersion))
                    {
                        if (GetComputerName().Substring(0, 3) == "OC1" || txtName.Text.ToLower() == "administrator")
                        {
                            string       strSQL = "update SetupConfig set Version='" + Application.ProductVersion + "' ";
                            AccessHelper ah     = new AccessHelper();
                            ah.ExecuteSQLNonquery(strSQL);
                            ah.Close();
                        }
                        LoginProcess();
                    }
                    else
                    {
                        MessageBox.Show("系统版本过低,请先升级后再重新登录使用!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                catch (Exception ex)
                {
                    if (txtName.Text.ToLower() == "administrator" || GetComputerName().Substring(0, 3) == "OC1")
                    {
                        MessageBox.Show("数据库损坏,点击确定后,系统将尝试自动修复,期间请勿操作!::" + ex.Message, "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        string strResult = RepairAccess(strConnstring);
                        if (strResult.Substring(0, 5) != "Error")
                        {
                            MessageBox.Show("数据库修复完成,请关闭系统,并重新登录!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show("数据库修复失败::" + strResult, "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                    else
                    {
                        MessageBox.Show("数据库损坏,稍后将由上海办公室修复,请稍后重新登录!::" + ex.Message, "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
            else
            {
                if (File.Exists(strTempDB))
                {
                    string strRepairUser = File.ReadAllText(strlock);
                    MessageBox.Show("登陆失败::数据库正在计算机: " + strRepairUser + " 启用自动修复中,请稍后重新登录!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    MessageBox.Show("登陆失败::远端缓存库联络失败,请联系管理员!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }