protected void grdImgType_ItemCommand(object source, DataGridCommandEventArgs e) { string strCA = e.CommandArgument.ToString(); switch (e.CommandName) { case "Edit": Insert = false; Id = strCA; List <Data.ImgType> listE = ImgTypeBUS.ImgType_GetById(Id); txtName.Text = listE[0].Name; txtCode.Text = listE[0].Code; 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 [ImageType] set Active=" + strA + " Where Id='" + strCA + "'"); BindGrid(); break; case "Delete": ImgTypeBUS.ImgType_Delete(strCA); BindGrid(); break; } }
private void BindGrid() { grdImgType.DataSource = ImgTypeBUS.ImgType_GetByAll(); grdImgType.DataBind(); if (grdImgType.PageCount <= 1) { grdImgType.PagerStyle.Visible = false; } }
public string ShowPosition(string str) { string s = ""; List <Data.ImgType> list = ImgTypeBUS.ImgType_GetByTop("", "Code=" + str + "", ""); if (list.Count > 0) { s += list[0].Name; } return(s); }
private void loadtype() { List <Data.ImgType> list = ImgTypeBUS.ImgType_GetByAll(); if (list.Count > 0) { ddlPosition.Items.Clear(); ddlFilterPosition.Items.Clear(); ddlPosition.Items.Add(new ListItem(" -- Chọn định dạng-- ", "")); ddlFilterPosition.Items.Add(new ListItem(" -- Chọn định dạng-- ", "")); for (int i = 0; i < list.Count; i++) { ddlPosition.Items.Add(new ListItem(list[i].Name, list[i].Code)); ddlFilterPosition.Items.Add(new ListItem(list[i].Name, list[i].Code)); } } }
protected void DeleteButton_Click(object sender, EventArgs e) { DataGridItem item = default(DataGridItem); for (int i = 0; i < grdImgType.Items.Count; i++) { item = grdImgType.Items[i]; if (item.ItemType == ListItemType.AlternatingItem | item.ItemType == ListItemType.Item) { if (((CheckBox)item.FindControl("ChkSelect")).Checked) { string strId = item.Cells[1].Text; ImgTypeBUS.ImgType_Delete(strId); } } } grdImgType.CurrentPageIndex = 0; BindGrid(); }
protected void Update_Click(object sender, EventArgs e) { if (Page.IsValid) { Data.ImgType obj = new Data.ImgType(); obj.Id = Id; obj.Name = txtName.Text; obj.Code = txtCode.Text; obj.Active = chkActive.Checked ? "1" : "0"; if (Insert == true) { ImgTypeBUS.ImgType_Insert(obj); } else { ImgTypeBUS.ImgType_Update(obj); } BindGrid(); pnView.Visible = true; pnUpdate.Visible = false; Insert = false; } }