편집 기록

편집 기록
  • 프로필 알 수 없는 사용자님의 편집
    날짜2016.11.28

    c# 관련해서 질문이있습니다.


    [C#] DB값에 저장된 값을 읽어와서 프로그램창이 최소화 되었을때 자동으로 타이머가 돌아서 자동 최대화 팝업이 뜨는 소스입니다.

    [1번]
    private void chkAutoPopup_CheckedChanged(object sender, EventArgs e)
            {
    
                IniFile.SetAutoPopup(chkAutoPopup.Checked);
    
                if (chkAutoPopup.Checked)
                {
                    timerPopup.Interval = Int32.Parse(cmbPopupInterval.Text) * 60 * 1000;
                    timerPopup.Start();
    
                    cmbPopupInterval.Enabled = false;
                }
                else
                {
                    timerPopup.Stop();
                    cmbPopupInterval.Enabled = true;
                }
    
            }
    
    

    아래 소스와 같이 Check박스 유무 상관없이 자동팝업을 일정시간 기준으로 띄우는 것같은데요.. 위 소스에서 체크가 false면 아래 소스가 실행된다는 뜻인가요..? 소스이해가안가서 설명좀 부탁드립니다.

    [2번]
            private void timerPopup_Tick(object sender, EventArgs e)
            {
                timerPopup.Stop();
    
                // 윈도우 팝업 살리기
                if (this.WindowState == FormWindowState.Minimized)
                this.WindowState = FormWindowState.Normal;
    
                // 타이머 재시작
                timerPopup.Interval = Int32.Parse(cmbPopupInterval.Text) * 60 * 1000;
                timerPopup.Start();
            }
    
    

    아래 소스는 제가 메인폼에 적용시킨 소스인데요.. DB값에 mini_popup_yn 값이 Y인 유저들만 자동팝업이 뜨게 만들어놨습니다.

    이렇게 디폴트값으로 시간을 60 * 1000; 을 주었는데요. 소스내에서 디폴트값이 아닌 위와같이 Y/N 유무를 읽어온다음 해당유저가 Y이면 DB코드값을 읽어와서 자동팝업시간을 조절할수있게 하고싶습니다.

    [1번] 소스와 [3번소스] 의 기능을 합치고싶은데 잘안되네요.

    [3번]
    private void timerPopup_Tick(object sender, EventArgs e)
            {
    
    
                // DB접속 환경 설정
                NpgsqlConnection conn = new NpgsqlConnection(Variable.dbConnStr());
                try
                {
                    conn.Open();
    
                    String SQL = "";
                    SQL += " SELECT user_nm, user_id, mini_popup_yn ";
                    SQL += " FROM t_wrk0080 ";
                    SQL += " WHERE user_id = @getUserNm";
    
    
                    // 쿼리를 실행한다.
                    NpgsqlCommand pg_cmd = new NpgsqlCommand(SQL, conn);
                    pg_cmd.Parameters.AddWithValue("@getUserNm", Variable.m_userID);
                    NpgsqlDataReader rd = pg_cmd.ExecuteReader();
                    if (rd.Read())
    
    
                        //윈도우 팝업 살리기
                        if (rd["mini_popup_yn"].ToString() == "Y")
                        {
    
                            if (this.WindowState == FormWindowState.Minimized)
                                timerPopup.Stop();
                            {
                                this.WindowState = FormWindowState.Normal;
                                timerPopup.Interval = m_nPopup * 60 * 1000;
                                timerPopup.Start();
                            }
                        }
                        else
                        {
                            timerPopup.Stop();
                            rd.Close();
                        }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally // 무조건 실행
                {
                    if (conn != null)
                        conn.Close(); // 연결을 종료
    
                    Cursor.Current = Cursors.Default;
                }
    
            }
    
  • 프로필 허대영(소프트웨어융합대학)님의 편집
    날짜2016.11.28

    c# 관련해서 질문이있습니다.


    c# 로그인후 메인폼 로드시 최소화 하여 프로그램을 내려놨을때

    일정시간 코드값을 읽어와서 자동으로 창을 다시뜨게하게끔 구현해놨는데

    DB값에 특정 인원을 Y/N 구분을줘서 Y일때만 그기능이 작동하게 하고싶습니다.

    private void timerPopup_Tick(object sender, EventArgs e)
            {        
                timerPopup.Stop();
    
                // 윈도우 팝업 살리기
                if 
                    (this.WindowState == FormWindowState.Minimized)
                    this.WindowState = FormWindowState.Normal;
    
                // 타이머 재시작
                timerPopup.Interval = m_nPopup * 60 * 1000;
                timerPopup.Start();
            }
    

    해당소스인데요.. 현재는 유저상관없이 특정코드값을 읽어와서 모든사용자들이 팝업창이 자동으로 뜨게 되어있습니다.

    private void timerPopup_Tick(object sender, EventArgs e)
            {
                int spopup = 0;
    
                //DB 접속 환경 설정
                NpgsqlConnection conn = new NpgsqlConnection(Variable.dbConnStr());
    
                try
                {
                    //데이터베이스에 접속한다.
                    conn.Open();
    
                    String SQL = "";
                    SQL += "SELECT user_nm, mini_popup_yn";         // 사용자 이름 컬럼, 팝업창 유무 (Y/N)컬럼
                    SQL += "FROM t_wrk0080";
                    SQL += "WHERE use_yn ='Y'";                     // 사용 유무 컬럼
                    SQL += "AND mini_popup_yn = 'Y'";               // 팝업창 유무 Y 일때만
    
                    //쿼리를 실행한다.
    
                    NpgsqlCommand pg_cmd = new NpgsqlCommand(SQL, conn);
                    NpgsqlDataReader rd = pg_cmd.ExecuteReader();
    
                    while (rd.Read())
                    {
                        spopup = Int32.Parse(rd[0].ToString());
                    }
                    rd.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
    finally // 무조건 실행
                {
                    if (conn != null)
                        conn.Close(); // 연결을 종료
    
                    Cursor.Current = Cursors.Default;
                }
                timerPopup.Stop();
    
                // 윈도우 팝업 살리기
                if 
                    (this.WindowState == FormWindowState.Minimized)
                    this.WindowState = FormWindowState.Normal;
    
                // 타이머 재시작
                timerPopup.Interval = m_nPopup * 60 * 1000;
                timerPopup.Start();
            }
    

    이렇게 소스를 짜서 구동했는데 Y,N 구분없이 어떤 사용자로 로그인하던지 기능이 작동하더라구요.. 고수님들 한수 배우고싶습니다.

  • 프로필 알 수 없는 사용자님의 편집
    날짜2016.11.23

    c# 관련해서 질문이있습니다.


    c# 로그인후 메인폼 로드시 최소화 하여 프로그램을 내려놨을때

    일정시간 코드값을 읽어와서 자동으로 창을 다시뜨게하게끔 구현해놨는데

    DB값에 특정 인원을 Y/N 구분을줘서 Y일때만 그기능이 작동하게 하고싶습니다.

    private void timerPopup_Tick(object sender, EventArgs e) {
    timerPopup.Stop();

            // 윈도우 팝업 살리기
            if 
                (this.WindowState == FormWindowState.Minimized)
                this.WindowState = FormWindowState.Normal;
    
            // 타이머 재시작
            timerPopup.Interval = m_nPopup * 60 * 1000;
            timerPopup.Start();
        }
    

    해당소스인데요.. 현재는 유저상관없이 특정코드값을 읽어와서 모든사용자들이 팝업창이 자동으로 뜨게 되어있습니다.

    private void timerPopup_Tick(object sender, EventArgs e) { int spopup = 0;

            //DB 접속 환경 설정
            NpgsqlConnection conn = new NpgsqlConnection(Variable.dbConnStr());
    
            try
            {
                //데이터베이스에 접속한다.
                conn.Open();
    
                String SQL = "";
                SQL += "SELECT user_nm, mini_popup_yn";         // 사용자 이름 컬럼, 팝업창 유무 (Y/N)컬럼
                SQL += "FROM t_wrk0080";
                SQL += "WHERE use_yn ='Y'";                     // 사용 유무 컬럼
                SQL += "AND mini_popup_yn = 'Y'";               // 팝업창 유무 Y 일때만
    
                //쿼리를 실행한다.
    
                NpgsqlCommand pg_cmd = new NpgsqlCommand(SQL, conn);
                NpgsqlDataReader rd = pg_cmd.ExecuteReader();
    
                while (rd.Read())
                {
                    spopup = Int32.Parse(rd[0].ToString());
                }
                rd.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
    

    finally // 무조건 실행 { if (conn != null) conn.Close(); // 연결을 종료

                Cursor.Current = Cursors.Default;
            }
            timerPopup.Stop();
    
            // 윈도우 팝업 살리기
            if 
                (this.WindowState == FormWindowState.Minimized)
                this.WindowState = FormWindowState.Normal;
    
            // 타이머 재시작
            timerPopup.Interval = m_nPopup * 60 * 1000;
            timerPopup.Start();
        }
    

    이렇게 소스를 짜서 구동했는데 Y,N 구분없이 어떤 사용자로 로그인하던지 기능이 작동하더라구요.. 고수님들 한수 배우고싶습니다.