Exemplo n.º 1
0
        private void DisplayDataForModify()
        {
            var  repo = new DB_Repository();
            Note note = repo.GetNoteById(Convert.ToInt32(_ID));

            txtName.Text     = note.Name;
            txtEmail.Text    = note.Email;
            txtHomepage.Text = note.Homepage;
            txtTitle.Text    = note.Title;
            txtContent.Text  = note.Content;

            //Encodig
            string encoding = note.Encoding;

            if (encoding == "Text")
            {
                rdoEncoding.SelectedIndex = 0;
            }
            else if (encoding == "Mixed")
            {
                rdoEncoding.SelectedIndex = 1;
            }

            //TODO : 파일처리
        }
Exemplo n.º 2
0
        private void DisplayDataForReply()
        {
            var  repo = new DB_Repository();
            Note note = repo.GetNoteById(Convert.ToInt32(_ID));

            txtTitle.Text   = $"답변:{note.Title}";
            txtContent.Text = $"\n\n작성일:{note.PostDate}, 작성자:'{note.Name}'\n-----------------------------------\n>" +
                              $"{note.Content.Replace("\n", "\n>")}\n-----------------------------------\n";
        }
Exemplo n.º 3
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            //현재 글의 ID와 비밀번호가 일치하면 삭제
            var repo = new DB_Repository();

            if (repo.DeleteNote(Convert.ToInt32(_Id), txtPassword.Text) > 0) //삭제되면 1, 안되면 0이므로 >0이 돼야 함
            {
                Response.Redirect("BoardList.aspx");
            }
            else
            {
                lblMessage.Text = "삭제되지 않았습니다.비밀번호를 확인하세요.";
            }
        }
Exemplo n.º 4
0
        protected void btnCommentDelete_Click(object sender, EventArgs e)
        {
            var repo = new DB_Repository();

            if (repo.GetCountBy(BoardId, Id, txtPassword.Text) > 0)
            {
                repo.DeleteNoteComment(BoardId, Id, txtPassword.Text);
                Response.Redirect($"BoardView.aspx?Id={BoardId}");
            }
            else
            {
                lblError.Text = "암호가 틀렸습니다. 다시 입력하세요.";
            }
        }
Exemplo n.º 5
0
        private void DisplayData()
        {
            var  repo = new DB_Repository();
            Note note = repo.GetNoteById(Convert.ToInt32(_Id));

            lblNum.Text   = _Id;
            lblName.Text  = note.Name;
            lblEmail.Text = string.Format("<a href='mailto:{0}'>{0}</a>", note.Email); //email을 누르면 바로 작성할 수 있도록 해줌(outlook으로 바로 연동 등)
            lblTitle.Text = note.Title;

            string content = note.Content;

            //인코딩 방식 : text, html, mixed
            string encoding = note.Encoding;

            if (encoding == "Text")
            {
                lblContent.Text = Helpers.HtmlUtility.EncodeWithTabAndSpace(content);
            }
            else if (encoding == "Mixed")
            {
                lblContent.Text = content.Replace("\r\n", "<br/>");
            }
            else //html
            {
                lblContent.Text = content; //html은 변환없이 출력
            }

            lblReadCount.Text = note.ReadCount.ToString();
            lblHomepage.Text  = $"<a href='{note.Homepage}' target='_blank'>{note.Homepage}</a>";
            lblPostDate.Text  = note.PostDate.ToString();
            lblPostIP.Text    = note.PostIp;

            if (note.FileName.Length > 1)
            {
                lblFile.Text = $"{note.FileName} / 다운로드 {note.DownCount}";
            }
            else
            {
                lblFile.Text = "(None)";
            }
        }
Exemplo n.º 6
0
 public BoardDown()
 {
     _repo = new DB_Repository();
 }
Exemplo n.º 7
0
        protected void btnWrite_Click(object sender, EventArgs e)
        {
            if (IsImageTextCorrect())
            {
                if (ViewState["Mode"].ToString() == "Edit")
                {
                    FormType = BoardWriteFormType.Modify;
                }
                else if (ViewState["Mode"].ToString() == "Reply")
                {
                    FormType = BoardWriteFormType.Reply;
                }
                else
                {
                    FormType = BoardWriteFormType.Write;
                }

                UploadFile();  //파일업로드

                Note note = new Note();
                note.Id       = Convert.ToInt32(_ID); //없으면 0
                note.Name     = txtName.Text;         //필수
                note.Email    = txtEmail.Text;
                note.Title    = txtTitle.Text;        //필수
                note.Homepage = txtHomepage.Text;
                note.Content  = txtContent.Text;      //필수
                note.FileName = _FileName;
                note.FileSize = _FileSize;
                note.Password = txtPassword.Text;
                note.PostIp   = Request.UserHostAddress;
                note.Encoding = rdoEncoding.SelectedValue; //필수 //text, html, mixed값이 들어감

                DB_Repository repo = new DB_Repository();
                switch (FormType)
                {
                case BoardWriteFormType.Write:
                    repo.Add(note);
                    Response.Redirect("BoardList.aspx");
                    break;

                case BoardWriteFormType.Modify:
                    note.ModifyIp = Request.UserHostAddress;
                    //TODO : 파일처리
                    note.FileName = ViewState["FileName"].ToString();
                    note.FileSize = Convert.ToInt32(ViewState["FileSize"]);
                    if (repo.UpdateNote(note) > 0)
                    {
                        Response.Redirect($"BoardView.aspx?Id={_ID}");
                    }
                    else
                    {
                        lblError.Text = "업데이트 실패, 암호를 확인하세요.";
                    }
                    break;

                case BoardWriteFormType.Reply:
                    note.ParentNum = Convert.ToInt32(_ID);
                    repo.ReplyNote(note);
                    Response.Redirect("BoardList.aspx");
                    break;

                default:
                    repo.ReplyNote(note);
                    Response.Redirect("BoardList.aspx");
                    break;
                }
            }
            else
            {
                lblError.Text = "보안코드가 틀립니다. 다시 입력하십시오.";
            }
        }
Exemplo n.º 8
0
        public int PageIndex   = 0; //페이징할 때 값, 현재 보여줄 페이지 번호

        public BoardList()
        {
            _repo = new DB_Repository(); //sqlconnection 생성
        }
Exemplo n.º 9
0
 public CommentControl()
 {
     _repo = new DB_Repository();
 }