Exemple #1
0
 protected void grdFilm_ItemCommand(object source, DataGridCommandEventArgs e)
 {
     try
     {
         string strCa    = e.CommandArgument.ToString();
         string strWhere = " 1=1 ";
         if (e.CommandName == "Edit")
         {
             _insert = false;
             DataTable dt = FilmService.Film_GetById(strCa);
             ddlCouId_Update.SelectedValue = dt.Rows[0]["CouId"].ToString();
             ddlTypId_Update.SelectedValue = dt.Rows[0]["TypId"].ToString();
             txtId.Value                = dt.Rows[0]["FilId"].ToString();
             txtName.Text               = dt.Rows[0]["NameF"].ToString();
             txtDirector.Text           = dt.Rows[0]["Director"].ToString();
             txtActor.Text              = dt.Rows[0]["Actor"].ToString();
             txtDuration.Text           = dt.Rows[0]["Duration"].ToString();
             imgImage.ImageUrl          = dt.Rows[0]["Picture"].ToString();
             imgImageBig.ImageUrl       = dt.Rows[0]["PictureBig"].ToString();
             txtPicture.Text            = dt.Rows[0]["Picture"].ToString();
             txtPictureBig.Text         = dt.Rows[0]["PictureBig"].ToString();
             FCKeditorDescription.Value = dt.Rows[0]["Description"].ToString();
             FCKeditorDetail.Value      = dt.Rows[0]["Detail"].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")
         {
             FilmService.Film_Delete(strCa);
             BindGrid();
         }
         if (e.CommandName == "Status")
         {
             string strA = "";
             string str  = e.Item.Cells[2].Text;
             strA = str == "1" ? "0" : "1";
             FilmService.Film_Update_Status(strCa, strA);
             BindGrid();
         }
         if (e.CommandName == "ascFilm")
         {
             if (Common.StringClass.Check(ddlFilterypeFilm.SelectedValue))
             {
                 strWhere += " and TypId = '" + ddlFilterypeFilm.SelectedValue + "' ";
             }
             if (Common.StringClass.Check(ddlFilterCountry.SelectedValue))
             {
                 strWhere += " and CouId = '" + ddlFilterCountry.SelectedValue + "' ";
             }
             if (Common.StringClass.Check(txtFilterName.Text))
             {
                 strWhere += " and NameF like N'%" + txtFilterName.Text + "%' ";
             }
             if (Common.StringClass.Check(ddlFilterActive.SelectedValue))
             {
                 strWhere += " and Status = '" + ddlFilterActive.SelectedValue + "' ";
             }
             grdFilm.DataSource = FilmService.Film_GetByTop("", strWhere, "NameF");
             grdFilm.DataBind();
             if (grdFilm.PageCount <= 1)
             {
                 grdFilm.PagerStyle.Visible = false;
             }
         }
         if (e.CommandName == "descFilm")
         {
             if (Common.StringClass.Check(ddlFilterypeFilm.SelectedValue))
             {
                 strWhere += " and TypId = '" + ddlFilterypeFilm.SelectedValue + "' ";
             }
             if (Common.StringClass.Check(ddlFilterCountry.SelectedValue))
             {
                 strWhere += " and CouId = '" + ddlFilterCountry.SelectedValue + "' ";
             }
             if (Common.StringClass.Check(txtFilterName.Text))
             {
                 strWhere += " and NameF like N'%" + txtFilterName.Text + "%' ";
             }
             if (Common.StringClass.Check(ddlFilterActive.SelectedValue))
             {
                 strWhere += " and Status = '" + ddlFilterActive.SelectedValue + "' ";
             }
             grdFilm.DataSource = FilmService.Film_GetByTop("", strWhere, "NameF desc");
             grdFilm.DataBind();
             if (grdFilm.PageCount <= 1)
             {
                 grdFilm.PagerStyle.Visible = false;
             }
         }
     }
     catch (Exception ex)
     {
         WebMsgBox.Show(ex.Message);
     }
 }