public static CustomList<Users> GetUserList() { ConnectionManager conManager = new ConnectionManager(ConnectionName.SysMan); CustomList<Users> EmpCollection = new CustomList<Users>(); IDataReader reader = null; String sql = String.Format("select UserCode,Name from [User]"); try { conManager.OpenDataReader(sql, out reader); while (reader.Read()) { Users user = new Users(); user.SetDataUser(reader); EmpCollection.Add(user); } return EmpCollection; } catch (Exception ex) { throw (ex); } finally { if (reader != null && !reader.IsClosed) reader.Close(); } }
public static Users GetDefaultApplicationByUserCode(string userCode) { ConnectionManager conManager = new ConnectionManager(ConnectionName.SysMan); IDataReader reader = null; conManager.OpenDataReader(out reader, "spWebGetDefaultApplicationByUserCode", userCode); try { Users user = new Users(); while (reader.Read()) { user.SetData(reader); break; } return user; } catch (Exception ex) { throw (ex); } finally { if (conManager != null) { conManager.CloseConnection(); conManager.Dispose(); } if (reader != null && !reader.IsClosed) reader.Close(); } }
public static Users GetUserInfoByEmployeeCode(String employeeCode) { ConnectionManager conManager = new ConnectionManager(ConnectionName.SysMan); IDataReader reader = null; String sql = String.Format("Select * From [User] Where EmployeeCode = '{0}'", employeeCode); try { conManager.OpenDataReader(sql, out reader); Users user = new Users(); while (reader.Read()) { user.SetData(reader); break; } return user; } catch (Exception ex) { throw (ex); } finally { if (reader != null && !reader.IsClosed) reader.Close(); } }
public static CustomList<Users> doSearch(string whereClause) { ConnectionManager conManager = new ConnectionManager(ConnectionName.SysMan); CustomList<Users> UsersCollection = new CustomList<Users>(); IDataReader reader = null; String sql = string.Format("Select * From [User] Where 1=1 {0}", whereClause); try { conManager.OpenDataReader(sql, out reader); while (reader.Read()) { Users newUsers = new Users(); newUsers.SetData(reader); UsersCollection.Add(newUsers); } return UsersCollection; } catch (Exception ex) { throw (ex); } finally { if (reader != null && !reader.IsClosed) reader.Close(); } }
public static Users DoLogin(string userName, string password) { ConnectionManager conManager = new ConnectionManager(ConnectionName.SysMan); IDataReader reader = null; conManager.OpenDataReader(out reader, "spWebLogin ", userName,password); try { Users user = new Users(); while (reader.Read()) { user.SetDataDoLogin(reader); } return user; } catch (Exception ex) { throw (ex); } finally { if (conManager != null) { conManager.CloseConnection(); conManager.Dispose(); } if (reader != null && !reader.IsClosed) reader.Close(); } }
private void SetDataInControls(Users u) { try { txtUserCode.Text = u.UserCode.ToString(); txtName.Text = u.Name.ToString(); ddlEmpCode.SelectedValue = u.EmpCode; txtUserName.Text = Enc.Decrypt(u.UserName, STATIC.StaticInfo.encString); txtPassword.Attributes.Add("value", Enc.Decrypt(u.Password, STATIC.StaticInfo.encString)); txtConfirmPassword.Attributes.Add("value", Enc.Decrypt(u.Password, STATIC.StaticInfo.encString)); if (u.IsActive == 1) chkActiveUser.Checked = true; else chkActiveUser.Checked = false; if (u.IsAdmin == 1) chkAdminUser.Checked = true; else chkAdminUser.Checked = false; } catch (Exception ex) { throw (ex); } }
private void PopulateUserInformation(Users u) { try { SetDataInControls(u); UserGroupList = manager.GetAllUserGroupWithUserCode(u.UserCode); } catch (Exception ex) { throw (ex); } }
protected void btnSave_Click(object sender, EventArgs e) { try { CustomList<Users> lstUser = UserList; if (lstUser.Count == 0) { Users newUser = new Users(); lstUser.Add(newUser); } SetDataControlsToObject(ref lstUser); if (CheckUserAuthentication(lstUser).IsFalse()) return; if (lstUser.IsNotNull()) { if (txtPassword.Text == txtConfirmPassword.Text) { if (!CheckUserAuthentication(lstUser)) return; manager.SaveUser(ref lstUser); txtUserCode.Text = manager.UserCode; this.SuccessMessage = (StaticInfo.SavedSuccessfullyMsg); } else ErrorMessage = "Password and ConfirmPassword does not match!"; } } catch (SqlException ex) { this.ErrorMessage = (ExceptionHelper.getSqlExceptionMessage(ex)); } catch (Exception ex) { this.ErrorMessage = (ExceptionHelper.getExceptionMessage(ex)); } }