protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { int Id = Convert.ToInt32(e.CommandArgument.ToString()); //subID question string cName = e.CommandName.ToLower(); //------------- Lay ParentID AdminBSO adminBSO = new AdminBSO(); ETO.Admin admin = new ETO.Admin(); ListQuestionBSO listQuestionBSO = new ListQuestionBSO(); DataTable dt = new DataTable(); string strParentID = ""; dt = listQuestionBSO.GetQuestionByID(Id); if (dt.Rows.Count > 0) strParentID = dt.Rows[0]["Question_ParentID"].ToString(); switch (cName) { case "_view_sub": break; case "_publish": listQuestionBSO.updateStatusPublishQuestion(Id, 1); Response.Redirect("~/Admin/listdetailquestion&Id=" + strParentID + "/Default.aspx"); break; case "_unpublish": listQuestionBSO.updateStatusPublishQuestion(Id, 0); Response.Redirect("~/Admin/listdetailquestion&Id=" + strParentID + "/Default.aspx"); break; case "_edit_sub": { Response.Redirect("~/Admin/s/listdetailquestion/" + strParentID + "/" + Id + "/Default.aspx"); break; } case "_delete_sub": { listQuestionBSO.deleteQuestionByID(Id); Response.Redirect("~/Admin/p/listquestion/0/Default.aspx"); break; } } }
protected void Page_Load(object sender, EventArgs e) { AdminBSO adminBSO = new AdminBSO(); //Admin admin = new Admin(); //admin = adminBSO.GetAdminById(Session["Admin_UserName"].ToString()); //RolesBSO roleBSO = new RolesBSO(); //IRoles iRole = new IRoles(); //btn_delall.Visible = false; //iRole = roleBSO.GetRolesById(admin.RolesID); //Thiet lap icon action cho nhom guest ListQuestionBSO listQuestionBSO_ = new ListQuestionBSO(); string RolesName_ = listQuestionBSO_.RolesNameByUserName(Session["Admin_UserName"].ToString()); if (RolesName_ == "Guest") { iconForUser(); } if (Page.RouteData.Values["dll"] != null) { strParam = Page.RouteData.Values["Id"].ToString(); //p = parameter: int outValue; if (!int.TryParse(strParam, out outValue)) Response.Redirect("~/Admin/listquestion/Default.aspx"); if (!string.IsNullOrEmpty(strParam)) { //-------------Kiem tra su ton tai cua User listParentQuestionByID(int.Parse(strParam), RolesName_); bindingContentQuestion(int.Parse(strParam), RolesName_); listChildQuestionByParentID(int.Parse(strParam), RolesName_); Label1.Text = "Xem câu trả lời"; //------------------------- Edit subQuestion if (!string.IsNullOrEmpty(Page.RouteData.Values["subid"].ToString())) { int outCheck; if (!int.TryParse(Page.RouteData.Values["subid"].ToString(), out outCheck)) Response.Redirect("~/Admin/listquestion/Default.aspx"); ListQuestionBSO listQuestionBSO = new ListQuestionBSO(); DataTable dt = new DataTable(); int subID = Convert.ToInt32(Page.RouteData.Values["subid"]); //int subID = int.Parse(Page.RouteData.Values["subid"]); dt = listQuestionBSO.GetQuestionByID(subID); if (dt.Rows.Count > 0) { txtRadShort.Html = dt.Rows[0]["Question_Content"].ToString(); if (!string.IsNullOrEmpty(dt.Rows[0]["Question_FileAttach"].ToString())) HiddenField_FileAttach.Value = dt.Rows[0]["Question_FileAttach"].ToString(); if (!string.IsNullOrEmpty(dt.Rows[0]["Question_Image"].ToString())) HiddenField_ImageAttach.Value = dt.Rows[0]["Question_Image"].ToString(); txtRadShort.Focus(); } } } } else { lbContentQuestion.Text = "Chưa có dữ liệu"; lbDatePostQuestion.Text = ""; lbQuestionTitle.Text = ""; btnSend.Enabled = false; Label1.Text = ""; txtRadShort.Enabled = false; } }