📄 fypzdwh_ypjgwh.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Oracle.DataAccess.Client;
using Sybase.DataWindow;
using Qeb.Control;
using Qeb.DBProxy;
using Qeb.Support.Common;
using Qeb.Support;
using Qeb.GY;
namespace Qeb.YK
{
public partial class FYpZdWh_YpJgWh : Qeb.Control.FBase
{
//药品价格ID 0 表示新增
private string m_YpJgId = "";
//药品规格ID
private string m_YpGgId = "";
//药品ID
private string m_YpId = "";
internal void SetId(string ypJgId,string ypGgId,string ypMcGg,string ypId)
{
m_YpJgId = ypJgId;
m_YpGgId = ypGgId;
m_YpId = ypId;
if (m_YpJgId == "0")
{
this.Text = "药品价格维护 新增";
}
else
{
this.Text = "药品价格维护 修改";
}
labelYpMcGg.Text = ypMcGg;
}
public FYpZdWh_YpJgWh()
{
InitializeComponent();
dwYpJg.LibraryList = PBL.YkPbl;
dwYpJg.DataWindowObject = YkDataObjects.D_Yk_YpJgWh;
}
private void btnClose_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
this.Close();
}
private bool CheckYpJgXx()
{
//招标药品标志
if (dwYpJg.IsItemNull(1,"zbypbz") || dwYpJg.GetItemDecimal(1,"zbypbz")==0)
{
dwYpJg.SetItemDecimal(1, "zbjj", 0);
}
if (!dwYpJg.AcceptText())
return false;
//产地名称
if (dwYpJg.IsItemNull(1, "cdid") || dwYpJg.GetItemString(1, "cdid") == "" ||
dwYpJg.IsItemNull(1, "cdmc") || dwYpJg.GetItemString(1, "cdmc") == "")
{
MessageBox.Show("产地名称不能为空,请输入!", MsgTitle.Prompt);
dwYpJg.Focus();
dwYpJg.SetColumn("cdmc");
return false;
}
//零售价
decimal lsj = 0;
if (!dwYpJg.IsItemNull(1, "lsj"))
lsj = dwYpJg.GetItemDecimal(1, "lsj");
if (lsj <= 0)
{
MessageBox.Show("零售价必须大于0,请输入!", MsgTitle.Prompt);
dwYpJg.Focus();
dwYpJg.SetColumn("lsj");
return false;
}
//批发价可否为空
decimal pfj = 0;
if (!dwYpJg.IsItemNull(1, "pfj"))
pfj = dwYpJg.GetItemDecimal(1, "pfj");
if (pfj < 0 )
{
MessageBox.Show("批发价不能小于0,请输入!", MsgTitle.Prompt);
dwYpJg.Focus();
dwYpJg.SetColumn("pfj");
return false;
}
string csId = "YK_YPZDWH_PFJKFBL";
string csz = "";
try
{
csz = AppParameters.GetParam(csId, "1");
}
catch (System.Exception ex)
{
MessageBox.Show("取参数值发生异常:"+ex.Message,MsgTitle.Error);
return false;
}
//必须录入批发价
if (csz == "1")
{
if (pfj == 0)
{
MessageBox.Show("批发价必须大于0,请输入!", MsgTitle.Prompt);
dwYpJg.Focus();
dwYpJg.SetColumn("pfj");
return false;
}
}
//批发价可否大于零售价
csId = "YK_YPZDWH_PFJKDYLSJ";
csz = "";
try
{
csz = AppParameters.GetParam(csId, "1");
}
catch (System.Exception ex)
{
MessageBox.Show("取参数值发生异常:" + ex.Message, MsgTitle.Error);
return false;
}
if (csz == "1")
{
if (pfj>lsj)
{
MessageBox.Show("批发价不能大于零售价!", MsgTitle.Prompt);
return false;
}
}
//最高零售价
decimal zgLsj = 0;
if (!dwYpJg.IsItemNull(1, "zglsj"))
zgLsj = dwYpJg.GetItemDecimal(1, "zglsj");
if (zgLsj < 0)
{
MessageBox.Show("最高零售价必须大于0,请输入!", MsgTitle.Prompt);
dwYpJg.Focus();
dwYpJg.SetColumn("zglsj");
return false;
}
if (zgLsj>0 && zgLsj < lsj)
{
MessageBox.Show("最高零售价不能小于零售价,请输入!", MsgTitle.Prompt);
dwYpJg.Focus();
dwYpJg.SetColumn("zgLsj");
return false;
}
//最高批发价
decimal zgPfj = 0;
if (!dwYpJg.IsItemNull(1, "zgpfj"))
zgPfj = dwYpJg.GetItemDecimal(1, "zgpfj");
if (zgPfj < 0)
{
MessageBox.Show("最高零售价必须大于0,请输入!", MsgTitle.Prompt);
dwYpJg.Focus();
dwYpJg.SetColumn("zgpfj");
return false;
}
if (zgPfj > 0 && zgPfj < pfj)
{
MessageBox.Show("最高批发价不能小于批发价,请输入!", MsgTitle.Prompt);
dwYpJg.Focus();
dwYpJg.SetColumn("zgPfj");
return false;
}
return true;
}
private void btnSave_Click(object sender, EventArgs e)
{
if (!CheckYpJgXx())
return;
if (m_YpJgId == "0")
{
//设置主键
try
{
string ypJgId = Sequence.GetXhByName("SEQ_GY_YPJGK_YPJGID", 6);
if (string.IsNullOrEmpty(ypJgId))
{
MessageBox.Show("取药品价格ID不成功,取到的值为空!", MsgTitle.Error);
return;
}
dwYpJg.SetItemString(1, "ypjgid", ypJgId);
}
catch (Exception ex)
{
MessageBox.Show("取药品价格ID发生异常:" + ex.Message, MsgTitle.Error);
return;
}
}
//保存
try
{
DbProxyClient proxy = App.DbProxy;
proxy.Clear();
proxy.AddDataWindow(dwYpJg);
if (m_YpJgId == "0")
{
//新增时需要调用存储过程处理冗余字段
proxy.AddDbCommand(GetUpdateYpJgXxCommand(), new VerifyInfo(VerifyModeEnum.OutputPara,":p_appcode", LogicSymbolEnum.Equal, 1));
//新增时需要调用存储过程处理小规格价格信息
proxy.AddDbCommand(Prc_AfterInsertYpJgXxCommand(), new VerifyInfo(VerifyModeEnum.OutputPara, ":p_appcode", LogicSymbolEnum.Equal, 1));
}
proxy.Update();
this.DialogResult = DialogResult.OK;
this.Close();
}
catch (Exception ex)
{
MessageBox.Show("保存药品价格信息时发生异常:" + ex.Message, MsgTitle.Error);
}
}
private OracleCommand GetUpdateYpJgXxCommand()
{
if (dwYpJg.IsItemNull(1, "ypjgid"))
throw new Exception("数据窗口中药品价格ID没有设置值。");
if (dwYpJg.IsItemNull(1, "ypggid"))
throw new Exception("数据窗口中药品规格ID没有设置值。");
string ypJgId = dwYpJg.GetItemString(1, "ypjgid");
string ypGgId = dwYpJg.GetItemString(1, "ypggid");
OracleCommand command = new OracleCommand();
command.CommandText = "PKG_GY_YPZD.Prc_UpdateYpJgXx";
command.CommandType = CommandType.StoredProcedure;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -