示例#1
0
    // sua :

    private void sua()
    {
        string        namePic = "none";
        string        tt      = "";
        DateTime      datet   = DateTime.Now;
        int           id      = Convert.ToInt32(Request.QueryString["id"]);
        advBLL        bs      = new advBLL();
        List <advDAL> ds      = bs.getAdv();

        if (fileHinh.HasFile)
        {
            if (CheckFileType(fileHinh.FileName) == true)
            {
                string ext = Path.GetExtension(fileHinh.FileName);
                namePic = string.Format("{0:yyyy-M-d-HH-mm-ss}", datet) + ext;
                String filePath = "~/adv/" + namePic;

                fileHinh.SaveAs(MapPath(filePath));
                lbErrorPic.Text = filePath;
            }
            else
            {
                lbErrorPic.Text = "Hình ảnh phải ở dạng đuôi *.png, *.jpg";
            }
        }

        if (rbYes.Checked == true)
        {
            tt = "true";
            for (int i = 0; i <= ds.Count - 1; i++)
            {
                if (ds[i].trangthai == true)
                {
                    bs.ttPic();
                    break;
                }
            }
        }
        else if (rbNo.Checked == true)
        {
            tt = "false";
        }

        bool tf = bs.edit(id, txtTen.Text, txtLink.Text, namePic, tt);

        if (tf == true)
        {
            Response.Redirect("quangcao.aspx?edit=t");
        }
        else
        {
            lbError.Text = "<div class='error'>"
                           + "<div class='tl'></div><div class='tr'></div>"
                           + "<div class='desc'>"
                           + "<p>Cập nhật bị lỗi !</p>"
                           + "</div>"
                           + "<div class='bl'></div><div class='br'></div>"
                           + "</div>";
        }
    }
示例#2
0
    // load adv
    private void loadadv()
    {
        advBLL        bs = new advBLL();
        List <advDAL> ds = bs.getAdv();

        rpQC.DataSource = ds;
        rpQC.DataBind();

        for (int i = 0; i < ds.Count; i++)
        {
            CheckBox cbDell = rpQC.Items[i].FindControl("cbDell") as CheckBox;
            Label    lbSTT  = rpQC.Items[i].FindControl("lbSTT") as Label;
            Label    lbTT   = rpQC.Items[i].FindControl("lbTT") as Label;
            lbSTT.Text = (i + 1).ToString();
            if (ds[i].trangthai == true)
            {
                lbTT.Text = "Đang hoạt động";
            }
            else
            {
                lbTT.Text = "Đã tắt";
            }
            if (ds[i].trangthai == true)
            {
                cbDell.Enabled = false;
            }
        }
    }