⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fselect.cs

📁 基于C/S的医疗卫生管理系统
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using Sybase.DataWindow;
using Qeb.DBProxy;
using Qeb.Support;
using Qeb.Support.Common;
using Qeb.Control;

namespace Qeb.Control
{
    public partial class FSelect : Qeb.Control.FBase
    {
        private int m_MaxPage = 4;
        private int m_PageCount = 0;
        private int m_CurrentPage = 1;
        private int m_PageRowCount = 9;
        private bool m_IsExisteWhere = true;
        private int m_DataRowCount = 0;

        private DataTable m_ShowColumn = new DataTable();
        private ArrayList m_ReturnCol = new ArrayList();
        private string[] m_ReturnValue = null;

        private QDataStore m_DsData = null;
        private string m_SourceSQL = "";
        public FSelect()
        {
            InitializeComponent();
            this.Init();
        }

        public void Init()
        {           
            #region Create Table
            m_ShowColumn.CaseSensitive = false;
            m_ShowColumn.Columns.Add("colName", typeof(string));
            m_ShowColumn.Columns.Add("colTitle", typeof(string));
            m_ShowColumn.Columns.Add("colWidth", typeof(int));
            #endregion
        }

        public void SetDataSource(IDataWindowBase data)
        {
           //m_DsData = ??
            //待完成
        }

        /// <summary>
        /// 设置数据源
        /// </summary>
        /// <param name="sql">SQL语句</param>
        /// <param name="isExisteWhere">是否已有WHERE条件</param>
        public void SetDataSource(string sql,bool isExisteWhere)
        {
            m_SourceSQL = sql;
            m_IsExisteWhere = isExisteWhere;
        }

        #region 设置标题
        public void SetTitle(string title)
        {
            this.Text = title + " 按Esc键取消";
        }
        #endregion

        #region 增加显示列
        public void AddShowColumn(string colName, string colTitle, int width)
        {
            DataRow dr = m_ShowColumn.NewRow();
            dr["colName"] = colName.ToLower();
            dr["colTitle"] = colTitle;
            dr["colWidth"] = width;
            m_ShowColumn.Rows.Add(dr);
        }

        /// <summary>
        /// 用","分开
        /// </summary>
        /// <param name="colName"></param>
        /// <param name="colTitle"></param>
        /// <param name="width"></param>
        public void AddMultiShowColumn(string colName, string colTitle, int[] width)
        {
            string[] name = colName.Split(new char[] { ',' });
            string[] title = colTitle.Split(new char[] { ',' });
            if (name.Length != title.Length)
            {
                throw new Exception("显示列个数与显示列标题个数不匹配!");
            }
            if (name.Length != width.Length)
            {
                throw new Exception("显示列个数与显示列宽度个数不匹配!");
            }

            for (int i = 0; i < colName.Length; i++)
            {
                this.AddShowColumn(name[i], " "+title[i], width[i]);
            }
        }
        #endregion

        #region 增加返回列
        public void AddReturnColumn(string colName)
        {
            m_ReturnCol.Add(colName);
        }

        /// <summary>
        /// 用","分开
        /// </summary>
        /// <param name="colName"></param>
        public void AddMultiReturnColumn(string colName)
        {
            string[] name = colName.Split(new char[] { ',' });
            for (int i = 0; i < name.Length; i++)
            {
                AddReturnColumn(name[i]);
            }
        }
        #endregion


        public string[] ReturnValue
        {
            get { return m_ReturnValue; }
        }

        /// <summary>
        /// 0 ~ 30
        /// </summary>        
        public int MaxPage
        {
            get { return m_MaxPage; }
            set
            {
                if (m_MaxPage > 0 && m_MaxPage < 30)
                    m_MaxPage = value;
            }
        }

        #region 创建数据窗口
        private void CreateDW()
        {
            dwSelect.DataWindowObject = "qq";

            dwSelect.Create(m_DsData.Syntax);
            dwSelect.InitUI();

            m_DsData.ShareData(dwSelect);
        }
        #endregion

