Esempio n. 1
0
        private void DisplayDataForModify()
        {
            var  repo = new DbRespository();
            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;

            //encoding
            string encoding = note.Encoding;

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

            //Todo :파일처리
        }
Esempio n. 2
0
        private void DisplayDataForReply()
        {
            var  repo = new DbRespository();
            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";
        }
        protected void btnCommentDelete_Click(object sender, EventArgs e)
        {
            var repo = new DbRespository();

            if (repo.GetCountBy(BoardId, Id, txtPassword.Text) > 0)
            {
                repo.DeleteNoteComment(BoardId, Id, txtPassword.Text);
                Response.Redirect($"BoardView.aspx?Id={BoardId}");
            }
            else
            {
                lblError.Text = "암호가 틀렸습니다. 다시 입력하세요.";
            }
        }
Esempio n. 4
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            //현재글의 ID와 비밀번호가 일치하면 삭제
            var repo = new DbRespository();

            if (repo.DeleteNote(Convert.ToInt32(_Id), txtPassword.Text) > 0)
            {
                Response.Redirect("BoardList.aspx");
            }
            else
            {
                lblMessage.Text = "삭제되지 않았습니다. 비밀번호를 확인하세요.";
            }
        }
Esempio n. 5
0
        private void DisplayData()
        {
            var  repo = new DbRespository();
            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);
            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
            {
                lblContent.Text = content;
            }

            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}";
            }
        }
Esempio n. 6
0
        public int PageIndex   = 0; //페이징 할때 값, 현재 보여줄 페이지 번호

        public BoardList()
        {
            _repo = new DbRespository(); //SQlConnection 생성
        }
Esempio n. 7
0
 public BoardDown()
 {
     _repo = new DbRespository();
 }
Esempio n. 8
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

                DbRespository repo = new DbRespository();

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

                case BoardWriteFormType.Modify:
                    note.ModifyIp = Request.UserHostAddress;
                    //TODo: file 처리
                    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.Add(note);
                    Response.Redirect("BoardList.aspx");
                    break;
                }
            }
            else
            {
                lblError.Text = "보안코드가 틀립니다. 다시 입력하세요.";
            }
        }
 public CommentControl()
 {
     _repo = new DbRespository();
 }