//数据库连接
        public bool sqlOpen(object sServer1)
        {
            String sServer     = Convert.ToString(sServer1);
            String strServer   = new clsIni().IniReadValue("Server", sServer);
            String strDatabase = new clsIni().IniReadValue("Database", sServer);
            String strUserID   = new clsIni().IniReadValue("UserName", sServer);
            String strPassword = new clsIni().IniReadValue("Password", sServer);
            String strCon      = "server=" + strServer + ";database=" + strDatabase + ";uid=" + strUserID + ";pwd=" + new clsSqlPassword().OutPassword(strPassword);

            sqlCon = new SqlConnection(strCon);
            try
            {
                sqlCon.Open();//打开连接
                return(true);
            }
            catch (Exception ex)
            {
                DialogResult r = MessageBox.Show("数据库连接失败!是否重新配置服务器!\n" + ex.Message, "提示!", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                if (r == DialogResult.OK)
                {
                    SqlFile.frmConfig frmConfig1 = new frmConfig();
                    frmConfig1.sServer = sServer;
                    frmConfig1.ShowDialog();
                }
                return(false);
            }
        }
Exemple #2
0
        private SqlDataAdapter sqlDa; //声明SqlDataAdapter对象
        //Thread threadLoading;

        //数据库连接测试
        public String sqlOpen1(String sServer1)
        {
            String sServer     = Convert.ToString(sServer1);
            String strServer   = new clsIni().IniReadValue("Server", sServer);
            String strDatabase = new clsIni().IniReadValue("Database", sServer);
            String strUserID   = new clsIni().IniReadValue("UserName", sServer);
            String strPassword = new clsIni().IniReadValue("Password", sServer);
            String strCon      = "server=" + strServer + ";database=" + strDatabase + ";uid=" + strUserID + ";pwd=" + new clsSqlPassword().OutPassword(strPassword);

            sqlCon = new SqlConnection(strCon);
            try
            {
                sqlCon.Open();  //打开连接
                sqlCon.Close(); //关闭连接
                return("");
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
        //数据库连接
        public bool sqlOpen(object sServer1)
        {
            String sServer     = Convert.ToString(sServer1);
            String strServer   = new clsIni().IniReadValue("Server", sServer);
            String strDatabase = new clsIni().IniReadValue("Database", sServer);
            String strUserID   = new clsIni().IniReadValue("UserName", sServer);
            String strPassword = new clsIni().IniReadValue("Password", sServer);
            String strCon      = "server=" + strServer + ";database=" + strDatabase + ";uid=" + strUserID + ";pwd=" + strPassword;

            sqlCon = new SqlConnection(strCon);
            try
            {
                sqlCon.Open();//打开连接
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("数据库连接失败!请与管理员联系!\n" + ex.Message, "提示!");
                return(false);
            }
        }
Exemple #4
0
        private void LoadBackgroundPicture()
        {
            try
            {
                ci = new clsIni(IniPath);
                string ImageBGPath = ci.IniReadValue("SplashBackground", "System");

                if (string.IsNullOrEmpty(ImageBGPath))
                {
                    ImageBGPath = Environment.CurrentDirectory + "\\Resources\\Background.jpg";
                }

                if (File.Exists(ImageBGPath))
                {
                    pictureBox1.Image = Image.FromFile(ImageBGPath);
                    pictureBox1.BackgroundImageLayout = ImageLayout.Stretch;
                }
            }catch
            {
            }
        }
Exemple #5
0
        private void Form1_Load(object sender, EventArgs e)
        {
            string IniPath = Environment.CurrentDirectory + "\\Settings.ini";

            if (!File.Exists(IniPath))
            {
                MessageBox.Show("Error: File Setting is missing. Please check\nPath:" + IniPath, "File not Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
                return;
            }

            ci = new clsIni(IniPath);
            GetCompanyInfo();
            string LoginPic = ci.Read("LoginPicLocation", "SystemSettings");

            if (!string.IsNullOrEmpty(LoginPic) && Path.GetExtension(LoginPic) == ".jpg")
            {
                pbImageLoading.Image = Image.FromFile(LoginPic);
            }
            PicLogin = GetPicFromCondoPics();
            Preparing();
        }
Exemple #6
0
        private void CheckHDLicense()
        {
            tmrLoading.Stop();
            string strPath = Environment.CurrentDirectory + "\\settings.ini";

            if (!File.Exists(strPath))
            {
                MessageBox.Show("Error: Cannot continue. Settings not found. Please check", "Ini File is missing", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            clsIni ci             = new clsIni(strPath);
            string HDLicense      = GetHardDiskSerialNo();
            string EncryptLicense = cv.Crypt(HDLicense);
            string LicenseIni     = ci.Read("LicenseCode", "Licensing");

            if (EncryptLicense != LicenseIni)
            {
                MessageBox.Show("Error: Cannot continue. License not found. Please check not match", "License Invalid", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            tmrLoading.Start();
        }
Exemple #7
0
        //数据库连接
        public bool sqlOpen(object sServer1)
        {
            //threadLoading = new Thread(new ThreadStart(s));
            //threadLoading.IsBackground = true;
            ////threadLoading.Priority = ThreadPriority.AboveNormal;
            //threadLoading.Start();
            String sServer     = Convert.ToString(sServer1);
            String strServer   = new clsIni().IniReadValue("Server", sServer);
            String strDatabase = new clsIni().IniReadValue("Database", sServer);
            String strUserID   = new clsIni().IniReadValue("UserName", sServer);
            String strPassword = new clsIni().IniReadValue("Password", sServer);
            String strCon      = "server=" + strServer + ";database=" + strDatabase + ";uid=" + strUserID + ";pwd=" + new clsSqlPassword().OutPassword(strPassword);

            sqlCon = new SqlConnection(strCon);
            try
            {
                sqlCon.Open();//打开连接
                return(true);
            }
            catch (Exception ex)
            {
                //if (frmLoading1.InvokeRequired)//判断是否有其他线程想访问
                //{
                //    Action act = () => { frmLoading1.Close(); };//封装一个窗体关闭的方法
                //    frmLoading1.Invoke(act);//在拥有该控件的线程上执行该方法
                //}
                //if (threadLoading != null)
                //    threadLoading.Abort();
                DialogResult r = MessageBox.Show("数据库连接失败!是否重新配置服务器!\n" + ex.Message, "提示!", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                if (r == DialogResult.OK)
                {
                    SqlFile.frmConfig frmConfig1 = new frmConfig();
                    frmConfig1.sServer = sServer;
                    frmConfig1.ShowDialog();
                }
                return(false);
            }
        }
Exemple #8
0
        private bool checkDatabase()
        {
            bool result = false;

            try
            {
                string SettingFilePath = Environment.CurrentDirectory + "\\Settings.ini";
                if (File.Exists(SettingFilePath))
                {
                    ci        = new clsIni(SettingFilePath);
                    strDBType = ci.Read("DatabaseType", "SystemSettings");
                    if (!string.IsNullOrEmpty(strDBType))
                    {
                        DBFile = ci.Read("DBFilePath", "SQLLite");
                    }

                    result = string.IsNullOrEmpty(DBFile) ? false : File.Exists(DBFile) ? true : false;
                }
            }
            catch
            {
            }
            return(result);
        }
Exemple #9
0
        static void Main()
        {
            string IniPath = Environment.CurrentDirectory + "\\Settings.ini";

            if (!System.IO.File.Exists(IniPath))
            {
                MessageBox.Show("Error: Setting file is missing or corrupt. Please check this path \n" + IniPath, "Missing Ini File", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            clsIni ci = new clsIni(IniPath);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (ci.Read("LoginFirst", "SystemSettings").ToLower() == "true")
            {
                Application.Run(new Form1());
            }
            else
            {
                Application.Run(new FrmMain());
            }
        }
        private void ViewSOA_Load(object sender, EventArgs e)
        {
            clsIni ci = new clsIni(Environment.CurrentDirectory + "\\" + "settings.ini");

            CompanyName = ci.Read("CompanyName", "SystemSettings");
        }