        #region InistDs
        private void InitDS()
        {
            string sql = "";
            if (m_IsExisteWhere)
                sql = m_SourceSQL + " AND ROWNUM<" + (m_MaxPage * m_PageRowCount + 1).ToString();
            else
                sql = m_SourceSQL + " WHERE ROWNUM<" + (m_MaxPage * m_PageRowCount + 1).ToString();

            DbProxyClient proxy = App.DbProxy;
            proxy.Clear();
            string data = "";
            string colInfo = proxy.GetSelectData(sql, ref data);
            if (colInfo == null || colInfo.Trim() == "")
            {
                throw new Exception("没有返回列信息!");
            }

            m_DsData = new QDataStore();
            StringBuilder colSyntax = new StringBuilder();
            string[] colNames = colInfo.ToLower().Split(new char[] { '|' });
            for (int i = 0; i < colNames.Length; i++)
            {
                colSyntax.Append(" column=(type=char(150) updatewhereclause=yes name=" + colNames[i] + " dbname=\"" + colNames[i] + "\" ) ");
            }
            StringBuilder dwSyntax = new StringBuilder();
            dwSyntax.Append("release 10.5;");
            dwSyntax.Append("datawindow(units=0 timer_interval=0 color=1073741824 processing=1 HTMLDW=no print.printername=\"\" print.documentname=\"\" print.orientation = 0 print.margin.left = 110 print.margin.right = 110 print.margin.top = 96 print.margin.bottom = 96 print.paper.source = 0 print.paper.size = 0 print.canusedefaultprinter=yes print.prompt=no print.buttons=no print.preview.buttons=no print.cliptext=no print.overrideprintjob=no print.collate=yes print.preview.outline=yes hidegrayline=no grid.lines=1 grid.columnmove=no selected.mouse=no )");
            dwSyntax.Append("header(height=80 color=\"33284040\")");
            dwSyntax.Append("summary(Height = 0 Color = \"536870912\" )");
            dwSyntax.Append("footer(Height = 0 Color = \"536870912\" )");
            dwSyntax.Append("detail(Height = 80 Color = \"536870912\" )");
            dwSyntax.Append("Table(" + colSyntax.ToString() + ")");
            dwSyntax.Append("htmltable(Border = \"1\" cellpadding = \"0\" cellspacing = \"0\" generatecss = \"no\" nowrap = \"yes\")");
            m_DsData.Create(dwSyntax.ToString());
            if (!string.IsNullOrEmpty(data))
                m_DsData.ImportString(data, FileSaveAsType.Text);


            int colX = 0;
            int colWidth = 80;
            colSyntax.Remove(0, colSyntax.Length);
            colSyntax.Append("create compute(band=detail alignment=\"2\" expression=\"if (mod(getrow(),9)=0,9,mod(getrow(),9))\"border=\"0\" color=\"33554432\" ");
            colSyntax.Append("x=\"" + colX.ToString() + "\" y=\"0\" height=\"80\" width=\"" + colWidth.ToString() + "\" format=\"[GENERAL]\" html.valueishtml=\"0\"  name=compute_1 ");
            colSyntax.Append("visible=\"1\"  font.face=\"宋体\" font.height=\"-10\" font.weight=\"400\"  font.family=\"0\" font.pitch=\"2\" ");
            colSyntax.Append("font.charset=\"134\" background.mode=\"2\" background.color=\"33284040\" )");
            m_DsData.Modify(colSyntax.ToString());
            colX += colWidth;

            DataRow[] dr;
            for (int i = 0; i < colNames.Length; i++)
            {
                dr = m_ShowColumn.Select("colName='" + colNames[i] + "'");
                if (dr.Length > 0)
                    colWidth = int.Parse(dr[0]["colWidth"].ToString());
                else
                    colWidth = 0;

                //Column
                colSyntax.Remove(0, colSyntax.Length);
                colSyntax.Append("create column(band=detail id=" + (i + 1).ToString());
                colSyntax.Append(" alignment='0' tabsequence=0 border='0' color='33554432' x='");
                colSyntax.Append(colX.ToString() + "' y='0' height='76' width='" + colWidth.ToString() + "' format='[general]' ");
                colSyntax.Append("html.valueishtml='0' visible='1' name=" + colNames[i] + " edit.limit=0 edit.case=any edit.focusrectangle=no ");
                colSyntax.Append("edit.autoselect=yes edit.autohscroll=yes  font.face='宋体' ");
                colSyntax.Append("font.height='-10' font.weight='400'  font.family='2' font.pitch='2' ");
                colSyntax.Append("font.charset='134' background.mode='1' background.color='553648127')");
                m_DsData.Modify(colSyntax.ToString());

                //Title
                if (dr.Length > 0)
                {
                    colSyntax.Remove(0, colSyntax.Length);
                    colSyntax.Append("create text(band=header alignment='0' text='" + dr[0]["colTitle"].ToString());
                    colSyntax.Append("' border='6' color='33554432' x='" + colX.ToString() + "' y='4' height='64' ");
                    colSyntax.Append("width='" + colWidth.ToString() + "'  name=" + colNames[i] + "_t" + " font.face='宋体'");
                    colSyntax.Append(" font.height='-10' font.weight='400'  font.family='0' font.pitch='2' ");
                    colSyntax.Append("font.charset='134' background.mode='2' background.color='33284040' )");
                }
                m_DsData.Modify(colSyntax.ToString());

                colX += colWidth;
            }

            this.Width = colX / 4;
            if (this.Width < 350)
                this.Width = 350;

            this.dwSelect.Width = this.Width;
        }
        #endregion

        #region 取数据 
        private void GetData()
        {
            if (m_DsData != null)
            {
                //待扩展
            }
            else
            {                    
                InitDS();
            }
        }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -