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

📄 ucdictbqwh.cs

📁 基于C/S的医疗卫生管理系统
💻 CS
字号:
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.Support;
using Qeb.Support.Common;
using Qeb.DBProxy;

namespace Qeb.GY
{
    public partial class UCDictBqWh : Qeb.GY.UCDictBase
    {
        public UCDictBqWh()
        {
            InitializeComponent();
        }

        private void UCDictBqWh_Load(object sender, EventArgs e)
        {
            this.LookUpPromptText = "请输入病区ID或病区名称";

            //初始化数据窗口
            this.dwBqGl.LibraryList = PBL.GyPbl;
            this.dwBqGl.DataWindowObject = GyDataObjects.D_Gy_BqXxWh;
            this.dwBqGl.InitUI();
            try
            {
                dwBqGl.SetProperty("DataWindow.ReadOnly", "Yes");
            }
            catch (Exception ex)
            {
                MessageBox.Show("设置数据窗口只读属性发生异常:" + ex.Message);
            }
            this.RetrieveData();
        }

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

            int findRow = dwBqGl.FindRow("bqid='" + value + "' or bqmc='" + value + "'", 1, dwBqGl.RowCount);
            if (findRow > 0)
            {
                dwBqGl.ScrollToRow(findRow);
                dwBqGl.SetRow(findRow);
            }

        }
        #endregion

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

            DataBuffer buffer = DataBuffer.Primary;

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

            rowNum = 0;
            do
            {

                rowNum = dwBqGl.FindNextModifiedRow(rowNum, buffer);
                if (rowNum > 0)
                {
                    colName = "bqid";
                    if (this.dwBqGl.IsItemNull(rowNum, colName))
                    {
                        errorMsg = "病区ID";
                        break;
                    }

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


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

            return true;
        }
        #endregion

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

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

                //病区ID
                string bqid = "";
                if (!dwBqGl.IsItemNull(dwBqGl.CurrentRow, "bqid"))
                {
                    bqid = dwBqGl.GetItemString(dwBqGl.CurrentRow, "bqid");
                }

                //病区名称
                string bqmc = "";
                if (!dwBqGl.IsItemNull(dwBqGl.CurrentRow, "bqmc"))
                {
                    bqmc = dwBqGl.GetItemString(dwBqGl.CurrentRow, "bqmc");
                }
                DialogResult result = MessageBox.Show(this, "病区ID为【" + bqid + "】病区名称为【" + bqmc + "】的记录只能停用,不能删除,您确定要停用吗?", MsgTitle.Prompt, MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                if (result == DialogResult.OK)
                {
                    dwBqGl.SetItemDecimal(dwBqGl.CurrentRow, "Zfbz", 1);
                    this.m_IsModified = true;
                    this.btnSave.Enabled = true;
                }
            }
            else
            {
                MessageBox.Show("请选择需要删除的用户再单击删除按钮!", MsgTitle.Prompt);
            }
        }
        #endregion

        #region 保存
        private void btnSave_Click(object sender, EventArgs e)
        {
            dwBqGl.AcceptText();

            //检验数据完整性
            if (!this.CheckBqXx())
                return;
            try
            {
                DbProxyClient proxy = App.DbProxy;
                proxy.Clear();
                proxy.AddDataWindow(this.dwBqGl);
                proxy.Update();
                this.m_IsModified = false;
                btnSave.Enabled = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show("保存用户信息发生异常:" + ex.Message, MsgTitle.Error);
            }
        }
        #endregion

        private void btnModify_Click(object sender, EventArgs e)
        {
            try
            {
                dwBqGl.SetProperty("DataWindow.ReadOnly", "No");
            }
            catch (Exception ex)
            {
                MessageBox.Show("设置数据窗口只读属性发生异常:" + ex.Message);
                return;
            }

            this.btnAdd.Enabled = true;
            this.btnStop.Enabled = true;
        }

        #region 检索数据
        private void RetrieveData()
        {
            try
            {
                DbProxyClient proxy = App.DbProxy;
                proxy.Clear();
                proxy.Retrieve(this.dwBqGl);
            }
            catch (Exception ex)
            {
                MessageBox.Show("检索数据出错:" + ex.Message, MsgTitle.Error);
            }
            finally
            {
                this.m_IsModified = false;
                btnSave.Enabled = false;
            }
            this.dwBqGl.SetSort("bqid");
            this.dwBqGl.Sort();

            try
            {
                DataWindowChild dwc = dwBqGl.GetChild("yqid");
                DbProxyClient proxy = App.DbProxy;
                proxy.Clear();
                proxy.Retrieve(dwc);
            }
            catch(Exception ex)
            {
                MessageBox.Show("处理子数据窗口发生异常:"+ex.Message);
            }


        }
        private void btnRefresh_Click(object sender, EventArgs e)
        {
            if (this.m_IsModified)
            {
                DialogResult result = MessageBox.Show(this, "数据已修改,是否需要保存?", MsgTitle.Prompt, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    return;
                }
            }

            this.RetrieveData();
        }
        #endregion

        private void btnPrint_Click(object sender, EventArgs e)
        {

        }

        private void btnExport_Click(object sender, EventArgs e)
        {

        }

        #region 关闭
        private void btnClose_Click(object sender, EventArgs e)
        {
            this.ParentForm.Close();
        }
        #endregion

        private void dwBqGl_EditChanged(object sender, EditChangedEventArgs e)
        {
            if (!this.m_IsModified)
            {
                this.m_IsModified = true;
                this.btnSave.Enabled = true;
            }
        }

        private void dwBqGl_ItemChanged(object sender, Sybase.DataWindow.ItemChangedEventArgs e)
        {
            switch (e.ColumnName)
            {
                case "bqid":
                    if (e.Data == null || e.Data == "")
                    {
                        MessageBox.Show("病区ID不允许为空,请输入!");
                        e.Action = ItemChangedAction.Reject;
                    }
                    break;
                case "bqmc":
                    if (e.Data == null || e.Data == "")
                    {
                        MessageBox.Show("病区名称不允许为空,请输入!");
                        e.Action = ItemChangedAction.Reject;
                    }
                    break;
            }
            this.m_IsModified = true;
            this.btnSave.Enabled = true;
        }

        private void dwBqGl_ItemError(object sender, ItemErrorEventArgs e)
        {
            e.Action = ItemErrorAction.RejectWithNoMessage;
        }

        private void dwBqGl_Click(object sender, EventArgs e)
        {
            if (this.btnAdd.Enabled && dwBqGl.ObjectUnderMouse.Band.Type == BandType.Detail)
            {
                if (dwBqGl.ObjectUnderMouse.Gob.Name == "zfbz")
                {
                    if (!this.m_IsModified)
                    {
                        this.m_IsModified = true;
                        this.btnSave.Enabled = true;
                    }
                }
            }
        }
    }
}

⌨️ 快捷键说明

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