private void BindGrid() { if (drlnhom.SelectedValue == "0") { grdImages.DataSource = ImagesService.Images_GetByAll(); grdImages.DataBind(); if (grdImages.PageCount <= 1) { grdImages.PagerStyle.Visible = false; } else { grdImages.PagerStyle.Visible = true; } } else { String level = String.Empty; List <Data.GroupImages> listG = GroupImagesService.GroupImages_GetById(drlnhom.SelectedValue); if (listG.Count > 0) { level = listG[0].Level; } grdImages.DataSource = ImagesService.Images_GetByTop("", "GroupId IN (Select Id From GroupImages WHERE left([Level],len('" + level + "'))='" + level + "')", "Ord"); grdImages.DataBind(); if (grdImages.PageCount <= 1) { grdImages.PagerStyle.Visible = false; } else { grdImages.PagerStyle.Visible = true; } } }
protected void grdGroupImages_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; List <Data.GroupImages> listE = GroupImagesService.GroupImages_GetById(Id); Level = listE[0].Level.Substring(0, listE[0].Level.Length - 5); txtName.Text = listE[0].Name; txtOrd.Text = listE[0].Ord; PageHelper.LoadDropDownListLanguage(ddlLanguage); ddlLanguage.SelectedValue = listE[0].Language; chkActive.Checked = listE[0].Active == "1" || listE[0].Active == "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 [GroupImages] set Active=" + strA + " Where Id='" + strCA + "'"); BindGrid(); break; case "Delete": GroupImagesService.GroupImages_Delete(strCA); SqlDataProvider sql1 = new SqlDataProvider(); sql1.ExecuteNonQuery("Delete From [Images] where GroupId='" + strCA + "'"); BindGrid(); break; } }
protected void Page_Load(object sender, EventArgs e) { try { if (Page.RouteData.Values["GroupId"] != null) { GroupId = Page.RouteData.Values["GroupId"] as string; } if (!IsPostBack) { List <GroupImages> listGrp; if (GroupId != null) { listGrp = GroupImagesService.GroupImages_GetByTop("", "Active=1", "Ord"); } else { listGrp = GroupImagesService.GroupImages_GetById(GroupId); } if (listGrp.Count > 0) { groupName = listGrp[0].Name; List <Data.Images> listImages = ImagesService.Images_GetByTop("", "Active = 1 AND GroupId = '" + listGrp[0].Id + "'", "Ord"); for (int i = 0; i < listImages.Count; i++) { ltrImages.Text += "<a href=#>\n"; ltrImages.Text += "<img alt='" + groupName + "'\n"; ltrImages.Text += "src='" + StringClass.ThumbImage(listImages[i].Image) + "'\n"; ltrImages.Text += "data-image='" + listImages[i].Image + "'\n"; ltrImages.Text += "style='display:none'></a>"; } } } } catch (Exception ex) { MailSender.SendMail("", "", "Error System", ex.Message + "\n" + ex.StackTrace); } }