Ejemplo n.º 1
0
        public void FillCustomerComboBox()
        {
            DataTable dt = CustomerServiceBL.CustomerDetails.Ins.GetAllCustomerData();

            DevExpress.Web.ASPxEditors.ListEditItem item = new DevExpress.Web.ASPxEditors.ListEditItem("Select All", 0);
            CustomerComboBox.DataSource = dt;
            CustomerComboBox.TextField  = "Name";
            CustomerComboBox.ValueField = "ID";
            CustomerComboBox.DataBind();
            CustomerComboBox.Items.Insert(0, item);
            CustomerComboBox.SelectedIndex = 0;
            //FillNotesGrid();
        }
    //end bind dll archive

    protected void bind_combos()
    {
        //company if company is not -1 (WWI employee)
        if (Session["user"] != null)
        {
            Int32 _companyid = (Int32)((UserClass)Page.Session["user"]).CompanyId;
            Int32 _officeid = (Int32)((UserClass)Page.Session["user"]).OfficeId;

            if (_companyid != -1) //bind contacts for this company
            {
                //contact names
                Query _qry = new Query(Tables.ContactTable, "WWIprov").AddWhere("CompanyID", Comparison.Equals, _companyid).ORDER_BY("ContactName", "asc");

                //180811 datareader much faster than loading to datatabble
                //ContactTableCollection _contact = new ContactTableCollection();
                //_contact.LoadAndCloseReader(_qry.ExecuteReader());
                //DataTable _dt = (DataTable)_contact.ToDataTable();
                IDataReader _rd = _qry.ExecuteReader();

                //this.cboName.DataSource = _dt;
                this.cboName.DataSource = _rd;
                this.cboName.ValueField = "ContactID";
                this.cboName.TextField = "ContactName";
                this.cboName.DataBind();
            }
            else //bind users by office instead  
            {
                //Query _qry = new Query(Tables.EmployeesTable, "WWIprov").AddWhere("OfficeID", Comparison.Equals, _officeid).ORDER_BY("Name", "asc");
                //EmployeesTableCollection _employee = new EmployeesTableCollection();
                //_employee.LoadAndCloseReader(_qry.ExecuteReader());
                //DataTable _dt = (DataTable)_employee.ToDataTable();
                //this.cboName.DataSource = _dt;
                //this.cboName.ValueField = "EmployeeID";
                //this.cboName.TextField = "Name";
                //this.cboName.DataBind();
            }

            //does user have any custom reports?
            //Int32 _userid = (Int32)((UserClass)Page.Session["user"]).UserId;
            //Query _qr = new Query(Tables.DbQueryLog, "WWIprov").AddWhere("by_contactID", Comparison.Equals, _userid).AddWhere("qry_source", Comparison.Equals, "OTR").ORDER_BY("qry_id", "desc");
            //DbQueryLogCollection _reports = new DbQueryLogCollection();
            //_reports.LoadAndCloseReader(_qr.ExecuteReader());
            //DataTable _dtb = (DataTable)_reports.ToDataTable();
            //this.cboName.DataSource = _dtb;
            //this.cboName.ValueField = "qry_text";
            //this.cboName.TextField = "qry_desc";
            //this.cboName.DataBind();


            //11/03/2011 append ALL USERS option as 1st item in dropdown
            //Code here to populate DropDownList
            DevExpress.Web.ASPxEditors.ListEditItem _li = new DevExpress.Web.ASPxEditors.ListEditItem("(All users)", "-1");
            this.cboName.Items.Insert(0, _li);
            //default to all users
            this.cboName.SelectedIndex = 0;

            //250112 bind quick filter fields if user is logged in or not
            this.ObjectDataSourceFields.SelectMethod = "FetchByActive";
            this.ObjectDataSourceFields.DataBind();
        }
        else
        {
            //250112 bind quick filter fields if user is logged in or not
            this.ObjectDataSourceFields.SelectMethod = "FetchByActiveAnonymous";
            this.ObjectDataSourceFields.DataBind();
        }

        //291111 set a default option for the exporter
        //don't need code just set Selected to true for the item you want
    }