Exemplo n.º 1
0
        /// <summary>
        /// 로그인
        /// </summary>
        public bool Login(string id, string pwd)
        {
            var sqlData = new AdminQuery().SelectWithId(id, pwd);

            if (sqlData.HasRows)
            {
                sqlData.Read();
                AdminDTO dto = new AdminDTO
                {
                    ADMIN_NUM      = Int32.Parse(sqlData["num"].ToString()),
                    ADMIN_ID       = sqlData["id"].ToString(),
                    ADMIN_PASSWORD = sqlData["password"].ToString(),
                    ADMIN_IDNUMBER = sqlData["idnumber"].ToString(),
                    ADMIN_NAME     = sqlData["name"].ToString(),
                    ADMIN_RANK     = sqlData["rank"].ToString(),
                    ADMIN_AUTH     = sqlData["auth"].ToString(),
                    ADMIN_GRADE    = sqlData["grade"].ToString()
                };
                SharedPreference.Instance.LoginAdmin       = new AdminModel(dto);
                SharedPreference.Instance.IsLoginCompleted = true;
                SharedPreference.Instance.IsManagement     = true;
                sqlData.Close();
                SharedPreference.Instance.DBM.SqlConn.Close();

                try
                {
                    AllLogDTO logDto = new AllLogDTO
                    {
                        ALLLOG_ADMIN       = id,
                        ALLLOG_WHAT        = "관리자 로그인",
                        ALLLOG_LOG         = "관리자 로그인",
                        ALLLOG_REASON      = "관리자 로그인",
                        ALLLOG_UPDATE_DATE = DateTime.Now.ToString()
                    };
                    new AllLogQuery().Insert(logDto);
                }
                catch (Exception e)
                {
                    SharedPreference.Instance.DBM.SqlConn.Close();
                    MessageBox.Show("관리자 로그인 실패\n에러 내용 : " + e.Message);
                }

                return(true);
            }
            else
            {
                SharedPreference.Instance.IsLoginCompleted = false;
                sqlData.Close();
                SharedPreference.Instance.DBM.SqlConn.Close();
                return(false);
            }
        } // end method
Exemplo n.º 2
0
        private void LoadAdmin()
        {
            AdminList.Clear();
            SqlDataReader sqlData = null;

            if (SharedPreference.Instance.LoginAdmin.ADMIN_GRADE == "000")
            {
                sqlData = new AdminQuery().SelectAll();
            }
            else
            {
                sqlData = new AdminQuery().SelectAllWithoutRoot();
            }
            if (sqlData.HasRows)
            {
                while (sqlData.Read())
                {
                    AdminDTO dto = new AdminDTO
                    {
                        ADMIN_NUM      = Int32.Parse(sqlData["num"].ToString()),
                        ADMIN_ID       = sqlData["id"].ToString(),
                        ADMIN_PASSWORD = sqlData["password"].ToString(),
                        ADMIN_IDNUMBER = sqlData["idnumber"].ToString(),
                        ADMIN_NAME     = sqlData["name"].ToString(),
                        ADMIN_RANK     = sqlData["rank"].ToString(),
                        ADMIN_AUTH     = sqlData["auth"].ToString(),
                        ADMIN_GRADE    = sqlData["grade"].ToString()
                    };
                    AdminList.Add(new AdminModel(dto));
                }
                sqlData.Close();
                SharedPreference.Instance.DBM.SqlConn.Close();
            }
            else
            {
                sqlData.Close();
                SharedPreference.Instance.DBM.SqlConn.Close();
            }
        }