示例#1
0
 protected void Filter_Click(object sender, EventArgs e)
 {
     try
     {
         string strWhere = " 1=1 ";
         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.CurrentPageIndex = 0;
         grdTypeFilm.DataSource       = TypeFilmService.TypeFilm_GetByTop("", strWhere, "");
         grdTypeFilm.DataBind();
         if (grdTypeFilm.PageCount <= 1)
         {
             grdTypeFilm.PagerStyle.Visible = false;
         }
         else
         {
             grdTypeFilm.PagerStyle.Visible = true;
         }
     }
     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);
     }
 }