Exemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     lblError.Text = "";
     if (!IsPostBack)
     {
         LoadChuyenMuc();
         if (Request.QueryString["Action"] != null)
         {
             if (Request.QueryString["Action"] == "Add" || Request.QueryString["Action"] == "Edit")
             {
                 pnlThem.Visible          = true;
                 txtMaChuyenMuc.Enabled   = true;
                 btnThemChuyenMuc.Visible = false;
                 if (Request.QueryString["Action"] == "Edit")
                 {
                     txtMaChuyenMuc.Enabled = false;
                     btnSave.Visible        = false;
                     int           id = Convert.ToInt32(Request.QueryString["ID"]);
                     XuLyChuyenMuc xl = new XuLyChuyenMuc();
                     DataTable     dt = xl.GetChuyenMuc(id);
                     txtMaChuyenMuc.Text  = dt.Rows[0]["idCategoryFood"].ToString();
                     txtTenChuyenMuc.Text = dt.Rows[0]["Name"].ToString();
                 }
             }
         }
         else
         {
             pnlThem.Visible          = false;
             btnThemChuyenMuc.Visible = true;
         }
     }
 }
Exemplo n.º 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     lblError.Text = "";
     if (!IsPostBack)
     {
         LoadChuyenMuc();
         if (Request.QueryString["Action"] != null)
         {
             if (Request.QueryString["Action"] == "Add" || Request.QueryString["Action"] == "Edit")
             {
                 pnlThem.Visible          = true;
                 btnThemChuyenMuc.Visible = false;
                 if (Request.QueryString["Action"] == "Edit")
                 {
                     btnSave.Visible = false;
                     int           id = Convert.ToInt32(Request.QueryString["ID"]);
                     XuLyChuyenMuc xl = new XuLyChuyenMuc();
                     DataTable     dt = xl.GetChuyenMuc(id);
                     txtMaChuyenMuc.Text  = dt.Rows[0]["MaChuyenMuc"].ToString();
                     txtTenChuyenMuc.Text = dt.Rows[0]["TenChuyenMuc"].ToString();
                     txtMoTa.Text         = dt.Rows[0]["MoTa"].ToString();
                     string trangThai = dt.Rows[0]["TrangThai"].ToString();
                     if (trangThai == "1" || trangThai == "True")
                     {
                         chkTrangThai.Checked = true;
                     }
                     else
                     {
                         chkTrangThai.Checked = false;
                     }
                 }
             }
         }
         else
         {
             pnlThem.Visible          = false;
             btnThemChuyenMuc.Visible = true;
         }
     }
 }