protected void Page_Load(object sender, EventArgs e)
    {
        HttpCookie usercookie = Request.Cookies["nowloginuser"];
        string     url        = PublicClass.CheckLogin(usercookie, "main");

        if (url != "")
        {
            Response.Write(url);
            return;
        }

        if (!IsPostBack)
        {
            string action = Request["action"];
            string sjid   = Request["sjid"];
            if (action != null && sjid != null)
            {
                int id = int.Parse(sjid);
                if (action.Equals("delete"))
                {
                    //删除服务器上面对应试卷的所有图片
                    foreach (DataRow row in TbImagesManager.GetImagesBySjid(id).Rows)
                    {
                        string path = Server.MapPath("images/" + row["Tpian"].ToString());
                        if (File.Exists(path))
                        {
                            File.Delete(path);
                        }
                    }
                    TbImagesManager.DeleteImageBySjid(id);
                    TbQuestionTypesManager.DeleteQuestionTypesBySjid(id);
                    TbTestPaperManager.DeleteTestpaperBySjid(id);
                }
            }
            GetAllTestPaperInfo();
        }
    }
Beispiel #2
0
    /// <summary>
    /// 根据试卷ID获得图片
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string sjid = Request["SjID"];  //获得传过来的试卷ID
            if (sjid != null)
            {
                int       Sjid   = int.Parse(sjid);
                DataTable dtable = TbImagesManager.GetImagesBySjid(Sjid);
                if (dtable != null)
                {
                    Dtb = dtable;
                    for (int i = 0; i < dtable.Rows.Count; i++)
                    {
                        string str = "../admin/TestPaper/images/";

                        Image img = new Image();
                        img.ImageUrl = str + dtable.Rows[i]["Tpian"];
                        PanImg.Controls.Add(img);
                    }
                }
            }
        }
    }