/// <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 { } } } }
/// <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); }