Beispiel #1
0
        private void btnYes_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(textServerIp.Text))
            {
                System.Windows.Forms.MessageBox.Show(this, "数据库IP地址不能为空");
                return;
            }
            if (rdbWindowsServer.Checked == false && rdbDeskttopClient.Checked == false)
            {
                System.Windows.Forms.MessageBox.Show(this, "请选择一种启动方式");
                return;
            }
            AppConfigurator.UpdateAppConfig("DatabaseServerIP", textServerIp.Text.Trim());
            AppConfigurator.UpdateAppConfig("DatabaseUser", textUser.Text.Trim());
            AppConfigurator.UpdateAppConfig("DatabasePwd", textPwd.Text.Trim());

            if (rdbWindowsServer.Checked)
            {
                //windows服务模式

                //进入服务设置UI 安装\卸载 启动\停止 服务设置 切换为桌面客户端等
                this.Hide();
                FrmServiceSetup dlg = new FrmServiceSetup();
                dlg.ShowDialog();
                Close(); //整个程序退出
            }
            else
            {
                SingletonInfo.GetInstance().SqlServerIP   = textServerIp.Text.Trim();
                SingletonInfo.GetInstance().SqlServerUser = textUser.Text.Trim();
                SingletonInfo.GetInstance().SqlServerPWD  = textPwd.Text.Trim();
                //桌面客户端模式
                this.Hide();
                FormMain dlg = new FormMain();
                dlg.ShowDialog();
                Close();
            }
        }
Beispiel #2
0
        private void StartForm_Load(object sender, EventArgs e)
        {
            textServerIp.Text = AppConfigurator.GetAppConfig("DatabaseServerIP");
            textUser.Text     = AppConfigurator.GetAppConfig("DatabaseUser");
            textPwd.Text      = AppConfigurator.GetAppConfig("DatabasePwd");

            SingletonInfo.GetInstance().SqlServerIP   = textServerIp.Text.Trim();
            SingletonInfo.GetInstance().SqlServerUser = textUser.Text.Trim();
            SingletonInfo.GetInstance().SqlServerPWD  = textPwd.Text.Trim();

            if (IsServerAlreadyExisted())
            {
                //进入服务设置UI 安装\卸载 启动\停止 服务设置 切换为桌面客户端等
                this.Hide();
                FrmServiceSetup dlg = new FrmServiceSetup();
                dlg.ShowDialog();
                Close(); //整个程序退出
            }
            else
            {
                //进入选择模式UI  选择程序启动模式  windows服务  或者 桌面客户端
            }
        }
Beispiel #3
0
        /// <summary>
        /// sqlite中 数据库连接信息设置
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UpdateSqlConnection()
        {
            try
            {
                string strPath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;

                AppConfigurator.UpdateConnectionStringsConfig("SqliteConn", "Data Source=" + strPath + "module-config.sqlite", "Dos.ORM.Sqlite", strPath + "MixManagementService.exe");

                string sql     = "SELECT * FROM SQLServerInfo";
                string connStr = @"Data Source=" + strPath + @"module-config.sqlite;Initial Catalog=sqlite;Integrated Security=True;Max Pool Size=10";
                using (SQLiteConnection conn = new SQLiteConnection(connStr))
                {
                    conn.Open();
                    using (SQLiteDataAdapter ap = new SQLiteDataAdapter(sql, conn))
                    {
                        DataSet ds = new DataSet();
                        ap.Fill(ds);

                        DataTable dt   = ds.Tables[0];
                        string    sql_ = "";
                        if (dt.Rows.Count > 0)
                        {
                            //更新
                            sql_ = string.Format("update SQLServerInfo set IP='{0}',USER='******',PWD='{2}' WHERE id=1", SingletonInfo.GetInstance().SqlServerIP, SingletonInfo.GetInstance().SqlServerUser, SingletonInfo.GetInstance().SqlServerPWD);
                        }
                        else
                        {
                            //插入
                            sql_ = string.Format("INSERT INTO SQLServerInfo (id,IP,USER,PWD) values ({0},{1},{2},{3})", "1", SingletonInfo.GetInstance().SqlServerIP, SingletonInfo.GetInstance().SqlServerUser, SingletonInfo.GetInstance().SqlServerPWD);
                        }
                        using (SQLiteCommand command = new SQLiteCommand(sql_, conn))
                        {
                            command.ExecuteNonQuery();
                        }
                    }
                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }