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

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

        private void UDictDwXxWh_Load(object sender, EventArgs e)
        {
            this.DWdwXx.LibraryList = PBL.GyPbl;
            this.DWdwXx.DataWindowObject = GyDataObjects.D_Gy_DwXxGl;
            this.DWdwXx.InitUI();

            try
            {
                DWdwXx.SetProperty("DataWindow.ReadOnly", "Yes");
            }
            catch (Exception ex)
            {
                MessageBox.Show("设置数据窗口只读属性发生异常:" + ex.Message);
            }
            this.RetrieveData();

        }
        //检索数据
        private void RetrieveData()
        {
            try
            {
                DbProxyClient proxy = App.DbProxy;
                proxy.Clear();
                proxy.Retrieve(this.DWdwXx);
             
            }
            catch (Exception ex)
            {
                MessageBox.Show("检索数据发生异常:" + ex.Message, MsgTitle.Error);
            }
            finally
            {
                this.m_IsModified = false;
                this.btnSave.Enabled = false;
            }

        }

        #region 在数据窗口中查找记录
        public override void FindInDw(string value)
        {
            if (value == null)
                value = "";

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

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

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

        private void btnAdd_Click(object sender, EventArgs e)
        {
            int rowIndex = DWdwXx.InsertRow(0);
            DWdwXx.SetRow(rowIndex);
            DWdwXx.ScrollToRow(rowIndex);
            DWdwXx.Focus();
            DWdwXx.SetColumn("dwid");
        }

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

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

                //工号
                string dwId = "";
                if (!DWdwXx.IsItemNull(DWdwXx.CurrentRow, "dwid"))
                {
                    dwId = DWdwXx.GetItemString(DWdwXx.CurrentRow, "dwid");
                }

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

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

        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();    

        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!DWdwXx.AcceptText())
                return;

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


            try
            {
                DbProxyClient proxy = App.DbProxy;
                proxy.Clear();
                proxy.AddDataWindow(this.DWdwXx);
                proxy.Update();
                this.m_IsModified = false;
                btnSave.Enabled = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show("保存协议单位信息发生异常:" + ex.Message, MsgTitle.Error);
            }

        }

        private bool CheckYhXx()
        {
            string colName = "";
            string errorMsg = "";
            int rowNum = 0;
            int rowCount = 0;

            DataBuffer buffer = DataBuffer.Primary;

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

            rowNum = 0;
            do
            {

                rowNum = DWdwXx.FindNextModifiedRow(rowNum, buffer);
                if (rowNum > 0)
                {
                    colName = "DwId";
                    if (this.DWdwXx.IsItemNull(rowNum, colName))
                    {
                        errorMsg = "单位ID";
                        goto Error;
                        //break;
                    }

                    colName = "DwBh";
                    if (this.DWdwXx.IsItemNull(rowNum, colName))
                    {
                        errorMsg = "单位编号";
                        goto Error;
                        //break;
                    }

                    colName = "DwMc";
                    if (this.DWdwXx.IsItemNull(rowNum, colName))
                    {
                        errorMsg = "单位名称";
                        goto Error;
                        //break;
                    }

                    colName = "DwDh";
                    if (this.DWdwXx.IsItemNull(rowNum, colName))
                    {
                        errorMsg = "单位电话";
                        goto Error;
                        //break;
                    }

                    colName = "DwDz";
                    if (this.DWdwXx.IsItemNull(rowNum, colName))
                    {
                        errorMsg = "单位地址";
                        goto Error;
                        //break;
                    }

                    colName = "FyLbId";
                    if (this.DWdwXx.IsItemNull(rowNum, colName))
                    {
                        errorMsg = "费用类别ID";
                        goto Error;
                        //break;
                    }

                    colName = "FyXzId";
                    if (this.DWdwXx.IsItemNull(rowNum, colName))
                    {
                        errorMsg = "费用性质ID";
                        goto Error;
                        //break;
                    }

                    colName = "SxRq";
                    if (this.DWdwXx.IsItemNull(rowNum, colName))
                    {
                        errorMsg = "生效日期";
                        goto Error;
                        //break;
                    }

                    colName = "TzRq";
                    if (this.DWdwXx.IsItemNull(rowNum, colName))
                    {
                        errorMsg = "停止日期";
                        goto Error;
                        //break;
                    }
                }
                else
                {
                    rowNum = rowCount;
                }
            }
            while (rowNum < rowCount);
            //处理过滤缓冲区
            if (buffer == DataBuffer.Primary && DWdwXx.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.DWdwXx.ScrollToRow(rowNum);
                    this.DWdwXx.Focus();
                    this.DWdwXx.SetRow(rowNum);
                    this.DWdwXx.SetColumn(colName);
                }
                return false;
            }

            return true;
        }

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

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.ParentForm.Close();
        }





    }
}

⌨️ 快捷键说明

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