private void FDatabase_Load(object sender, EventArgs e) { INIClass iniClass = new INIClass("config.ini"); if (iniClass.ExistINIFile()) { txbDBIP.Text = EncAndDec.Decode(iniClass.IniReadValue("Database", "server")); txbDBName.Text = EncAndDec.Decode(iniClass.IniReadValue("Database", "database")); txbUserName.Text = EncAndDec.Decode(iniClass.IniReadValue("Database", "user")); txbPassword.Text = EncAndDec.Decode(iniClass.IniReadValue("Database", "password")); } txbDBIP_TextChanged(null, null); }
private void btnSave_Click(object sender, EventArgs e) { string server = txbDBIP.Text.Trim(); string db = txbDBName.Text.Trim(); string user = txbUserName.Text.Trim(); string pwd = txbPassword.Text.Trim(); if (server.Length > 0 && db.Length > 0 && user.Length > 0 && pwd.Length > 0) { INIClass iniClass = new INIClass("config.ini"); iniClass.IniWriteValue("Database", "server", EncAndDec.Encode(server)); iniClass.IniWriteValue("Database", "database", EncAndDec.Encode(db)); iniClass.IniWriteValue("Database", "user", EncAndDec.Encode(user)); iniClass.IniWriteValue("Database", "password", EncAndDec.Encode(pwd)); this.Close(); } }
public static void WritePrintername(string printerName) { INIClass iniclass = new INIClass("config.ini"); iniclass.IniWriteValue("Other", "printer", printerName); }
public static string ReadPrinterName() { INIClass iniclass = new INIClass("config.ini"); return iniclass.IniReadValue("Other", "printer"); }
public static string getIniConnInfo(string iniPath) { INIClass iniClass = new INIClass(iniPath); string coninfo = ""; if (iniClass.ExistINIFile()) { string Server = EncAndDec.Decode(iniClass.IniReadValue("Database", "server")); string dataBase = EncAndDec.Decode(iniClass.IniReadValue("Database", "database")); coninfo = string.Format("{0} {1}", Server, dataBase, Server, dataBase); } return coninfo; }
public static string getIniConn(string iniPath,int timeOut) { INIClass iniClass = new INIClass( iniPath); string connString = ""; if (iniClass.ExistINIFile()) { string Server = EncAndDec.Decode(iniClass.IniReadValue("Database", "server")); string dataBase = EncAndDec.Decode(iniClass.IniReadValue("Database", "database")); string user = EncAndDec.Decode(iniClass.IniReadValue("Database", "user")); string pwd = EncAndDec.Decode(iniClass.IniReadValue("Database", "password")); connString = string.Format("data source={0};initial catalog={1};persist security info=True;user id={2};password={3};MultipleActiveResultSets=True;App=EntityFramework;Connection Timeout={4};", Server, dataBase, user, pwd,timeOut); } return connString; }