示例#1
0
        void grdFilters_ItemCommand(object source, GridCommandEventArgs e)
        {
            int filterID = int.Parse(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["FilterId"].ToString());

            Entities.CustomPrincipal principal = (Entities.CustomPrincipal)Page.User;

            switch (e.CommandName.ToLower())
            {
            case "setdefault":
                using (Facade.ITrafficSheetFilter facTrafficSheetFilter = new Facade.Traffic())
                    facTrafficSheetFilter.SetDefault(filterID, principal.IdentityId, principal.UserName);
                grdFilters.Rebind();
                break;

            case "switchactivity":
                GridDataItem gdi      = e.Item as GridDataItem;
                bool         isActive = (gdi["IsActive"] as TableCell).Text == "Yes" ? true : false;

                using (Facade.ITrafficSheetFilter facTrafficSheetFilter = new Facade.Traffic())
                    if (isActive)
                    {
                        facTrafficSheetFilter.Deactivate(filterID, principal.UserName);
                    }
                    else if (e.Item.Cells[5].Text.ToLower() == "no")
                    {
                        facTrafficSheetFilter.Activate(filterID, principal.UserName);
                    }
                grdFilters.Rebind();

                break;
            }
        }