internal ChangePasswordDialog(SQLiteConnectionProperties props) { _props = props; InitializeComponent(); password.Text = GetCurrentPassword(); }
private void ChangePassword(int itemId) { DataConnection dataConn = DataViewHierarchyAccessor.Connection; DbConnection cnn = DataViewHierarchyAccessor.Connection.ConnectionSupport.ProviderObject as DbConnection; if (cnn == null) { return; } SQLiteConnectionProperties props = new SQLiteConnectionProperties(cnn.ConnectionString); using (ChangePasswordDialog dlg = new ChangePasswordDialog(props)) { if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (String.IsNullOrEmpty(dlg.Password)) { props.Remove("Password"); } else { props["Password"] = dlg.Password; } System.Reflection.MethodInfo method = cnn.GetType().GetMethod("ChangePassword", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.InvokeMethod, null, new Type[] { typeof(string) }, null); if (method != null) { method.Invoke(cnn, new object[] { dlg.Password }); dataConn.Close(); dataConn.DisplayConnectionString = props.ToDisplayString(); dataConn.Open(); Refresh(itemId); } } } }
private void ChangePassword(int itemId) { DataConnection dataConn = DataViewHierarchyAccessor.Connection; DbConnection cnn = DataViewHierarchyAccessor.Connection.ConnectionSupport.ProviderObject as DbConnection; if (cnn == null) return; SQLiteConnectionProperties props = new SQLiteConnectionProperties(cnn.ConnectionString); using (ChangePasswordDialog dlg = new ChangePasswordDialog(props)) { if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (String.IsNullOrEmpty(dlg.Password)) props.Remove("Password"); else props["Password"] = dlg.Password; System.Reflection.MethodInfo method = cnn.GetType().GetMethod("ChangePassword", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.InvokeMethod, null, new Type[] { typeof(string) }, null); if (method != null) { method.Invoke(cnn, new object[] { dlg.Password }); dataConn.Close(); dataConn.DisplayConnectionString = props.ToDisplayString(); dataConn.Open(); Refresh(itemId); } } } }