/// <summary> /// this code is used with LinqServerModePricer_Selecting so we can run in server mode /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void LinqServerModePricer_Selecting(object sender, DevExpress.Data.Linq.LinqServerModeDataSourceSelectEventArgs e) { //get user id to limit result set if (Session["user"] != null) { UserClass _thisuser = (UserClass)Session["user"]; Int32 _uid = _thisuser.UserId; Int32 _cid = _thisuser.CompanyId; //dynamic queries using system.Linq.dynamic + Dynamic.cs library e.KeyExpression = "quote_Id"; //a key expression is required if (_uid != 0 && _cid != 0) { var _nquery = new linq.linq_pricer_view1DataContext().view_price_clients.Where( c => c.request_date.GetValueOrDefault().Date == DateTime.Today && c.client_visible == true && c.request_user_id == _thisuser.UserId && c.request_company_id == _thisuser.CompanyId ); //c => c.CompanyID == 7 e.QueryableSource = _nquery; //Int32 _count = _nquery.Count(); } } else //default to display nothing in grid { e.KeyExpression = "quote_Id"; //a key expression is required var _nquery = new linq.linq_pricer_view1DataContext().view_price_clients.Where(c => c.quote_Id == -1); //_count = _nquery.Count(); e.QueryableSource = _nquery; } }//end linq server mode
/// <summary> /// this code is used with LinqServerModePricer_Selecting so we can run in server mode /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void LinqServerModePricer_Selecting(object sender, DevExpress.Data.Linq.LinqServerModeDataSourceSelectEventArgs e) { if (Session["user"] != null) { string _query = ""; string _mode = this.dxhfMethod.Contains("mode") ? this.dxhfMethod["mode"].ToString() : "0"; //only 0 or 1 (quick search) UserClass _thisuser = (UserClass)Session["user"]; ParameterCollection _params = new ParameterCollection(); //check quick search parameters if (_mode == "1") { _query = get_filter(); } //company id if (this.dxcbocompany.Value != null && this.dxcbocompany.Value.ToString() != "") { _params.Add("request_company_id", this.dxcbocompany.Value.ToString()); } //now rebuild query with additional parameters if any string _f = ""; if (_params.Count > 0) { foreach (Parameter p in _params) { string _a = _f != "" ? " AND " : ""; _f += _a + "(" + p.Name.ToString() + "==" + p.DefaultValue.ToString() + ")"; } if (_query != "") { _query = _f + " AND " + _query; } else { _query = _f; } } //dynamic queries using system.Linq.dynamic + Dynamic.cs library e.KeyExpression = "quote_Id"; //a key expression is required if (!string.IsNullOrEmpty(_query)) { var _nquery = new linq.linq_pricer_view1DataContext().view_price_clients.Where(_query); //c => c.CompanyID == 7 e.QueryableSource = _nquery; //Int32 _count = _nquery.Count(); } else //default to display nothing in grid { var _nquery = new linq.linq_pricer_view1DataContext().view_price_clients.Where(c => c.quote_Id == -1); //_count = _nquery.Count(); e.QueryableSource = _nquery; } } }//end linq server mode
/// <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 LinqServerModePricerTop_Selecting(object sender, DevExpress.Data.Linq.LinqServerModeDataSourceSelectEventArgs e) { try { Int32 _companyid = -1; //after testing default to empty string Int32 _userid = -1; //company id: always add as a search param as user must be logged in //if (Page.Session["user"] != null) if (Page.Session["user"] != null) { _companyid = (Int32)((UserClass)Page.Session["user"]).CompanyId; _userid = (Int32)((UserClass)Page.Session["user"]).UserId; } //dynamic queries using system.Linq.dynamic + Dynamic.cs library //20/10/2010 we have build a unique index (OrderIx) from OrderId, TitleId, ContainerSubId as usual primary keys are not going to //be unique in the view. aspxgrid only works properly when it has a unique key e.KeyExpression = "quote_Id"; //"OrderID"; //a key expression is required if (_companyid > 0 && _userid > 0) { //var _query = new linq_classesDataContext().view_orders.Where(_filter); var _nquery = new linq.linq_pricer_view1DataContext().view_price_clients.Where(p => p.request_company_id == _companyid && p.request_user_id == _userid && p.client_visible == true).OrderByDescending(p => p.quote_Id).Take(10); //c => c.CompanyID == 7 e.QueryableSource = _nquery; //Int32 _count = _nquery.Count(); } else //they should never reach this as must be logged in to get dashboard but just a precaution { var _nquery = new linq.linq_pricer_view1DataContext().view_price_clients.Where(p => p.client_visible == true).OrderByDescending(p => p.quote_Id).Take(10); //c => c.CompanyID == 7 //var _nquery = new linq_pricer_view1DataContext().view_price_clients.Where(p => p.quote_Id == -1); //_count = _nquery.Count(); e.QueryableSource = _nquery; } } catch (Exception ex) { this.dxlblerr6.Text = ex.Message.ToString(); this.dxlblerr6.Visible = true; } }
/// <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 LinqServerModePricerTop_Selecting(object sender, DevExpress.Data.Linq.LinqServerModeDataSourceSelectEventArgs e) { try { Int32 _companyid = -1; //after testing default to empty string Int32 _userid = -1; //company id: always add as a search param as user must be logged in //if (Page.Session["user"] != null) if (Page.Session["user"] != null) { _companyid = (Int32)((UserClass)Page.Session["user"]).CompanyId; _userid = (Int32)((UserClass)Page.Session["user"]).UserId; } //dynamic queries using system.Linq.dynamic + Dynamic.cs library //20/10/2010 we have build a unique index (OrderIx) from OrderId, TitleId, ContainerSubId as usual primary keys are not going to //be unique in the view. aspxgrid only works properly when it has a unique key e.KeyExpression = "quote_Id"; //"OrderID"; //a key expression is required if (_companyid > 0 && _userid > 0) { //var _query = new linq_classesDataContext().view_orders.Where(_filter); var _nquery = new linq.linq_pricer_view1DataContext().view_price_clients.Where(p => p.request_company_id == _companyid && p.request_user_id == _userid && p.client_visible == true).OrderByDescending(p => p.quote_Id).Take(10); //c => c.CompanyID == 7 e.QueryableSource = _nquery; //Int32 _count = _nquery.Count(); } else //they should never reach this as must be logged in to get dashboard but just a precaution { var _nquery = new linq.linq_pricer_view1DataContext().view_price_clients.Where(p => p.client_visible == true).OrderByDescending(p => p.quote_Id).Take(10); //c => c.CompanyID == 7 //var _nquery = new linq_pricer_view1DataContext().view_price_clients.Where(p => p.quote_Id == -1); //_count = _nquery.Count(); e.QueryableSource = _nquery; } } catch (Exception ex) { this.dxlblerr6.Text = ex.Message.ToString(); this.dxlblerr6.Visible = true; } }
/// <summary> /// this code is used with LinqServerModePricer_Selecting so we can run in server mode /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void LinqServerModePricer_Selecting(object sender, DevExpress.Data.Linq.LinqServerModeDataSourceSelectEventArgs e) { //get user id to limit result set if (Session["user"] != null) { UserClass _thisuser = (UserClass)Session["user"]; Int32 _uid = _thisuser.UserId; Int32 _cid = _thisuser.CompanyId; //dynamic queries using system.Linq.dynamic + Dynamic.cs library e.KeyExpression = "quote_Id"; //a key expression is required if (_uid != 0 && _cid != 0) { var _nquery = new linq.linq_pricer_view1DataContext().view_price_clients.Where( c => c.request_date.GetValueOrDefault().Date == DateTime.Today && c.client_visible == true && c.request_user_id == _thisuser.UserId && c.request_company_id == _thisuser.CompanyId ); //c => c.CompanyID == 7 e.QueryableSource = _nquery; //Int32 _count = _nquery.Count(); } } else //default to display nothing in grid { e.KeyExpression = "quote_Id"; //a key expression is required var _nquery = new linq.linq_pricer_view1DataContext().view_price_clients.Where(c => c.quote_Id == -1); //_count = _nquery.Count(); e.QueryableSource = _nquery; } }//end linq server mode
/// <summary> /// this code is used with LinqServerModePricer_Selecting so we can run in server mode /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void LinqServerModePricer_Selecting(object sender, DevExpress.Data.Linq.LinqServerModeDataSourceSelectEventArgs e) { //get user id to limit result set if (Session["user"] != null) { string _query = ""; string _mode = this.dxhfMethod.Contains("mode") ? this.dxhfMethod["mode"].ToString() : "0"; //only 0 or 1 (quick search) UserClass _thisuser = (UserClass)Session["user"]; Int32 _id = _thisuser.UserId; ParameterCollection _params = new ParameterCollection(); //check quick search parameters if (_mode == "1") { _query = get_filter(); } //020911 only show records where client_visible = true Parameter _p0 = new Parameter(); _p0.Name = "client_visible"; _p0.DefaultValue = true.ToString(); _params.Add(_p0); //check user id Parameter _p1= new Parameter(); _p1.Name = "request_user_id"; _p1.DefaultValue = _thisuser.UserId.ToString(); _params.Add(_p1); //and company id Parameter _p2 = new Parameter(); _p2.Name = "request_company_id"; _p2.DefaultValue = _thisuser.CompanyId.ToString(); _params.Add(_p2); //now rebuild query with additional parameters string _f = ""; if (_params.Count > 0) { foreach (Parameter p in _params) { string _a = _f != "" ? " AND " : ""; _f += _a + "(" + p.Name.ToString() + "==" + p.DefaultValue.ToString() + ")"; } if (_query != "") { _query = _f + " AND " + _query; } else { _query = _f; } } //dynamic queries using system.Linq.dynamic + Dynamic.cs library e.KeyExpression = "quote_Id"; //a key expression is required if (!string.IsNullOrEmpty(_query)) { var _nquery = new linq.linq_pricer_view1DataContext().view_price_clients.Where(_query); //c => c.CompanyID == 7 e.QueryableSource = _nquery; //Int32 _count = _nquery.Count(); } else //default to display nothing in grid { var _nquery = new linq.linq_pricer_view1DataContext().view_price_clients.Where(c => c.quote_Id == -1); //_count = _nquery.Count(); e.QueryableSource = _nquery; } } }//end linq server mode