예제 #1
0
        protected void lbtDeleteB_Click(object sender, EventArgs e)
        {
            try
            {
                DataGridItem item = default(DataGridItem);
                for (int i = 0; i < grdTypeFilm.Items.Count; i++)
                {
                    item = grdTypeFilm.Items[i];
                    if (item.ItemType == ListItemType.AlternatingItem | item.ItemType == ListItemType.Item)
                    {
                        if (((CheckBox)item.FindControl("ChkSelect")).Checked)
                        {
                            string strId = item.Cells[1].Text;
                            var    dt    = new DataTable();
                            TypeFilmService.TypeFilm_Delete(strId);
                        }
                    }
                }

                grdTypeFilm.CurrentPageIndex = 0;
                LoadFilterNewsNameAutocomplete();
                BindGrid();
            }
            catch (Exception ex)
            {
                WebMsgBox.Show(ex.Message);
            }
        }
예제 #2
0
 protected void grdTypeFilm_ItemCommand(object source, DataGridCommandEventArgs e)
 {
     try
     {
         string strCa    = e.CommandArgument.ToString();
         string strWhere = " 1=1 ";
         if (e.CommandName == "Edit")
         {
             _insert = false;
             DataTable dt = TypeFilmService.TypeFilm_GetById(strCa);
             txtId.Value       = dt.Rows[0]["TypId"].ToString();
             txtName.Text      = dt.Rows[0]["NameT"].ToString();
             chkActive.Checked = dt.Rows[0]["Status"].ToString() == "1" || dt.Rows[0]["Status"].ToString() == "True";
             pnUpdate.Visible  = true;
             pnView.Visible    = false;
         }
         if (e.CommandName == "Delete")
         {
             TypeFilmService.TypeFilm_Delete(strCa);
             BindGrid();
         }
         if (e.CommandName == "Status")
         {
             string strA = "";
             string str  = e.Item.Cells[2].Text;
             strA = str == "1" ? "0" : "1";
             TypeFilmService.TypeFilm_Update_Status(strCa, strA);
             BindGrid();
         }
         if (e.CommandName == "ascTypeFilm")
         {
             if (Common.StringClass.Check(txtFilterName.Text))
             {
                 strWhere += " and NameT like N'%" + txtFilterName.Text + "%' ";
             }
             if (Common.StringClass.Check(ddlFilterActive.SelectedValue))
             {
                 strWhere += " and Status = '" + ddlFilterActive.SelectedValue + "' ";
             }
             grdTypeFilm.DataSource = TypeFilmService.TypeFilm_GetByTop("", strWhere, "NameT");
             grdTypeFilm.DataBind();
             if (grdTypeFilm.PageCount <= 1)
             {
                 grdTypeFilm.PagerStyle.Visible = false;
             }
         }
         if (e.CommandName == "descTypeFilm")
         {
             if (Common.StringClass.Check(txtFilterName.Text))
             {
                 strWhere += " and NameT like N'%" + txtFilterName.Text + "%' ";
             }
             if (Common.StringClass.Check(ddlFilterActive.SelectedValue))
             {
                 strWhere += " and Status = '" + ddlFilterActive.SelectedValue + "' ";
             }
             grdTypeFilm.DataSource = TypeFilmService.TypeFilm_GetByTop("", strWhere, "NameT desc");
             grdTypeFilm.DataBind();
             if (grdTypeFilm.PageCount <= 1)
             {
                 grdTypeFilm.PagerStyle.Visible = false;
             }
         }
     }
     catch (Exception ex)
     {
         WebMsgBox.Show(ex.Message);
     }
 }