示例#1
0
        private static bool Load()
        {
            string path = Environment.CurrentDirectory + @"\Database.xml";

            lock (syncObj)
            {
                Stream fStream = null;
                try
                {
                    fStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Read);
                    if (fStream.Length == 0)
                    {
                        fStream.Close();
                    }
                    XmlSerializer format = new XmlSerializer(typeof(DbConnectString));//创建二进制序列化器
                    connString = (DbConnectString)format.Deserialize(fStream);
                    fStream.Close();
                }
                catch (System.Exception ex)
                {
                    connString = new DbConnectString();
                    MessageBox.Show(ex.Message);
                    return(false);
                }
                finally
                {
                    if (fStream != null)
                    {
                        fStream.Close();
                    }
                }
            }

            return(true);
        }
示例#2
0
 public static string GetString()
 {
     if (connString == null)
     {
         connString = DbConnectString.GetString();
     }
     return(connString);
 }
示例#3
0
        private void SetConnForm_Load(object sender, EventArgs e)
        {
            DbConnectString dcs = DbConnectString.Get();

            textBoxIp.Text       = dcs.server;
            textBoxPort.Text     = dcs.port.ToString();
            textBoxUser.Text     = dcs.user;
            textBoxPassword.Text = dcs.password;
        }
示例#4
0
 public static void Reset(string ip, int port, string user, string password, string schema)
 {
     connString = new DbConnectString()
     {
         server   = ip,
         port     = port,
         user     = user,
         password = password,
         schema   = schema,
     };
     Save();
 }
示例#5
0
 private void buttonOK_Click(object sender, EventArgs e)
 {
     DbConnectString.Reset(textBoxIp.Text, Convert.ToInt32(textBoxPort.Text), textBoxUser.Text, textBoxPassword.Text, "shuiwen");
     this.Close();
     Application.Exit();
 }