protected override void LoadViewState(object savedState) { base.LoadViewState(savedState); vwBmAdminMember = (BmAdminMember)ViewState["vwBmAdminMember"]; vwBmAdminMemberList = (List<BmAdminMember>)ViewState["vwBmAdminMemberList"]; }
/// <summary>AdminMember 삭제</summary> public bool DeleteAdminMember(BmAdminMember pDataRq) { try { using (SqlConn = new SqlConnection(ConnectionString)) { using (TransactionScope scope = new TransactionScope()) { try { SqlConn.Open(); var result = dac.DeleteAdminMember(pDataRq); scope.Complete(); return result; } catch (Exception ex) { throw ex; } finally { SqlConn.Dispose(); } } } } catch (Exception ex) { WriteLog("Exception", ex.Message); throw; } }
public static bool CheckOverLapId(string pId) { if (!string.IsNullOrEmpty(pId.Trim())) { BizMember bizMember = new BizMember(); BmAdminMember bmAdminMember = new BmAdminMember(); bmAdminMember.Id = pId; var result = bizMember.GetAdminMemberList(bmAdminMember); if (result.Count == 0) { return true; } } return false; }
/// <summary>AdminMember 삭제</summary> 로그 등록 필요 public bool DeleteAdminMember(BmAdminMember pDataRq) { try { #region SetQuery string strQuery = @"DELETE tbAdmin WHERE Seq = @Seq"; #endregion SetQuery int result = 0; SqlCommand cmd = new SqlCommand(); cmd.Connection = SqlConn; cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = strQuery.ToString(); #region Set Parameters cmd.Parameters.Add("@Seq", SqlDbType.Int, 0).Value = pDataRq.Seq; #endregion Set Parameters result = cmd.ExecuteNonQuery(); cmd.Dispose(); if (result == 1) { WriteHistory(pDataRq, HistoryCommandType.DELETE); return true; } else { return false; } } catch (Exception ex) { throw ex; } }
/// <summary>관리자 Convert DataTable -> BizAdminMember</summary> private List<BmAdminMember> ConvertToBmAdminMember(DataTable dt) { List<BmAdminMember> bmAdminMemberList = new List<BmAdminMember>(); foreach (DataRow dr in dt.Rows) { BmAdminMember data = new BmAdminMember(); data.Seq = (int)dr["Seq"]; data.Id = dr["Id"].ToString(); data.Pw = dr["pw"].ToString(); data.Name = dr["Name"].ToString(); data.AuthLevel = (int)dr["AuthLevel"]; data.RegDt = (DateTime)dr["RegDt"]; data.ModifyDt = string.IsNullOrEmpty(dr["ModifyDt"].ToString()) ? null : (DateTime?)dr["ModifyDt"]; data.Modifyer = dr["Modifyer"].ToString(); data.State = (int)dr["State"]; data.SessionId = dr["SessionId"].ToString(); bmAdminMemberList.Add(data); } return bmAdminMemberList; }
/// <summary>로그인 세션 업데이트(중복 로그인 방지용)</summary> public bool UpdateAdminMemberSession(BmAdminMember pDataRq) { try { #region SetQuery string strQuery = @"UPDATE tbAdmin SET SessionId = @SessionId WHERE Seq = @Seq"; #endregion SetQuery int result = 0; SqlCommand cmd = new SqlCommand(); cmd.Connection = SqlConn; cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = strQuery.ToString(); #region Set Parameters cmd.Parameters.Add("@Seq", SqlDbType.Int, 0).Value = pDataRq.Seq; cmd.Parameters.Add("@SessionId", SqlDbType.VarChar).Value = pDataRq.SessionId; #endregion Set Parameters result = cmd.ExecuteNonQuery(); cmd.Dispose(); if (result == 1) { //변경이력로그 남기지 않음. //WriteHistory(pDataRq, HistoryCommandType.UPDATE); return true; } else { return false; } } catch (Exception ex) { throw ex; } }
/// <summary>AdminMember 수정</summary> public bool UpdateAdminMember(BmAdminMember pDataRq) { try { #region SetQuery string strQuery = @"UPDATE tbAdmin SET Pw = @Pw, Name = @Name, AuthLevel = @AuthLevel, State = @State, Modifyer = @Modifyer, ModifyDt = dbo.getkordate() WHERE Seq = @Seq"; #endregion SetQuery int result = 0; SqlCommand cmd = new SqlCommand(); cmd.Connection = SqlConn; cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = strQuery.ToString(); #region Set Parameters cmd.Parameters.Add("@Seq", SqlDbType.Int, 0).Value = pDataRq.Seq; cmd.Parameters.Add("@Pw", SqlDbType.VarChar, 100).Value = pDataRq.Pw; cmd.Parameters.Add("@Name", SqlDbType.VarChar, 20).Value = pDataRq.Name; cmd.Parameters.Add("@AuthLevel", SqlDbType.Int, 0).Value = pDataRq.AuthLevel; cmd.Parameters.Add("@State", SqlDbType.Int, 0).Value = pDataRq.State; cmd.Parameters.Add("@Modifyer", SqlDbType.VarChar, 50).Value = pDataRq.Modifyer; #endregion Set Parameters result = cmd.ExecuteNonQuery(); cmd.Dispose(); if (result == 1) { WriteHistory(pDataRq, HistoryCommandType.UPDATE); return true; } else { return false; } } catch (Exception ex) { throw ex; } }
/// <summary>AdminMember 등록</summary> public bool InsertAdminMember(BmAdminMember pDataRq) { try { #region SetQuery string strQuery = @"Insert Into tbAdmin (Id , Pw , Name , AuthLevel , State , Registrant) Values (@Id , @Pw , @Name , @AuthLevel , @State , @Registrant) SELECT @@Identity"; #endregion SetQuery int result = 0; SqlCommand cmd = new SqlCommand(); cmd.Connection = SqlConn; cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = strQuery.ToString(); #region Set Parameters cmd.Parameters.Add("@Id", SqlDbType.VarChar, 20).Value = pDataRq.Id; cmd.Parameters.Add("@Pw", SqlDbType.VarChar, 100).Value = pDataRq.Pw; cmd.Parameters.Add("@Name", SqlDbType.VarChar, 20).Value = pDataRq.Name; cmd.Parameters.Add("@AuthLevel", SqlDbType.Int, 0).Value = pDataRq.AuthLevel; cmd.Parameters.Add("@State", SqlDbType.Int, 0).Value = pDataRq.State; cmd.Parameters.Add("@Registrant", SqlDbType.VarChar, 20).Value = pDataRq.Registrant; #endregion Set Parameters result = Convert.ToInt32(cmd.ExecuteScalar()); cmd.Dispose(); if (result > 0) { pDataRq.Seq = result; WriteHistory(pDataRq, HistoryCommandType.INSERT); return true; } else { return false; } } catch (Exception ex) { throw ex; } }
/// <summary>AdminMemberList 조회</summary> public List<BmAdminMember> GetAdminMemberList(BmAdminMember pDataRq) { try { #region SetQuery StringBuilder sbQuery = new StringBuilder("SELECT * FROM tbAdmin WHERE 1=1"); if (pDataRq.Seq > 0) sbQuery.AppendLine(" AND Seq = @Seq"); if (!string.IsNullOrEmpty(pDataRq.Id)) sbQuery.AppendLine(" AND Id = @Id"); if (pDataRq.State > 0) sbQuery.AppendLine(" AND State = @State"); sbQuery.AppendLine(" order by RegDt"); #endregion SetQuery List<BmAdminMember> result = new List<BmAdminMember>(); SqlCommand cmd = new SqlCommand(); cmd.Connection = SqlConn; cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = sbQuery.ToString(); #region Set Parameters if (pDataRq.Seq > 0) cmd.Parameters.Add("@Seq", SqlDbType.Int, 0).Value = pDataRq.Seq; if (string.IsNullOrEmpty(pDataRq.Id) == false) cmd.Parameters.Add("@Id", SqlDbType.VarChar, 20).Value = pDataRq.Id; if (pDataRq.State > 0) cmd.Parameters.Add("@State", SqlDbType.Int, 0).Value = pDataRq.State; #endregion Set Parameters SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { DataTable dt = new DataTable(); dt.Load(reader); result = ConvertToBmAdminMember(dt); } reader.Dispose(); cmd.Dispose(); return result; } catch (Exception ex) { throw ex; } }
public BmAdminMemberPagingRq() { Admin = new BmAdminMember(); Paging = new BmPaging(); }
/// <summary>관리자 등록</summary> private void InsertAdminMember() { string strMsg = ""; BizMember bizMember = new BizMember(); BmAdminMember bmAdminMemberRq = new BmAdminMember(); bmAdminMemberRq.Id = tbxId.Text; var checkId = bizMember.GetAdminMemberList(bmAdminMemberRq); if (checkId.Count == 0) { #region Set InsertModel Rq bmAdminMemberRq.Id = tbxId.Text; bmAdminMemberRq.Pw = tbxPw.Text; bmAdminMemberRq.Name = tbxNm.Text; bmAdminMemberRq.AuthLevel = Convert.ToInt32(ddlAuthLevel.SelectedValue); bmAdminMemberRq.State = Convert.ToInt32(ddlState.SelectedValue); bmAdminMemberRq.Registrant = LoginMgr.Id; #endregion Set InsertModel Rq bool result = bizMember.InsertAdminMember(bmAdminMemberRq); if (result) { strMsg = "관리자 등록이 완료 되었습니다."; ListSearch(); BindAdminMemberDetail(vwBmAdminMemberList.FirstOrDefault(o => o.Id.Equals(bmAdminMemberRq.Id)).Seq); } else { strMsg = "관리자 등록이 실패하였습니다."; } } else { strMsg = "이미 존재하는 ID입니다."; } SetAndShowCmmModal("관리자 등록", strMsg); }
/// <summary>리스트 관리자 삭제</summary> private void DeleteAdminMember(int pSeq) { string strMsg = ""; if (pSeq > 0) { BmAdminMember bmAdminMember = new BmAdminMember(); BizMember bizMember = new BizMember(); bmAdminMember = vwBmAdminMemberList.FirstOrDefault(o => o.Seq.Equals(pSeq)); if (bmAdminMember != null) { bmAdminMember.Modifyer = LoginMgr.Id; bool result = bizMember.DeleteAdminMember(bmAdminMember); if (result) { strMsg = "관리자 삭제가 완료되었습니다."; ucPaging.CurPage = 0; ListSearch(); ucPaging.ReSetPageControl(); } else { strMsg = "관리자 삭제에 실패하였습니다."; } } } else { strMsg = "잘못된 관리자 입니다."; } SetAndShowCmmModal("관리자 삭제", strMsg); }
/// <summary>관리자정보 바인드</summary> private void BindAdminMemberDetail(int pSeq) { vwBmAdminMember = vwBmAdminMemberList.FirstOrDefault(o => o.Seq.Equals(pSeq)); tbxId.Text = vwBmAdminMember.Id; tbxPw.Text = vwBmAdminMember.Pw; tbxNm.Text = vwBmAdminMember.Name; ddlAuthLevel.SelectedValue = vwBmAdminMember.AuthLevel.ToString(); ddlState.SelectedValue = vwBmAdminMember.State.ToString(); tbxRegDt.Text = vwBmAdminMember.RegDt.ToString(); tbxModifyer.Text = vwBmAdminMember.Modifyer; tbxModifyDt.Text = vwBmAdminMember.ModifyDt.ToString(); SetCtrlsModifyMode(); }
/// <summary>현재 접속중인 세션아이디 가져오기</summary> private static string GetConnectSession(int pSeq) { BizMember bizMember = new BizMember(); BmAdminMember bmAdminMember = new BmAdminMember(); bmAdminMember.Seq = pSeq; var result = bizMember.GetAdminMemberList(bmAdminMember)[0]; return result.SessionId; }
/// <summary>로그인</summary> /// <returns> /// 0 = 성공 /// , -1 = 비밀번호 오류 /// , -2 = 아이디 오류 /// , -3 = 세션 갱신 실패 /// , -4 = Exception /// , -5 = 접속로그 오류 /// </returns> public static int Login(string Id, string Pw) { try { HttpContext context = HttpContext.Current; BizMember bizMember = new BizMember(); BmAdminMember bmAdminMember = new BmAdminMember(); bmAdminMember.Id = Id; bmAdminMember.State = 1; var AccountList = bizMember.GetAdminMemberList(bmAdminMember); if (AccountList.Count == 1) { BmAdminMember Account = AccountList[0]; if (Pw == Account.Pw) { Account.SessionId = context.Session.SessionID; SessionId = context.Session.SessionID; if (bizMember.UpdateAdminMemberSession(Account)) { BizLog bizLog = new BizLog(); BmConnectLog bmConnectLog = new BmConnectLog(); //접속세션이 없을시 접속세션 등록 if (context.Session["ConnectSeq"] == null) { bmConnectLog.ReconnectYn = "Y"; bmConnectLog.SessionId = context.Session.SessionID; bmConnectLog.Ip = context.Request.ServerVariables["REMOTE_ADDR"] != null ? context.Request.ServerVariables["REMOTE_ADDR"] : ""; bmConnectLog.LinkUrl = context.Request.ServerVariables["HTTP_REFERER"] != null ? context.Request.ServerVariables["HTTP_REFERER"] : ""; context.Session["ConnectSeq"] = bizLog.InsertConnectLogScalar(bmConnectLog); } bmConnectLog.Seq = (int)context.Session["ConnectSeq"]; bmConnectLog.Id = bmAdminMember.Id; //접속로그 로그인Id, 시간 업데이트 if (bizLog.UpdateLoginLog(bmConnectLog)) { //로그인 성공 세션 등록 foreach (string colName in strLoginColumnArray) { Type t = Account.GetType(); context.Session.Add("Login" + colName, t.GetProperties().FirstOrDefault(o => o.Name.Equals(colName)).GetValue(Account).ToString()); } return 0; } //접속 로그 오류 else return -5; } else { //세션 갱신 실패 return -3; } } else { //비밀번호가 다를 경우 return -1; } } else { //아이디가 1개가 아닐경우 return -2; } } catch (Exception ex) { _cLib.WriteLog("Exception", ex.Message); return -4; } }