📄 ucdictfjwh.cs
字号:
fjmc = dwFjXx.GetItemString(dwFjXx.CurrentRow, "fjmc");
}
DialogResult result = MessageBox.Show(this, "房间ID为【" + fjid + "】和房间名称为【" + fjmc + "】的信息将要被删除,您确定吗?", MsgTitle.Prompt, MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (result == DialogResult.OK)
{
this.dwFjXx.DeleteRow(0);
this.m_IsModified = true;
this.btnSave.Enabled = true;
}
}
else
{
MessageBox.Show("请选择需要删除的房间再单击删除按钮!", MsgTitle.Prompt);
}
//int rowNum = this.dwFjXx.CurrentRow;
//if (rowNum > 0)
//{
// this.dwFjXx.DeleteRow(0);
// if (!this.m_IsModified)
// this.m_IsModified = true;
// this.btnSave.Enabled = true;
// }
}
#endregion
//主键
private void SetPk()
{
DbProxyClient proxy = App.DbProxy;
string fjid = "";
int rowNum = 0;
int rowCount = dwFjXx.RowCount;
do
{
rowNum = dwFjXx.FindNextModifiedRow(rowNum, DataBuffer.Primary);
if (rowNum > 0)
{
if (dwFjXx.IsItemNull(rowNum, "fjid") || dwFjXx.GetItemString(rowNum, "fjid") == "")
{
try
{
fjid = Sequence.GetXhByName("SEQ_GY_FJXX_FJID");
if (string.IsNullOrEmpty(fjid))
{
MessageBox.Show("没有取到序列,返回值为空!", MsgTitle.Error);
return;
}
dwFjXx.SetItemString(rowNum, "fjid", fjid);
}
catch (Exception ex)
{
MessageBox.Show("取序列发生异常:" + ex.Message, MsgTitle.Error);
break;
}
}
}
else
{
rowNum = rowCount;
}
}
while (rowNum < rowCount);
}
#region 保存
private void btnSave_Click(object sender, EventArgs e)
{
dwFjXx.AcceptText();
//检验数据完整性
SetPk();
if (!this.CheckFjXx())
return;
try
{
DbProxyClient proxy = App.DbProxy;
proxy.Clear();
proxy.AddDataWindow(this.dwFjXx);
proxy.Update();
this.m_IsModified = false;
btnSave.Enabled = false;
}
catch(Exception ex)
{
MessageBox.Show("保存用户信息发生异常:" + ex.Message,MsgTitle.Error);
}
}
#endregion
#region 关闭
private void btnClose_Click(object sender, EventArgs e)
{
this.ParentForm.Close();
}
#endregion
#region 检索数据
private void RetrieveData(string bqId)
{
try
{
DbProxyClient proxy = App.DbProxy;
proxy.Clear();
proxy.AddRetrieveParam("p_bqid", bqId);
proxy.Retrieve(this.dwFjXx);
//检索子数据窗口 病区ID
DataWindowChild dwc = dwFjXx.GetChild("bqid");
proxy.Clear();
proxy.Retrieve(dwc);
}
catch (Exception ex)
{
MessageBox.Show("检索数据出错:" + ex.Message, MsgTitle.Error);
}
finally
{
this.m_IsModified = false;
btnSave.Enabled = false;
}
}
//判断是否需要保存
private DialogResult needSave()
{
DialogResult result = DialogResult.No;
if (this.m_IsModified)
{
result = MessageBox.Show(this, "数据已修改,是否需要保存?", MsgTitle.Prompt, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
}
return result;
}
private void btnRefresh_Click(object sender, EventArgs e)
{
if (needSave() == DialogResult.Yes)
return;
this.RetrieveData(m_RetrieveParam);
}
//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(m_RetrieveParam);
//}
#endregion
private void btnModify_Click(object sender, EventArgs e)
{
try
{
dwFjXx.SetProperty("DataWindow.ReadOnly", "No");
}
catch (Exception ex)
{
MessageBox.Show("设置数据窗口只读属性发生异常:" + ex.Message);
return;
}
this.btnAdd.Enabled = true;
this.btnStop.Enabled = true;
}
private void dwFjXx_EditChanged(object sender, EditChangedEventArgs e)
{
if (!this.m_IsModified)
{
this.m_IsModified = true;
this.btnSave.Enabled = true;
}
}
private void dwFjXx_ItemChanged(object sender, Sybase.DataWindow.ItemChangedEventArgs e)
{
switch (e.ColumnName)
{
case "fjid":
if (e.Data == null || e.Data == "")
{
MessageBox.Show("房间ID不允许为空,请输入!");
e.Action = ItemChangedAction.Reject;
}
break;
case "fjmc":
if (e.Data == null || e.Data == "")
{
MessageBox.Show("房间名称不允许为空,请输入!");
e.Action = ItemChangedAction.Reject;
}
break;
case "bqid":
if (e.Data == null || e.Data == "")
{
MessageBox.Show("病区id不允许为空,请输入!");
e.Action = ItemChangedAction.Reject;
}
break;
}
}
private void dwFjXx_ItemError(object sender, ItemErrorEventArgs e)
{
e.Action = ItemErrorAction.RejectWithNoMessage;
}
private void dwFjXx_Click(object sender, EventArgs e)
{
if (this.btnAdd.Enabled && dwFjXx.ObjectUnderMouse.Band.Type == BandType.Detail)
{
if (dwFjXx.ObjectUnderMouse.Gob.Name == "xbsx")
{
if (!this.m_IsModified)
{
this.m_IsModified = true;
this.btnSave.Enabled = true;
}
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -