private void GetQueryDefinition()
        {
            try
            {
                WorkSpace area = checkStandard.Checked == true ? WorkSpace.StandardArea : WorkSpace.GlobalArea;
                SAPConnection con = new SAPConnection(systemName);

                q = con.CreateQuery(area, userGroup, queryName, variant);
                // parameterCollection = new QuerySelectionParameterCollection();
                parameterCollection = q.SelectionParameters;

                dgvParameters.Rows.Clear();
                DataGridViewComboBoxColumn col = (DataGridViewComboBoxColumn)dgvParameters.Columns["CSELNAME"];
                col.DataSource = null;

                col.DataSource = parameterCollection;
                col.DisplayMember = "DescriptionText";
                q = null;
            }
            catch (Exception e)
            {

                MessageBox.Show(e.Message);
            }
        }
        private void btnCreateIdoc_Click(object sender, EventArgs e)
        {
            m_SapSystemName = this.cboxSystemList1.Text.Trim();
            m_IdocType = this.txtIdocType.Text;
            m_IdocEnhanceMent = this.txtEnhancement.Text;

            if (string.IsNullOrEmpty(m_SapSystemName))
            {
                MessageBox.Show("请选择SAP系统");
                return;
            }
            if (string.IsNullOrEmpty(m_IdocType))
            {
                MessageBox.Show("请选择Idoc类型");
                return;
            }

            SAPConnection connection = new SAPConnection(m_SapSystemName);
            Idoc = connection.CreateIdoc(m_IdocType, m_IdocEnhanceMent);
            IdocToTreeControl();
        }
        private void Excute()
        {
            try
            {

                SAPConnection con = new SAPConnection(systemName);
                q = con.CreateQuery(area, userGroup, queryName, variant);
                q.MaxRows = maxRow;

                foreach (DataGridViewRow row in dgvParameters.Rows)
                {

                    if (row.Cells["CNAME"].Value != null && row.Cells["CSIGN"].Value != null)
                    {
                        Range r = new Range();
                        r.Sign = row.Cells["CSIGN"].Value.ToString() == "I" ? Sign.Include : Sign.Exclude;
                        if (row.Cells["CLOW"].Value != null)
                        {
                            r.LowValue = row.Cells["CLOW"].Value.ToString();
                        }

                        if (row.Cells["CHIGH"].Value != null)
                        {
                            r.HighValue = row.Cells["CHIGH"].Value.ToString();
                        }
                        if (row.Cells["CNAME"].Value != null)
                        {
                            q.SelectionParameters[row.Cells["CNAME"].Value.ToString()].Ranges.Add(r);
                        }

                    }
                }

                q.Excute();

            }
            catch (Exception ee)
            {

                MessageBox.Show(ee.Message);
            }
        }
        private void Excute()
        {
            try
            {
                SAPConnection con = new SAPConnection(systemName);
                q = con.CreateQuery(area, userGroup, queryName, variant);
                q.MaxRows = maxRow;
                foreach (DataGridViewRow row in dgvParameters.Rows)
                {
                    if (row.Cells["CNAME"].Value != null && row.Cells["CSIGN"].Value != null)
                    {
                        Range r = new Range();
                        r.Sign = row.Cells["CSIGN"].Value.ToString() == "I" ? Sign.Include : Sign.Exclude;
                        if (row.Cells["CLOW"].Value != null)
                        {
                            r.LowValue = row.Cells["CLOW"].Value.ToString();
                        }
                        if (row.Cells["CHIGH"].Value != null)
                        {
                            r.HighValue = row.Cells["CHIGH"].Value.ToString();
                        }
                        if (row.Cells["CNAME"].Value != null)
                        {
                            q.SelectionParameters[row.Cells["CNAME"].Value.ToString()].Ranges.Add(r);
                        }
                    }
                }
                q.Excute();
               // DataTable dt = q.Result;
                eventQueryExuteDone(q.Result);
                //Worksheet ws;          //当前工作表。
                ////在当前激活的工作表上存放数据
                //ws = Globals.Factory.GetVstoObject(Globals.ThisAddIn.Application.ActiveWorkbook.ActiveSheet);
                //ListObject ls;
                //if (!ws.Controls.Contains(queryName))
                //{
                //    int count = ws.ListObjects.Count;
                //    for (int i = 1; i < count + 1; i++)
                //    {
                //        if (ws.ListObjects[i].Name == queryName)
                //        {
                //            ws.ListObjects[i].Delete();
                //            // ws.Controls.Remove(_tableName);
                //        }
                //    }
                //    ls = ws.Controls.AddListObject(ws.Range["A2"], queryName);
                //}
                //else
                //{
                //    ls = (ListObject)ws.Controls[queryName];
                //}
                //ls.SetDataBinding(q.Result);

                //for (int i = 0; i < q.Fields.Count; i++)
                //{
                //    ls.ListColumns[i + 1].Name = q.Fields[i].Name;
                //    ws.Cells.set_Item(1,i+1,q.Fields[i].Description);
                //}
                //ws.Columns.AutoFit();
                //ws.Columns.ShrinkToFit = true;
                //ws.Name = queryName;
                MessageBox.Show("加载完成");
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
        }