コード例 #1
0
 protected void PhanLoaiGridView_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "xoa")
     {
         string maphanloai = (e.CommandArgument).ToString();
         phanloaiBUS.XoaPhanLoai(maphanloai);
         NapDuLieu();
        
     }
     else if (e.CommandName == "sua")
     {
         PhanLoaiCollection phanloaicoll = new PhanLoaiCollection();
         phanloaicoll = phanloaiBUS.TimDSCapNhatPhanLoai(TimTextbox.Text);
         int index = Convert.ToInt32(e.CommandArgument.ToString());
         ViewState["MaPhanLoai"] = phanloaicoll.Index(index).MaPhanLoai;
         string tenphanloai = phanloaicoll.Index(index).TenPhanLoai;
         SuaPopup.Show();
         SuaTextBox.Text = tenphanloai;
         
     }
     else if (e.CommandName == "chitiet")
     {
         PhanLoaiCollection phanloaicoll = new PhanLoaiCollection();
         phanloaicoll = phanloaiBUS.TimDSCapNhatPhanLoai(TimTextbox.Text);
         int index = Convert.ToInt32(e.CommandArgument.ToString());
         ViewState["MaPhanLoai"] = phanloaicoll.Index(index).MaPhanLoai;
         string tenchitiet = phanloaicoll.Index(index).TenPhanLoai;
         ChiTietPopup.Show();
         NapChiTiet();
         TenPhanLoaiLabel.Text = tenchitiet;
     }
 }
コード例 #2
0
 public void NapTheLoai()
 {
     TheLoaiDropdown.Items.Clear();
     PhanLoaiCollection source = new PhanLoaiCollection();      
     PhanLoaiBO phanloaiBO = new PhanLoaiBO();
     phanloaiBO.TenPhanLoai = "Tất cả";
     phanloaiBO.MaPhanLoai = "";
     source.Add(phanloaiBO);
     //add
     PhanLoaiCollection temp = new PhanLoaiCollection();
     temp=phanloaiBUS.TimDSPhanLoai();
     for (int i = 0; i < temp.Count; i++)
     {
         source.Add(temp.Index(i));
     }
     TheLoaiDropdown.DataSource = source;
     TheLoaiDropdown.DataTextField = "Tenphanloai";
     TheLoaiDropdown.DataValueField = "Maphanloai";
     TheLoaiDropdown.DataBind();
 }