コード例 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["ACCOUNT"] == null)
        {
            Response.Redirect("../Login.aspx");
        }

        try
        {
            this.itemId = int.Parse(Request["id"].ToString());
        }
        catch
        {
            Response.Redirect("/Category/ListCategory.aspx");
        }

        DanhMuc objDanhMuc = new DanhMuc();

        objData = objDanhMuc.getItem(itemId);
        if (objData == null)
        {
            Response.Redirect("/Category/ListCategory.aspx");
        }
        if ((int)objData["DanhMucId"] == 0)
        {
            Response.Redirect("/Category/ListCategory.aspx");
        }

        try
        {
            danhmuc = objDanhMuc.getDanhMuc((int)objData["DanhMucId"])["NameDanhMuc"].ToString();
        }
        catch { }
    }
コード例 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["ACCOUNT"] == null)
        {
            Response.Redirect("../Login.aspx");
        }

        try
        {
            this.itemId = int.Parse(Request["id"].ToString());
        }
        catch
        {
            itemId = 0;
        }

        try
        {
            this.group = int.Parse(Request["dm"].ToString());
        }
        catch
        {
            group = 0;
        }

        if (itemId == 0 && group == 0)
        {
            Response.Redirect("/Category/ListCategory.aspx");
        }

        if (itemId != 0)
        {
            objData = objDanhMuc.getItem(itemId);
            if (objData == null)
            {
                Response.Redirect("/Category/ListCategory.aspx");
            }
            if ((int)objData["DanhMucId"] == 0)
            {
                Response.Redirect("/Category/ListCategory.aspx");
            }
            group = (int)objData["DanhMucId"];

            if (!Page.IsPostBack)
            {
                txtNameDanhMuc.Text = objData["NameDanhMuc"].ToString();
                txtNote.Text        = objData["Note"].ToString();
                ckbState.Checked    = (bool)objData["State"];
            }
        }
        else if (!Page.IsPostBack)
        {
            ckbState.Checked = true;
        }

        DataRow danhuc = objDanhMuc.getDanhMuc(group);

        if (danhuc == null)
        {
            Response.Redirect("/Category/ListCategory.aspx");
        }

        Session["TITLE"] = danhuc["NameDanhMuc"].ToString().ToUpper();
    }