Exemplo n.º 1
0
        private void RefreshCooperatorList()
        {
            DataSet ds          = new DataSet();
            string  findText    = "";
            string  searchPKeys = "";

            // First get the cooperator_ids for the orginal search criteria (_originalPKeys)...
            ds          = _sharedUtils.GetWebServiceData("get_cooperator", _originalPKeys, 0, 0);
            searchPKeys = ":cooperatorid=";
            if (ds.Tables.Contains("get_cooperator"))
            {
                foreach (DataRow dr in ds.Tables["get_cooperator"].Rows)
                {
                    searchPKeys += dr["cooperator_id"].ToString() + ",";
                }
            }

            // Now get the cooperator_ids from the local LU table that match the lastname and first name...
            if (!string.IsNullOrEmpty(ux_textboxLastName.Text))
            {
                findText += ux_textboxLastName.Text + "%";
            }
            if (!string.IsNullOrEmpty(ux_textboxFirstName.Text))
            {
                findText += ux_textboxFirstName.Text + "%";
            }
            if (!string.IsNullOrEmpty(findText))
            {
                DataTable dt = new DataTable();

                dt = _sharedUtils.LookupTablesGetMatchingRows("cooperator_lookup", findText, 1000);
                foreach (DataRow dr in dt.Rows)
                {
                    searchPKeys += dr["value_member"].ToString() + ",";
                }
            }

            // Remove the last trailing comma...
            searchPKeys = searchPKeys.TrimEnd(',');

            // Finally go get the full collection of cooperator_ids...
            ds = _sharedUtils.GetWebServiceData("get_cooperator", searchPKeys, 0, 0);
            if (ds.Tables.Contains("get_cooperator"))
            {
                _cooperator = ds.Tables["get_cooperator"].Copy();
            }
            else if (_cooperator == null)
            {
                _cooperator = new DataTable();
            }
            // And then update the binding source's data...
            _cooperatorBindingSource.DataSource = _cooperator;
        }