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

📄 ucdictfjwh.cs

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

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

namespace Qeb.GY
{
    public partial class UCDictFjWh : Qeb.GY.UCDictBase
    {
        //检索参数
        private string m_RetrieveParam = "";

        public UCDictFjWh()
        {
            InitializeComponent();
        }


        private void UCDictFjWh_Load(object sender, EventArgs e)
        {
            //初始化数据窗口
            this.dwFjXx.LibraryList = PBL.GyPbl;
            this.dwFjXx.DataWindowObject = GyDataObjects.D_Gy_FjXx;
            this.dwFjXx.InitUI();
            try
            {
                dwFjXx.SetProperty("DataWindow.ReadOnly", "Yes");
            }
            catch (Exception ex)
            {
                MessageBox.Show("设置数据窗口只读属性发生异常:" + ex.Message);
            }

            //订阅消息         
            this.SubscribeEvent(MsgEventDefine.Dict_RefreshWithParam);
        }
        #region 消息处理
        protected override void ProcessUIMessage(string messageId, UIMessageEventArgs e)
        {
            if (messageId == MsgEventDefine.Dict_RefreshWithParam)
            {
                FDictBase.TagInfo tagInfo;
                try
                {
                    tagInfo = (FDictBase.TagInfo)e.Values;
                    if (tagInfo.ControlName != "UCDictFjWh")
                        return;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("处理刷新数据消息发生异常(转换参数出错):"+ex.Message,MsgTitle.Error);
                    return;
                }

                if (m_RetrieveParam != tagInfo.RefreshParam)
                {
                    if(needSave() == DialogResult.Yes)
                        return;
                    m_RetrieveParam = tagInfo.RefreshParam;
                    this.RetrieveData(tagInfo.RefreshParam);
                    //上级目录不允许修改
                    if(m_RetrieveParam=="*")
                        setEnabled(false);
                    else
                        setEnabled(true);
                }
            }
        }
        #endregion
        private void setEnabled(bool ok)
        {
            if(ok)
            {
                this.btnModify.Enabled = true;
            }
            else
            {
                this.btnModify.Enabled = false;
                btnAdd.Enabled = false;
                btnSave.Enabled = false;
                btnStop.Enabled = false;
            }
        }

        #region 根据房间ID和房间名称查找记录
        public override void FindInDw(string value)
        {
            if (value == null)
                value = "";

            int findRow = dwFjXx.FindRow("fjid='" + value + "' or fjmc='" + value + "'", 1, dwFjXx.RowCount);
            if (findRow > 0)
            {
                dwFjXx.ScrollToRow(findRow);
                dwFjXx.SetRow(findRow);
            }
        }
        #endregion

        #region 数据完整性检查
        private bool CheckFjXx()
        {
            string colName = "";
            string errorMsg = "";
            int rowNum = 0;
            int rowCount = 0;

            DataBuffer buffer = DataBuffer.Primary;

        find:
            if (buffer == DataBuffer.Primary)
                rowCount = dwFjXx.RowCount;
            else
                rowCount = dwFjXx.FilteredCount;

            rowNum = 0;
            do
            {
                rowNum = dwFjXx.FindNextModifiedRow(rowNum, buffer);
                if (rowNum > 0)
                {
                    colName = "fjid";
                    if (this.dwFjXx.IsItemNull(rowNum, colName))
                    {
                        errorMsg = "房间ID";
                        goto Error;
                        //break;
                    }

                    //colName = "xbsx";
                    //if (this.dwFjXx.IsItemNull(rowNum, colName))
                    //{
                    //    errorMsg = "性别属性";
                    //    break;
                    //}

                    colName = "fjmc";
                    if (this.dwFjXx.IsItemNull(rowNum, colName))
                    {
                        errorMsg = "房间名称";
                        goto Error;
                        //break;
                    }

                    colName = "bqid";
                    if (this.dwFjXx.IsItemNull(rowNum, colName))
                    {
                        errorMsg = "病区ID";
                        goto Error;
                        //break;
                    }
                }
                else
                {
                    rowNum = rowCount;
                }
            }
            while (rowNum < rowCount);
            //处理过滤缓冲区
            if (buffer == DataBuffer.Primary && dwFjXx.FilteredCount > 0)
            {
                buffer = DataBuffer.Filter;
                goto find;
            }


            Error:
            if (errorMsg != "")
            {
                if (buffer == DataBuffer.Filter)
                {
                    MessageBox.Show("数据输入不完整," + errorMsg + "没有输入,该记录已被过滤,重新设置过滤条件后可显示!", MsgTitle.Warning);
                }
                else
                {
                    MessageBox.Show("数据输入不完整,第" + rowNum.ToString() + "行" + errorMsg + "没有输入!", MsgTitle.Warning);
                    this.dwFjXx.ScrollToRow(rowNum);
                    this.dwFjXx.Focus();
                    this.dwFjXx.SetRow(rowNum);
                    this.dwFjXx.SetColumn(colName);
                }
                return false;
            }

            return true;
        }
        #endregion

        #region 增加
        private void btnAdd_Click(object sender, EventArgs e)
        {
            int rowIndex = dwFjXx.InsertRow(0);
            dwFjXx.SetRow(rowIndex);
            dwFjXx.SetItemString(rowIndex,"bqid", m_RetrieveParam);
            dwFjXx.ScrollToRow(rowIndex);
            dwFjXx.Focus();
            dwFjXx.SetColumn("fjid");
        }
        #endregion

        #region 删除
        private void btnStop_Click(object sender, EventArgs e)
        {
            if (dwFjXx.CurrentRow > 0)
            {
                //删除的记录如果是新增的,直接删除,不提示
                RowStatus status = dwFjXx.GetRowStatus(dwFjXx.CurrentRow, DataBuffer.Primary);
                if (status == RowStatus.New || status == RowStatus.NewAndModified)
                {
                    dwFjXx.DeleteRow(dwFjXx.CurrentRow);
                    return;
                }

                //房间ID
                string fjid = "";
                if (!dwFjXx.IsItemNull(dwFjXx.CurrentRow, "fjid"))
                {
                    fjid = dwFjXx.GetItemString(dwFjXx.CurrentRow, "fjid");
                }

                //房间名称
                string fjmc = "";
                if (!dwFjXx.IsItemNull(dwFjXx.CurrentRow, "fjmc"))
                {

⌨️ 快捷键说明

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