private void LoadCheckBoxChude() { cklChude.Items.Clear(); DataTable dt = ChudeService.Chude_GetByTop("", "Active = 1", "Id"); for (int i = 0; i < dt.Rows.Count; i++) { DataRow row = dt.Rows[i]; cklChude.Items.Add(new ListItem(row["Name"].ToString(), row["Id"].ToString())); } cklChude.DataBind(); }
private void BindGrid() { grdChude.DataSource = ChudeService.Chude_GetByAll(); grdChude.DataBind(); if (grdChude.PageCount <= 1) { grdChude.PagerStyle.Visible = false; } else { grdChude.PagerStyle.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { if (Page.RouteData.Values["GroupId"] != null) { id = Page.RouteData.Values["GroupId"] as string; } if (Page.RouteData.Values["Id"] != null) { chudeId = Page.RouteData.Values["Id"] as string; } if (!IsPostBack) { if (Microsoft.VisualBasic.Information.IsNumeric(id)) { List <Data.GroupProduct> listGroup = GroupProductService.GroupProduct_GetById(id); if (listGroup.Count > 0) { DataTable dt = GroupProductService.GroupProduct_GetByTop("", "Active = 1 AND Len(Level) > " + listGroup[0].Level.Length + " AND Left(Level,Len('" + listGroup[0].Level + "'))='" + listGroup[0].Level + "' AND Id <> " + id, ""); if (dt.Rows.Count > 0) { idU_ProductList.Visible = false; U_GroupProductList.Visible = true; U_GroupProductList.GroupProduct = dt; } else { idU_ProductList.Visible = true; U_GroupProductList.Visible = false; idU_ProductList.Level = listGroup[0].Level; idU_ProductList.ItemCount = listGroup[0].Items; } lblGroupName.Text = listGroup[0].Name; } } else if (Microsoft.VisualBasic.Information.IsNumeric(chudeId)) { DataTable chude = ChudeService.Chude_GetById(chudeId); if (chude.Rows.Count > 0) { lblGroupName.Text = chude.Rows[0]["Name"].ToString(); idU_ProductList.ChudeId = chudeId; } } if (Request.QueryString["key"] != null) { lblGroupName.Text = Request.QueryString["key"].ToString(); } } }
private void LoadDropDownListPageLink() { ddlLink.Items.Clear(); ddlLink.Items.Add(new ListItem("Trang chủ", "/")); DataTable dt = new DataTable(); dt = GroupNewsService.GroupNews_GetByTop("", "Active=1", "Level, Ord"); ddlLink.Items.Add(new ListItem("Tin tức", "#")); for (int i = 0; i < dt.Rows.Count; i++) { ddlLink.Items.Add(new ListItem(StringClass.ShowNameLevel(dt.Rows[i]["Name"].ToString(), dt.Rows[i]["Level"].ToString() + "00000"), PageHelper.GeneralGroupUrl(Consts.CON_TIN_TUC, dt.Rows[i]["Id"].ToString(), dt.Rows[i]["Name"].ToString()))); } List <Data.GroupImages> listG = GroupImagesService.GroupImages_GetByTop("", "Active=1", "Level, Ord"); ddlLink.Items.Add(new ListItem("Hình ảnh", "#")); if (listG.Count > 0) { for (int i = 0; i < listG.Count; i++) { ddlLink.Items.Add(new ListItem(StringClass.ShowNameLevel(listG[i].Name, listG[i].Level + "00000"), "/Thu-vien-anh/" + listG[i].Id + "/" + StringClass.NameToTag(listG[i].Name))); } } DataTable listGProduct = GroupProductService.GroupProduct_GetByTop("", "Active=1", "Level, Ord"); ddlLink.Items.Add(new ListItem("Sản phẩm", "#")); if (listGProduct.Rows.Count > 0) { for (int i = 0; i < listGProduct.Rows.Count; i++) { ddlLink.Items.Add(new ListItem(StringClass.ShowNameLevel(listGProduct.Rows[i]["Name"].ToString(), listGProduct.Rows[i]["Level"].ToString() + "00000"), PageHelper.GeneralGroupUrl(Consts.CON_SAN_PHAM, listGProduct.Rows[i]["Id"].ToString(), listGProduct.Rows[i]["Name"].ToString()))); } } DataTable listChude = ChudeService.Chude_GetByTop("", "Active=1", "Ord"); ddlLink.Items.Add(new ListItem("Chủ đề", "#")); if (listChude.Rows.Count > 0) { for (int i = 0; i < listChude.Rows.Count; i++) { ddlLink.Items.Add(new ListItem(StringClass.ShowNameLevel(listChude.Rows[i]["Name"].ToString(), "0000000000"), "/chu-de/chu-de-" + listChude.Rows[i]["Id"].ToString() + "/" + StringClass.NameToTag(listChude.Rows[i]["Name"].ToString()))); } } ddlLink.Items.Add(new ListItem("Liên hệ", "/lien-he")); ddlLink.DataBind(); }
protected void DeleteButton_Click(object sender, EventArgs e) { DataGridItem item = default(DataGridItem); for (int i = 0; i < grdChude.Items.Count; i++) { item = grdChude.Items[i]; if (item.ItemType == ListItemType.AlternatingItem | item.ItemType == ListItemType.Item) { if (((CheckBox)item.FindControl("ChkSelect")).Checked) { string strId = item.Cells[1].Text; ChudeService.Chude_Delete(strId); SqlDataProvider sql = new SqlDataProvider(); sql.ExecuteNonQuery("Delete From [Images] where GroupId='" + strId + "'"); } } } grdChude.CurrentPageIndex = 0; BindGrid(); }
protected void grdChude_ItemCommand(object source, DataGridCommandEventArgs e) { string strCA = e.CommandArgument.ToString(); switch (e.CommandName) { case "AddSub": Level = strCA; AddButton_Click(source, e); break; case "Edit": Insert = false; Id = strCA; DataTable listE = ChudeService.Chude_GetById(Id); Level = listE.Rows[0]["Level"].ToString(); txtName.Text = listE.Rows[0]["Name"].ToString(); txtOrd.Text = listE.Rows[0]["Ord"].ToString(); chkActive.Checked = listE.Rows[0]["Active"].ToString() == "1" || listE.Rows[0]["Active"].ToString() == "True"; pnView.Visible = false; pnUpdate.Visible = true; break; case "Active": string strA = ""; string str = e.Item.Cells[2].Text; strA = str == "1" ? "0" : "1"; SqlDataProvider sql = new SqlDataProvider(); sql.ExecuteNonQuery("Update [Chude] set Active=" + strA + " Where Id='" + strCA + "'"); BindGrid(); break; case "Delete": ChudeService.Chude_Delete(strCA); BindGrid(); break; } }
protected void Update_Click(object sender, EventArgs e) { if (Page.IsValid) { Data.Chude obj = new Data.Chude(); obj.Id = Id; obj.Name = txtName.Text; obj.Ord = txtOrd.Text != "" ? txtOrd.Text : "1"; obj.Active = chkActive.Checked ? "1" : "0"; if (Insert == true) { ChudeService.Chude_Insert(obj); } else { ChudeService.Chude_Update(obj); } BindGrid(); pnView.Visible = true; pnUpdate.Visible = false; Level = ""; Insert = false; } }