示例#1
0
    //incremental filtering for large datasets on combos
    /// <summary>
    /// incremental filtering and partial loading of vessels for speed
    /// both ItemsRequestedByFilterCondition and ItemRequestedByValue must be set up for this to work
    /// </summary>
    /// <param name="source"></param>
    /// <param name="e"></param>
    protected void dxcbocompany_ItemsRequestedByFilterCondition(object source, DevExpress.Web.ASPxEditors.ListEditItemsRequestedByFilterConditionEventArgs e)
    {
        ASPxComboBox _combo = (ASPxComboBox)source;

        //if (Page.Session["user"] != null) //if publiship user allow filter to be used otherwise filter null
        //{
        //    Int32 _companyid = wwi_func.vint(((UserClass)Page.Session["user"]).CompanyId.ToString());
        //    if (_companyid == -1)
        //    {
        string _filter = !string.IsNullOrEmpty(e.Filter) ? e.Filter : "";

        //use datareaders - much faster than loading into collections
        string[] _cols = { "CompanyID, CompanyName", "Address1", "Address2", "Address3", "CountryName", "TelNo", "Customer", "CountryID" };

        //SubSonic.SqlQuery _query = DAL.Logistics.DB.Select(_cols).From(DAL.Logistics.Tables.NameAndAddressBook).Paged(e.BeginIndex + 1, e.EndIndex + 1, "CompanyID").WhereExpression("CompanyName").Like(string.Format("%{0}%", e.Filter.ToString()));
        SubSonic.SqlQuery _query = DAL.Logistics.DB.Select(_cols).From("view_delivery_address").Paged(e.BeginIndex + 1, e.EndIndex + 1, "CompanyID").WhereExpression("CompanyName").Like(string.Format("{0}%", e.Filter.ToString()));


        switch (_combo.ID)
        {
        case "dxcboClearingAgentIDEdit":
        {
            int[] _vals = { 3, 6 };
            _query.And("TypeID").In(_vals);
            break;
        }

        case "dxcboOnCarriageIDEdit":
        {
            _query.And("TypeID").IsEqualTo(3);
            break;
        }

        case "dxcboAgentAtDestinationIDEdit":
        {
            _query.And("TypeID").IsEqualTo(3);
            break;
        }

        default:
        {
            break;
        }
        }

        IDataReader _rd = _query.ExecuteReader();

        _combo.DataSource = _rd;
        _combo.ValueField = "CompanyID";
        _combo.ValueType  = typeof(int);
        _combo.TextField  = "CompanyName";
        _combo.DataBindItems();
        //    }
        //}
    }
示例#2
0
    protected void dxcboVesselID_ItemsRequestedByFilterCondition(object source, ListEditItemsRequestedByFilterConditionEventArgs e)
    {
        DevExpress.Web.ASPxEditors.ASPxComboBox _combo = (DevExpress.Web.ASPxEditors.ASPxComboBox)source;

        string _filter = !string.IsNullOrEmpty(e.Filter) ? e.Filter : "";

        //use datareaders - much faster than loading into collections
        string[] _cols = { "VoyageID", "Joined", "ETS", "ETA", "DestinationPortID", "OriginPortID" };
        string[] _sort = { "Joined" };

        //additional filters on this dll
        string _originportid = ""; //get_token("pstart").ToString();
        string _destportid   = ""; //get_token("pend").ToString();

        ASPxComboBox _cbo = (ASPxComboBox)this.fmvBol.FindControl("dxcboOriginPort");

        if (_cbo != null && _cbo.SelectedItem != null)
        {
            _originportid = _cbo.SelectedItem.Value.ToString();
        }

        _cbo = (ASPxComboBox)this.fmvBol.FindControl("dxcboDestinationPort");
        if (_cbo != null && _cbo.SelectedItem != null)
        {
            _destportid = _cbo.SelectedItem.Value.ToString();
        }

        //
        //SubSonic.SqlQuery _query = DAL.Logistics.DB.Select(_cols).From(DAL.Logistics.Tables.NameAndAddressBook).Paged(e.BeginIndex + 1, e.EndIndex + 1, "CompanyID").WhereExpression("CompanyName").Like(string.Format("%{0}%", e.Filter.ToString()));
        SubSonic.SqlQuery _query = DAL.Logistics.DB.Select(_cols).From("Page2VesselView").Paged(e.BeginIndex + 1, e.EndIndex + 1, "VoyageID").Where("Joined").Like(string.Format("{0}%", e.Filter.ToString()));

        if (_originportid != "" && _destportid != "")
        {
            _query.And("DestinationPortID").IsEqualTo(_destportid).And("OriginPortID").IsEqualTo(_originportid).OrderAsc(_sort);
        }

        string test = _query.ToString();

        IDataReader _rd = _query.ExecuteReader();

        _combo.DataSource = _rd;
        _combo.ValueField = "VoyageID";
        _combo.TextField  = "Joined";
        _combo.DataBindItems();
    }