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

📄 ucdictyhwh.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 UCDictYhWh : Qeb.GY.UCDictBase
    {
        public UCDictYhWh()
        {
            InitializeComponent();
        }

        private void UCDictYhWh_Load(object sender, EventArgs e)
        {
            this.LookUpPromptText = "用户工号或用户名称";

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

        #region 根据用户工号、用户名查找记录
        public override void FindInDw(string value)
        {
            if (value == null)
                value = "";

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

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

            DataBuffer buffer = DataBuffer.Primary;

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

            rowNum = 0;            
            do
            {

                rowNum = dwYhXx.FindNextModifiedRow(rowNum, buffer);
                if (rowNum > 0)
                {
                    colName = "Gh";
                    if (this.dwYhXx.IsItemNull(rowNum, colName))
                    {
                        errorMsg = "用户ID";
                        goto Error;
                        //break;
                    }

                    colName = "YhMc";
                    if (this.dwYhXx.IsItemNull(rowNum, colName))
                    {
                        errorMsg = "用户名称";
                        goto Error;
                        //break;
                    }

                    colName = "MiMa";
                    if (this.dwYhXx.IsItemNull(rowNum, colName))
                    {
                        errorMsg = "密码";
                        goto Error;
                        //break;
                    }

                    colName = "MrSrm";
                    if (this.dwYhXx.IsItemNull(rowNum, colName))
                    {
                        errorMsg = "默认输入码";
                        goto Error;
                        //break;
                    }
                }
                else
                {
                    rowNum = rowCount;
                }
            }
            while (rowNum < rowCount);
            //处理过滤缓冲区
            if (buffer == DataBuffer.Primary && dwYhXx.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.dwYhXx.ScrollToRow(rowNum);
                    this.dwYhXx.Focus();
                    this.dwYhXx.SetRow(rowNum);
                    this.dwYhXx.SetColumn(colName);
                }
                return false;
            }

            return true;
        }
        #endregion

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

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

                //工号
                string gh = "";                
                if (!dwYhXx.IsItemNull(dwYhXx.CurrentRow,"gh"))
                {
                    gh = dwYhXx.GetItemString(dwYhXx.CurrentRow,"gh");
                }

                //用户名称
                string yhMc = "";               
                if (!dwYhXx.IsItemNull(dwYhXx.CurrentRow,"yhmc"))
                {
                    yhMc = dwYhXx.GetItemString(dwYhXx.CurrentRow,"yhmc");
                }
                DialogResult result = MessageBox.Show(this, "工号为【" + gh + "】用户名为【" + yhMc + "】的帐号只能停用,不能删除,您确定要停用吗?", MsgTitle.Prompt, MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                if (result == DialogResult.OK)
                {
                    dwYhXx.SetItemDecimal(dwYhXx.CurrentRow, "TyBz",1);
                    this.m_IsModified = true;
                    this.btnSave.Enabled = true;
                }
            }
            else
            {
                MessageBox.Show("请选择需要删除的用户再单击删除按钮!",MsgTitle.Prompt);
            }
        }
        #endregion

        #region 保存
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!dwYhXx.AcceptText())
                return;

            //检验数据完整性
            if (!this.CheckYhXx())
                return;

           
            try
            {
                DbProxyClient proxy = App.DbProxy;

⌨️ 快捷键说明

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