private bool InitDataset(string userName, string password) { bool result = false; System.Data.SqlClient.SqlConnectionStringBuilder builder = new System.Data.SqlClient.SqlConnectionStringBuilder(Properties.Settings.Default.DetroitConnectionString); builder.UserID = userName; builder.Password = password; builder.IntegratedSecurity = false; Security.Properties.Settings.ChangeConnectionString(builder.ConnectionString); this.logProvider.LogAlert(AlertType.Info, DateTime.Now.ToString() + " --- " + "Security", "builder.ConnectionString = " + builder.ConnectionString); this.logProvider.LogAlert(AlertType.Info, DateTime.Now.ToString() + " --- " + "Security", "DetroitConnectionString = " + Properties.Settings.Default.DetroitConnectionString.ToString()); // test connection ?! // try { string cnStr = builder.ConnectionString; SqlConnection cn = new SqlConnection(); cn.ConnectionString = cnStr; cn.Open(); this.detroit = new Detroit(); this.usersTableAdapter = new UsersTableAdapter(); this.permissionsTableAdapter = new PermissionsTableAdapter(); this.userPermissionsTableAdapter = new UserPermissionsTableAdapter(); result = true; return(result); } catch (SqlException ex) { this.logProvider.LogAlert(AlertType.Info, DateTime.Now.ToString() + " --- " + "Security", "There is no access to SQL database."); //MessageBox.Show("There is no access to SQL database. User \"" + userName + "\". \n Please, try again.", "SQL connecting ...", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } // }
public int SetUserPermission(UserPermission up) { int retVal = 0; UserPermissionsTableAdapter adapter = new UserPermissionsTableAdapter(); Object obj = adapter.SetUserPermission(up.userId, up.permissionId, up.status); if (obj != null) { retVal = Convert.ToInt32(obj); } return retVal; }
public bool GetUserPermission(int userId, int permissionId) { bool retVal = false; UserPermissionsTableAdapter adapter = new UserPermissionsTableAdapter(); Object obj = adapter.GetUserPermission(userId, permissionId); if (obj != null) { retVal = Convert.ToBoolean(obj); } return retVal; }