/// <summary>
        /// 初始化
        /// </summary>
        /// <returns>成功 1 失败 -1</returns>
        protected int Init()
        {
            #region 加载XML配置
            OpenSpread();
            #endregion
            #region 默认时间设置成当前时间到当前时间前一个月的时间
            this.dtpBeginTime.Value = this.dataBaseManager.GetDateTimeFromSysDateTime().AddMonths(-1);
            this.dtpEndTime.Value   = this.dataBaseManager.GetDateTimeFromSysDateTime();
            #endregion

            #region 清空数据表格
            if (SvMain.RowCount > this.DataBeginRowIndex + 1)
            {
                SvMain.ClearRange(this.DataBeginRowIndex + 1, 0, SvMain.Rows.Count - 1, SvMain.Columns.Count - 1, false);
            }
            #endregion

            this.OnDrawTree();

            if (this.tvLeft != null)
            {
                if (this.tvLeft.Nodes.Count > 0)
                {
                    this.tvLeft.Select();
                    this.tvLeft.SelectedNode = this.tvLeft.Nodes[0];
                }
            }
            //this.neuSpread1.CellClick += new FarPoint.Win.Spread.CellClickEventHandler(neuSpread1_CellClick);
            this.neuSpread1.SelectionChanged += new FarPoint.Win.Spread.SelectionChangedEventHandler(neuSpread1_SelectionChanged);
            this.SetTitle();
            return(1);
        }
 /// <summary>
 /// 设置数据窗口Title名称
 /// </summary>
 protected virtual void SetTitle()
 {
     if (this.SvMain != null)
     {
         if (this.HospitalName != string.Empty)
         {
             try
             {
                 // SvMain.Cells["{title}"].Text = HospitalName + SvMain.Cells["{title}"].Text;
                 FarPoint.Win.Spread.Cell c = null;
                 string CellText            = string.Empty;
                 c = SvMain.GetCellFromTag(c, "{hospitalName}");
                 if (c != null)
                 {
                     CellText = c.Note;
                     CellText = CellText.Replace("{hospitalName}", HospitalName);
                     c.Text   = CellText;
                 }
             }
             catch { }
         }
     }
 }
 protected virtual void OnSort()
 {
     //点的是标题行
     if (this.SvMain.ActiveRowIndex == this.dataBeginRowIndex - 1)
     {
         //点的是标题列
         if (this.SvMain.ActiveColumnIndex <= this.dataBeginColumnIndex + this.dataDisplayColumns.Length - 1 && this.SvMain.ActiveColumnIndex >= this.dataBeginColumnIndex)
         {
             //新建排序条件
             FarPoint.Win.Spread.SortInfo[] sort = new FarPoint.Win.Spread.SortInfo[1];
             //遍历标题列取原排序条件
             for (int i = dataBeginColumnIndex; i < this.dataDisplayColumns.Length; i++)
             {
                 bool ascending = true;
                 if (i == this.SvMain.ActiveColumnIndex)
                 {
                     //没有“↑”号就是升序
                     if (SvMain.Cells[this.dataBeginRowIndex - 1, i].Text.IndexOf("▽") < 0)
                     {
                         //
                         SvMain.Cells[this.dataBeginRowIndex - 1, i].Text = SvMain.Cells[this.dataBeginRowIndex - 1, i].Text.Replace("△", "");
                         ascending = false;
                         SvMain.Cells[this.dataBeginRowIndex - 1, i].Text = SvMain.Cells[this.dataBeginRowIndex - 1, i].Text + "▽";
                     }
                     else
                     {
                         //
                         SvMain.Cells[this.dataBeginRowIndex - 1, i].Text = SvMain.Cells[this.dataBeginRowIndex - 1, i].Text.Replace("▽", "");
                         ascending = true;
                         SvMain.Cells[this.dataBeginRowIndex - 1, i].Text = SvMain.Cells[this.dataBeginRowIndex - 1, i].Text + "△";
                     }
                     //生成排序信息
                     sort[0] = new FarPoint.Win.Spread.SortInfo(i, ascending, System.Collections.Comparer.Default);
                 }
                 else
                 {
                     //没有“↑”号就是升序
                     if (SvMain.Cells[this.dataBeginRowIndex - 1, i].Text.IndexOf("▽") < 0)
                     {
                         SvMain.Cells[this.dataBeginRowIndex - 1, i].Text = SvMain.Cells[this.dataBeginRowIndex - 1, i].Text.Replace("△", "");
                         //ascending = false;
                         //SvMain.Cells[this.dataBeginRowIndex, i].Text = SvMain.Cells[this.dataBeginRowIndex, i].Text + "△";
                     }
                     else
                     {
                         SvMain.Cells[this.dataBeginRowIndex - 1, i].Text = SvMain.Cells[this.dataBeginRowIndex - 1, i].Text.Replace("▽", "");
                         //ascending = true;
                         //SvMain.Cells[this.dataBeginRowIndex, i].Text = SvMain.Cells[this.dataBeginRowIndex, i].Text + "▽";
                     }
                 }
                 //生成排序信息
                 //sort[i] = new FarPoint.Win.Spread.SortInfo(i, ascending, System.Collections.Comparer.Default);
             }
             ////新建排序条件
             //FarPoint.Win.Spread.SortInfo[] sort = new FarPoint.Win.Spread.SortInfo[this.dataDisplayColumns.Length];
             ////遍历标题列取原排序条件
             //for (int i = 0; i < this.dataDisplayColumns.Length; i++)
             //{
             //    bool ascending = true;
             //    if (i == this.SvMain.ActiveColumnIndex )
             //    {
             //        //没有“↑”号就是升序
             //        if (SvMain.Cells[this.dataBeginRowIndex, i].Text.IndexOf("▽") < 0)
             //        {
             //            //
             //            SvMain.Cells[this.dataBeginRowIndex, i].Text = SvMain.Cells[this.dataBeginRowIndex, i].Text.Replace("△", "");
             //            ascending = false;
             //            SvMain.Cells[this.dataBeginRowIndex, i].Text = SvMain.Cells[this.dataBeginRowIndex, i].Text + "▽";
             //        }
             //        else
             //        {
             //            //
             //            SvMain.Cells[this.dataBeginRowIndex, i].Text = SvMain.Cells[this.dataBeginRowIndex, i].Text.Replace("▽", "");
             //            ascending = true;
             //            SvMain.Cells[this.dataBeginRowIndex, i].Text = SvMain.Cells[this.dataBeginRowIndex, i].Text + "△";
             //        }
             //    }
             //    else
             //    {
             //        //没有“↑”号就是升序
             //        if (SvMain.Cells[this.dataBeginRowIndex, i].Text.IndexOf("▽") <0)
             //        {
             //            SvMain.Cells[this.dataBeginRowIndex, i].Text = SvMain.Cells[this.dataBeginRowIndex, i].Text.Replace("△", "");
             //            ascending = false;
             //            SvMain.Cells[this.dataBeginRowIndex, i].Text = SvMain.Cells[this.dataBeginRowIndex, i].Text + "△";
             //        }
             //        else
             //        {
             //            SvMain.Cells[this.dataBeginRowIndex, i].Text = SvMain.Cells[this.dataBeginRowIndex, i].Text.Replace("▽", "");
             //            ascending = true;
             //            SvMain.Cells[this.dataBeginRowIndex, i].Text = SvMain.Cells[this.dataBeginRowIndex, i].Text + "▽";
             //        }
             //    }
             //    //生成排序信息
             //    sort[i] = new FarPoint.Win.Spread.SortInfo(i, ascending,System.Collections.Comparer.Default );
             //}
             SvMain.SortRange(this.dataBeginRowIndex, this.dataBeginColumnIndex, this.dataRowCount, this.dataDisplayColumns.Length, true, sort);
         }
     }
 }
        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="neuObject"></param>
        /// <returns></returns>
        protected override int OnQuery(object sender, object neuObject)
        {
            //int rtnVal = -1;
            Cursor = Cursors.WaitCursor;

            Neusoft.FrameWork.WinForms.Classes.Function.ShowWaitForm("正在查询数据,请等待....");

            Application.DoEvents();

            #region 清空数据表格
            if (SvMain.RowCount >= this.dataBeginRowIndex + 1)
            {
                SvMain.ClearRange(this.dataBeginRowIndex, dataBeginColumnIndex, SvMain.Rows.Count - this.dataBeginRowIndex + 1, this.dataDisplayColumns.Length, false);
            }
            #endregion
            #region 参数替换
            FarPoint.Win.Spread.Cell c = null;
            for (int j = 0; j < this.useParamCellsCount; j++)
            {
                string CellText = string.Empty;
                c = SvMain.GetCellFromTag(c, "{QueryParams}");
                if (c != null)
                {
                    CellText = c.Note;
                    for (int i = 0; i < this.QueryParams.Count; i++)
                    {
                        CellText = CellText.Replace("{" + i + "}", this.QueryParams[i].ToString());
                    }
                    c.Text = CellText;
                }
            }
            #endregion
            #region 显示到表格
            DataTable dt = new DataTable();
            dataRowCount = 0;
            switch (this.QuerySqlTypeValue)
            {
            case QuerySqlType.id:
                if (Db.QueryDataBySqlId(this.QuerySql, ref dt, this.QueryParams) != 1)
                {
                    Cursor = Cursors.Arrow;
                    Neusoft.FrameWork.WinForms.Classes.Function.HideWaitForm();
                    return(-1);
                }
                break;

            case QuerySqlType.text:
                if (Db.QueryDataBySql(this.QuerySql, ref dt, this.QueryParams) != 1)
                {
                    Cursor = Cursors.Arrow;
                    Neusoft.FrameWork.WinForms.Classes.Function.HideWaitForm();
                    return(-1);
                }
                break;

            default:
                break;
            }
            #region 清空排序状态
            if (this.dataBeginColumnIndex > 0 || this.dataBeginRowIndex > 0)
            {
                //遍历标题列取原排序条件
                for (int i = dataBeginColumnIndex; i < this.dataDisplayColumns.Length; i++)
                {
                    //没有“↑”号就是升序
                    if (SvMain.Cells[this.dataBeginRowIndex - 1, i].Text.IndexOf("△") >= 0)
                    {
                        //
                        SvMain.Cells[this.dataBeginRowIndex - 1, i].Text = SvMain.Cells[this.dataBeginRowIndex - 1, i].Text.Replace("△", "");
                    }
                    //没有“↑”号就是升序
                    if (SvMain.Cells[this.dataBeginRowIndex - 1, i].Text.IndexOf("▽") >= 0)
                    {
                        //
                        SvMain.Cells[this.dataBeginRowIndex - 1, i].Text = SvMain.Cells[this.dataBeginRowIndex - 1, i].Text.Replace("▽", "");
                    }
                }
            }
            #endregion
            DataSetHelper dsh      = new DataSetHelper();
            DataTable     dtValues = dsh.SelectIntoByIndex(string.Empty, dt, dataDisplayColumns, string.Empty, string.Empty);
            this.dataRowCount = dtValues.Rows.Count;
            #region 设置表格列数
            //this.SvMain.ColumnCount = dataDisplayColumns.Length ;
            if (this.SvMain.Rows.Count < DataBeginRowIndex + dt.Rows.Count)
            {
                this.SvMain.RowCount = DataBeginRowIndex + dt.Rows.Count;
            }

            #endregion
            #region 逐个单元格填充数据
            Function.DisplayToFp(SvMain, dtValues, DataBeginRowIndex, DataBeginColumnIndex);
            //foreach (DataRow dr in dt.Rows)
            //{
            //    foreach (DataColumn dc in dt.Columns)
            //    {
            //        if (Array.IndexOf(dataDisplayColumns,dt.Columns.IndexOf(dc).ToString())>=0)
            //        {
            //            SvMain.Cells[dt.Rows.IndexOf(dr) + 1 + DataBeginRowIndex, Array.IndexOf(dataDisplayColumns, dt.Columns.IndexOf(dc).ToString())].Text = dr[dt.Columns.IndexOf(dc)].ToString();
            //        }

            //    }
            //}
            #endregion

            #endregion

            #region 设置分页符
            if (this.rowPageBreak > 0)
            {
                for (int i = 0; i < this.SvMain.Rows.Count; i = ((i + 1) * this.rowPageBreak + this.DataBeginRowIndex))
                {
                    this.SvMain.SetRowPageBreak((i * this.rowPageBreak + this.DataBeginRowIndex), true);
                }
            }
            #endregion

            Function.DrawGridLine(SvMain, this.dataBeginRowIndex, this.dataBeginColumnIndex, dtValues.Rows.Count, dtValues.Columns.Count);
            Neusoft.FrameWork.WinForms.Classes.Function.HideWaitForm();

            Cursor = Cursors.Arrow;

            return(1);
        }