/// <summary>
    /// this code is used with LinqServerModeDataSource_Selecting so we can run in server mode
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void linqservermodesearch_Selecting(object sender, DevExpress.Data.Linq.LinqServerModeDataSourceSelectEventArgs e)
    {
        ParameterCollection _params = new ParameterCollection();

        if (Session["user"] != null)
        {
            UserClass _thisuser = (UserClass)Session["user"];
            Int32 _cid = _thisuser.CompanyId;
            Int32 _uid = _thisuser.UserId; 
            Parameter _p = new Parameter();

            //dynamic queries using system.Linq.dynamic + Dynamic.cs library
            e.KeyExpression = "cargoupdateid"; //a key expression is required 


            if (_cid != -1) //external company not WWI so search in by company id
            {
                //var _query = new linq_classesDataContext().view_orders.Where(_filter);
                var _nquery = new linq.Linq_Classes_CargoDataContext().view_cargo_updates.Where(c => c.companyid == _cid);
                //_count = _query.Count();
                e.QueryableSource = _nquery;
            }
            else //search in byemployeeid
            {
                //var _query = new linq_classesDataContext().view_orders.Where(_filter);
                var _nquery = new linq.Linq_Classes_CargoDataContext().view_cargo_updates.Where(c => c.userid == _uid);
                //_count = _query.Count();
                e.QueryableSource = _nquery;
            }

        }
        else
        {
            e.KeyExpression = "cargoupdateid"; //a key expression is required 

            //var _query = new linq_classesDataContext().view_orders.Where(_filter);
            var _nquery = new linq.Linq_Classes_CargoDataContext().view_cargo_updates.Where(c => c.cargoupdateid == 0);
            //_count = _query.Count();
            e.QueryableSource = _nquery;
        }
    }//end linq server mode
Пример #2
0
    /// <summary>
    /// this code is used with LinqServerModeDataSource_Selecting so we can run in server mode
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void linqservermodesearch_Selecting(object sender, DevExpress.Data.Linq.LinqServerModeDataSourceSelectEventArgs e)
    {
        ParameterCollection _params = new ParameterCollection();

        if (Session["user"] != null)
        {
            UserClass _thisuser = (UserClass)Session["user"];
            Int32     _cid      = _thisuser.CompanyId;
            Int32     _uid      = _thisuser.UserId;
            Parameter _p        = new Parameter();

            //dynamic queries using system.Linq.dynamic + Dynamic.cs library
            e.KeyExpression = "cargoupdateid"; //a key expression is required


            if (_cid != -1) //external company not WWI so search in by company id
            {
                //var _query = new linq_classesDataContext().view_orders.Where(_filter);
                var _nquery = new linq.Linq_Classes_CargoDataContext().view_cargo_updates.Where(c => c.companyid == _cid);
                //_count = _query.Count();
                e.QueryableSource = _nquery;
            }
            else //search in byemployeeid
            {
                //var _query = new linq_classesDataContext().view_orders.Where(_filter);
                var _nquery = new linq.Linq_Classes_CargoDataContext().view_cargo_updates.Where(c => c.userid == _uid);
                //_count = _query.Count();
                e.QueryableSource = _nquery;
            }
        }
        else
        {
            e.KeyExpression = "cargoupdateid"; //a key expression is required

            //var _query = new linq_classesDataContext().view_orders.Where(_filter);
            var _nquery = new linq.Linq_Classes_CargoDataContext().view_cargo_updates.Where(c => c.cargoupdateid == 0);
            //_count = _query.Count();
            e.QueryableSource = _nquery;
        }
    }//end linq server mode