📄 ucdictcwwh.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.Control;
using Qeb.Support;
using Qeb.Support.Common;
using Qeb.DBProxy;
namespace Qeb.GY
{
public partial class UCDictCwWh : Qeb.GY.UCDictBase
{
//检索参数
private string m_RetrieveParam = "";
public UCDictCwWh()
{
InitializeComponent();
}
private void UCDictCwWh_Load(object sender, EventArgs e)
{
//初始化数据窗口
this.dwCwXx.LibraryList = PBL.GyPbl;
this.dwCwXx.DataWindowObject = GyDataObjects.D_Gy_Cwxx;
this.dwCwXx.InitUI();
try
{
dwCwXx.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 != "UCDictCwWh")
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
#region 根据床位号查找记录
public override void FindInDw(string value)
{
if (value == null)
value = "";
int findRow = dwCwXx.FindRow("cwh='" + value + "'", 1, dwCwXx.RowCount);
if (findRow > 0)
{
dwCwXx.ScrollToRow(findRow);
dwCwXx.SetRow(findRow);
}
}
#endregion
#region 数据完整性检查
private bool CheckCwXx()
{
string colName = "";
string errorMsg = "";
int rowNum = 0;
int rowCount = 0;
DataBuffer buffer = DataBuffer.Primary;
find:
if (buffer == DataBuffer.Primary)
rowCount = dwCwXx.RowCount;
else
rowCount = dwCwXx.FilteredCount;
rowNum = 0;
do
{
rowNum = dwCwXx.FindNextModifiedRow(rowNum, buffer);
if (rowNum > 0)
{
colName = "cwh";
if (this.dwCwXx.IsItemNull(rowNum, colName))
{
errorMsg = "床位号";
goto Error;
//break;
}
colName = "bqid";
if (this.dwCwXx.IsItemNull(rowNum, colName))
{
errorMsg = "病区名称";
goto Error;
//break;
}
colName = "fjid";
if (this.dwCwXx.IsItemNull(rowNum, colName))
{
errorMsg = "房间名称";
goto Error;
//break;
}
colName = "ksid";
if (this.dwCwXx.IsItemNull(rowNum, colName))
{
errorMsg = "科室ID";
goto Error;
//break;
}
colName = "cwlx";
if (this.dwCwXx.IsItemNull(rowNum, colName))
{
errorMsg = "床位类型";
goto Error;
}
}
else
{
rowNum = rowCount;
}
}
while (rowNum < rowCount);
//处理过滤缓冲区
if (buffer == DataBuffer.Primary && dwCwXx.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.dwCwXx.ScrollToRow(rowNum);
this.dwCwXx.Focus();
this.dwCwXx.SetRow(rowNum);
this.dwCwXx.SetColumn(colName);
}
return false;
}
return true;
}
#endregion
#region 增加
private void btnAdd_Click(object sender, EventArgs e)
{
int row = dwCwXx.InsertRow(0);
dwCwXx.SetRow(row);
dwCwXx.SetItemString(row, "bqid", m_RetrieveParam);
dwCwXx.SetItemDecimal(row, "cwzt", 0);
dwCwXx.ScrollToRow(row);
dwCwXx.Focus();
dwCwXx.SetColumn("cwh");
}
#endregion
#region 删除
private void btnStop_Click(object sender, EventArgs e)
{
int rowNum = this.dwCwXx.CurrentRow;
if (rowNum > 0)
{
if (!dwCwXx.IsItemNull(rowNum, "cwzt") && dwCwXx.GetItemDecimal(rowNum, "cwzt") != 0)
{
MessageBox.Show("床位非空,不允许删除", MsgTitle.Warning);
}
else
{
if (dwCwXx.CurrentRow > 0)
{
//删除的记录如果是新增的,直接删除,不提示
RowStatus status = dwCwXx.GetRowStatus(dwCwXx.CurrentRow, DataBuffer.Primary);
if (status == RowStatus.New || status == RowStatus.NewAndModified)
{
dwCwXx.DeleteRow(dwCwXx.CurrentRow);
return;
}
//床位号
string cwh = "";
if (!dwCwXx.IsItemNull(dwCwXx.CurrentRow, "cwh"))
{
cwh = dwCwXx.GetItemString(dwCwXx.CurrentRow, "cwh");
}
DialogResult result = MessageBox.Show(this, "房间ID为【" + cwh + "】的信息将要被删除,您确定吗?", MsgTitle.Prompt, MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (result == DialogResult.OK)
{
this.dwCwXx.DeleteRow(0);
this.m_IsModified = true;
this.btnSave.Enabled = true;
}
}
else
{
MessageBox.Show("请选择需要删除的床位号再单击删除按钮!", MsgTitle.Prompt);
}
}
}
}
#endregion
private void SetEnabled(bool ok)
{
if (ok)
{
this.btnModify.Enabled = true;
}
else
{
this.btnModify.Enabled = false;
btnAdd.Enabled = false;
btnStop.Enabled = false;
btnSave.Enabled = false;
}
}
#region 关闭
private void btnClose_Click(object sender, EventArgs e)
{
this.ParentForm.Close();
}
#endregion
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -