protected void btnAddComment_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(tbComment.Text)) { lbResult.Text = "コメントを入力して下さい"; return; } DataDoc dc = DataDoc.Instance(Server); lock (dc) { HttpCookie hc = Request.Cookies["user"]; string user; if (hc == null || string.IsNullOrEmpty(user = MasterPage.UserName(hc))) { lbResult.Text = "ログインして下さい"; return; } Answer aw = dc.GetAnswer((int?)Session["Answer"]); if (aw == null) { lbResult.Text = "対象がありません"; return; } dc.AddComment(aw.ID, user, tbComment.Text); dc.Save(null); } SetData(); }
protected void btnAdd_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(tbUser.Text)) { lbResult.Text = "作成者を入力して下さい"; return; } if (string.IsNullOrEmpty(tbTitle.Text)) { lbResult.Text = "タイトルを入力して下さい"; return; } if (string.IsNullOrEmpty(tbAnswer.Text)) { lbResult.Text = "内容を入力して下さい"; return; } lbResult.Text = ""; DataDoc dc = DataDoc.Instance(Server); lock (dc) { dc.AddAnswer(tbTitle.Text, tbUser.Text, tbAnswer.Text); dc.Save(null); lbResult.Text = "追加しました"; } }
protected void btnYes_Click(object sender, EventArgs e) { DataDoc dc = DataDoc.Instance(Server); lock (dc) { bool bNotFound = true; string tgt = (string)Session["DeleteTarget"]; if (tgt == "Problem") { Problem pb = dc.GetProblem((string)Session["Title"]); if (pb != null) { bNotFound = false; dc.Problems.Remove(pb); } } else if (tgt == "Answer") { Answer aw = dc.GetAnswer((int?)Session["Answer"]); if (aw != null) { bNotFound = false; dc.Answers.Remove(aw); } } else if (tgt == "Comment") { Comment cm = dc.GetComment((int?)Session["Comment"]); if (cm != null) { bNotFound = false; dc.Comments.Remove(cm); } } if (bNotFound) { lbResult.Text = "対象がありません"; return; } dc.Save(null); } lbResult.Text = ""; btnNo_Click(null, null); }
protected void btnUpdate_Click(object sender, EventArgs e) { DataDoc dc = DataDoc.Instance(Server); lock (dc) { Problem pb = dc.GetProblem(tbTitle.Text); if (pb == null) { lbResult.Text = "対象がありません"; return; } pb.Contents = tbProblem.Text; pb.Time = DateTime.Now.ToString(); dc.Save(null); lbResult.Text = "更新しました"; } }
protected void btnUpdate_Click(object sender, EventArgs e) { DataDoc dc = DataDoc.Instance(Server); lock (dc) { Answer aw = dc.GetAnswer((int?)Session["Answer"]); if (aw == null) { lbResult.Text = "対象がありません"; return; } aw.Contents = tbAnswer.Text; aw.Time = DateTime.Now.ToString(); dc.Save(null); lbResult.Text = "更新しました"; } }
protected void btnAdd_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(tbUser.Text)) { lbResult.Text = "作成者を入力して下さい"; return; } if (string.IsNullOrEmpty(tbTitle.Text)) { lbResult.Text = "タイトルを入力して下さい"; return; } if (string.IsNullOrEmpty(tbCate.Text)) { lbResult.Text = "カテゴリを入力して下さい"; return; } if (string.IsNullOrEmpty(tbProblem.Text)) { lbResult.Text = "内容を入力して下さい"; return; } lbResult.Text = ""; DataDoc dc = DataDoc.Instance(Server); lock (dc) { Problem pb = dc.GetProblem(tbTitle.Text); if (pb != null) { lbResult.Text = "カテゴリ(" + pb.Category + ")に同じタイトルがあります"; return; } dc.AddProblem(tbTitle.Text, tbCate.Text, tbUser.Text, tbProblem.Text); dc.Save(null); lbResult.Text = "追加しました"; } Encoding enc = Encoding.UTF8; MasterPage mp = (MasterPage)Master; mp.SetUser(Convert.ToBase64String(enc.GetBytes(tbUser.Text))); mp.SetCateUser(); }