1.31录入处方
增加药品的时候,把鼠标放在项目名称处单击,如图(1)
图(1)
会弹出一个窗体,如图(2)
图(2)
然后就选择你需要的药品,双击选择
查询药品功能实现:
第一步:数据库
1、表与关系
然后就选择你需要的药品,双击选择
查询药品功能实现:
第一步:数据库
1、表与关系
表1:药品表(KC_MedicineList)
列名 | 数据类型 | 说明 |
MedicineID | int - Identity | 药品ID |
MedicineName | nchar (50) | 药品名称 |
CommonalityName | nchar (30) | 通用名 |
SpellCode | nchar (20) | 拼音码 |
Specification | nchar (20) | 规格 |
ParturitionManufacturers | nchar (50) | 生产厂家 |
PackUnitID | int | 包装单位ID |
DoseSortID | int | 剂型类别ID |
BatchNumber | nchar (50) | 批号 |
EffectiveDate | nchar (10) | 有效期 |
Encoding | nchar (20) | 编码 |
RetailPrice | decimal (18, 2) | 零售价(包装) |
Content | nchar (20) | 含量 |
MeteringUnitID | Int | 计量单位ID |
StopUseNo | bit | 停用否 |
MedicinalTypeID | int | 药品类型ID |
Dosage | nchar (50) | 用量 |
BadnessReaction | nchar (300) | 不良反应 |
AttentionItems | nchar (300) | 注意事项 |
Performance | nchar (300) | 性能 |
RetailPrice_J | decimal (18, 4) | 零售价_j(单个) |
ManageStockNo | bit | 管库存否 |
ProducingArea | nchar (10) | 产地 |
RatifyNumber | nchar (30) | 批准文号 |
IdentifyingSign | nchar (30) | 标识符号 |
YiJiNo | bit | 医技否 |
ImportNo | bit | 进口否 |
RecentlyEnterPrice | decimal (18, 4) | 最近进价 |
StorageCondition | nchar (10) | 存储条件 |
QualityStandard | nchar (30) | 质量标准 |
BarCode | nchar (30) | 条形码 |
Manufacturer | nchar (30) | 厂商 |
Taboo | nchar (100) | 禁忌 |
CheckoutMethod | nchar (200) | 检验方法 |
RegisterIdNumber | nchar (30) | 注册证号 |
RightSymptom | nchar (200) | 适应症 |
FinitudeMoney | decimal (18, 2) | 限额 |
SpecificMedicinalID | Int | 特殊药品 |
UseMethod | nchar (200) | 用法 |
UpperLimit | nchar (10) | 上限 |
LowerLimit | nchar (10) | 下限 |
BaoNeiFuo | bit | 保内否 |
表2:库存表(KC_StockList)
列名 | 数据类型 | 说明 |
StockID | int - Identity | 库存ID |
StoreroomID | int | (库房表)库房ID |
MedicineID | int | (药品表)药品ID |
StockNumber | decimal (18) | 库存数 |
StockUpperLimit | decimal (18) | 库存上限 |
StockLowerLimit | decimal (18) | 库存下限 |
表3:库房表(KC_StoreroomList)
列名 | 数据类型 | 说明 |
StoreroomID | int - Identity | 库房ID |
StoreroomName | nchar (20) | 库房名称 |
从界面上可以看到我们这里用到的控件有
控件名称 | 说明 |
日期控件(DateTimePicker) | 控件可以在工具箱直接拖动至窗体,拖至窗体后右击属性可以修改控件的样式和各种属性,还可以编辑事件。 |
选项卡(TabControl) | |
文本(TextBox) | |
按钮(Button) | |
表格(DataGridView) |
添加药品功能实现:
private void btnInsertMedicine_Click(object sender, EventArgs e)
{
try
{
if (txtName.Text == "")
{
MessageBox.Show("还没有选择病人呢?");
return;
}
dgvMedicineInformation.Rows.Add(1);//每点击一下新增药品按钮,就新增一行空白行
dgvMedicineInformation.Rows[dgvMedicineInformation.Rows.Count - 1].Cells["SumNumber"].Value = "1";//在数量单元格加1
SkinTestNo.DataSource = myFrm_MenZhenYiShengGongZuoZhanClient.Frm_MenZhenYiShengGongZuoZhan_cboChaXunShiFouPiShi().Tables[0];
SkinTestNo.DisplayMember = "SkinTestNo"; //绑定dgvMedicineInformation里的cbo数据
SkinTestNo.ValueMember = "AttributeMingXiID";
Usage.DataSource = myFrm_MenZhenYiShengGongZuoZhanClient.Frm_MenZhenYiShengGongZuoZhan_cboChaXunYaoPinYongFa().Tables[0];
Usage.DisplayMember = "Usage";
Usage.ValueMember = "AttributeMingXiID";
UseMedicineFrequency.DataSource = myFrm_MenZhenYiShengGongZuoZhanClient.Frm_MenZhenYiShengGongZuoZhan_cboChaXunYaoPinYongYaoPinLv().Tables[0];
UseMedicineFrequency.DisplayMember = "UseMedicineFrequency";
UseMedicineFrequency.ValueMember = "AttributeMingXiID";
AtEveryTurnDose.DataSource = myFrm_MenZhenYiShengGongZuoZhanClient.Frm_MenZhenYiShengGongZuoZhan_cboChaXunYaoPinYongMeiCiShuLiang().Tables[0];
AtEveryTurnDose.DisplayMember = "AtEveryTurnNumber";
AtEveryTurnDose.ValueMember = "AttributeMingXiID";
OfficeName.DataSource = myFrm_MenZhenYiShengGongZuoZhanClient.Frm_MenZhenYiShengGongZuoZhan_cboChaXunKeShi().Tables[0];
OfficeName.DisplayMember = "OfficeName";
OfficeName.ValueMember = "OfficeID";
}
catch { }
}
单击单元格列索引弹出窗体和传值实现
#region 根据单元格索引弹出窗体
public static int intMedicineID2;
public static decimal decShuLiang;
private void dgvMedicineInformation_CellClick(object sender, DataGridViewCellEventArgs e)
{
try
{
int WeiZhi = dgvMedicineInformation.CurrentCell.ColumnIndex;//获取单元格的列索引
if (WeiZhi == 0)//当为0时就弹出窗体
{
门诊管理.Frm_MenZhenYiShengGongZuoZhanYaoPin_Insert myFrm_MenZhenYiShengGongZuoZhanYaoPin_Insert =
new Frm_MenZhenYiShengGongZuoZhanYaoPin_Insert();
myFrm_MenZhenYiShengGongZuoZhanYaoPin_Insert.ShowDialog();
//下面是跨窗体传值
dgvMedicineInformation.CurrentRow.Cells["MedicineID"].Value = Frm_MenZhenYiShengGongZuoZhanYaoPin_Insert.intYaoPinID;
dgvMedicineInformation.CurrentRow.Cells["MedicineName"].Value = Frm_MenZhenYiShengGongZuoZhanYaoPin_Insert.strYaoPinMingCheng;
dgvMedicineInformation.CurrentRow.Cells["ParturitionManufacturers"].Value = Frm_MenZhenYiShengGongZuoZhanYaoPin_Insert.strShengChanChangJia;
dgvMedicineInformation.CurrentRow.Cells["Specification"].Value = Frm_MenZhenYiShengGongZuoZhanYaoPin_Insert.strGuiGe;
dgvMedicineInformation.CurrentRow.Cells["MeteringUnit"].Value = Frm_MenZhenYiShengGongZuoZhanYaoPin_Insert.strJiLiangDanWei;
dgvMedicineInformation.CurrentRow.Cells["RetailPrice_J"].Value = Frm_MenZhenYiShengGongZuoZhanYaoPin_Insert.delLingShouJia;
dgvMedicineInformation.CurrentRow.Cells["StoreroomID"].Value = Frm_MenZhenYiShengGongZuoZhanYaoPin_Insert.intStoreroomID;
intMedicineID2 = Convert.ToInt32(dgvMedicineInformation.CurrentRow.Cells["MedicineID"].Value);
decShuLiang = Convert.ToDecimal(dgvMedicineInformation.CurrentRow.Cells["SumNumber"].Value);
dgvMedicineInformation.CurrentRow.Cells["MedicineName"].ReadOnly = true; ;
}
}
catch { }
}
#endregion
新增处方功能实现
第一步:数据库
1、表与关系
表1:处方表(MZ_PrescriptionBillsList)
列名 | 数据类型 | 说明 |
PrescriptionBillsID | int - Identity | 处方ID |
MenZhenRegisterID | int | (门诊登记表)门诊登记ID |
PrescriptionNumber | char (30) | 门诊号 |
TieNumber | decimal (18) | 贴数 |
OpenBillsDate | datetime | 开单日期 |
DealWithNo | bit | 处置否 |
SettleAccountsNo | bit | 结算否 |
Diagnosis | nchar (50) | 诊断 |
RefundNo | bit | 还款否 |
表2:处方明细表(MZ_PrescriptionBillsMingXiList)
列名 | 数据类型 | 说明 |
PrescriptionBillsMingXiID | int - Identity | 处方明细ID |
MedicineID | int | 药品ID |
Number | decimal (18, 2) | 数量 |
PrescriptionBillsID | int | 处方ID |
SendOutMedicineNo | bit | 发药否 |
SkinTestID | int | 皮试ID |
UsageID | int | 用法ID |
UseMedicineFrequencyID | int | 用药频率ID |
AtEveryTurnNumber | decimal (18) | 每次数量 |
AtEveryTurnDoseID | int | 每次剂量ID |
PayMoney | decimal (18, 2) | 自付金额 |
OfficeID | int | 科室ID |
RetreatMedicineNumber | decimal (18) | 退药数量 |
InhospitalNo | bit | 住院否 |
2:保存处方功能实现
第一步:数据库的存储过程
处方单储存过程
if(@Type='Frm_MenZhenYiShengGongZuoZhan_InsertChuFangDan')
begin
begin tran
insert MZ_PrescriptionBillsList(MenZhenRegisterID, PrescriptionNumber, TieNumber,
OpenBillsDate, DealWithNo, SettleAccountsNo,Diagnosis,RefundNo)
values (@MenZhenRegisterID, @PrescriptionNumber, @TieNumber,
@OpenBillsDate, @DealWithNo, @SettleAccountsNo,@Diagnosis,0)
select @@IDENTITY
commit tran
end
处方单明细储存过程
if(@Type='Frm_MenZhenYiShengGongZuoZhan_InsertChuFangDanMingXi')
begin
insert MZ_PrescriptionBillsMingXiList(MedicineID, Number, PrescriptionBillsID, SendOutMedicineNo,
SkinTestID, UsageID, UseMedicineFrequencyID,
AtEveryTurnNumber, AtEveryTurnDoseID, PayMoney,OfficeID,ChargeNo)
values (@MedicineID, @Number, @PrescriptionBillsID, @SendOutMedicineNo,
@SkinTestID, @UsageID, @UseMedicineFrequencyID,
@AtEveryTurnNumber, @AtEveryTurnDoseID, @PayMoney,@OfficeID,0)
end
第二步:逻辑层(BLL)代码
处方单BLL
if(@Type='Frm_MenZhenYiShengGongZuoZhan_InsertChuFangDan')
begin
begin tran
insert MZ_PrescriptionBillsList(MenZhenRegisterID, PrescriptionNumber, TieNumber,
OpenBillsDate, DealWithNo, SettleAccountsNo,Diagnosis,RefundNo)
values (@MenZhenRegisterID, @PrescriptionNumber, @TieNumber,
@OpenBillsDate, @DealWithNo, @SettleAccountsNo,@Diagnosis,0)
select @@IDENTITY
commit tran
end
处方单明细BLL
if(@Type='Frm_MenZhenYiShengGongZuoZhan_InsertChuFangDanMingXi')
begin
insert MZ_PrescriptionBillsMingXiList(MedicineID, Number, PrescriptionBillsID, SendOutMedicineNo,
SkinTestID, UsageID, UseMedicineFrequencyID,
AtEveryTurnNumber, AtEveryTurnDoseID, PayMoney,OfficeID,ChargeNo)
values (@MedicineID, @Number, @PrescriptionBillsID, @SendOutMedicineNo,
@SkinTestID, @UsageID, @UseMedicineFrequencyID,
@AtEveryTurnNumber, @AtEveryTurnDoseID, @PayMoney,@OfficeID,0)
end
第三步:界面层(UIL)代码
#region
//声明变量
int intMedicineID;
int Count;
int intMenZhenRegisterID;
string strPrescriptionNumber;
decimal decTieNumber;
DateTime dtmOpenBillsDate;
bool bitDealWithNo;
bool bitSettleAccountsNo;
string strDiagnosis;
int intPrescriptionBillsID;
DataTable dt;
int intPrescriptionBills;
int intPrescriptionBillsIDMingXi;
private void btSave_Click(object sender, EventArgs e)
{
if (dgvMedicineInformation.Rows.Count == 0)//如果dgvMedicineInformation行数为零,提示
{
MessageBox.Show("还没添加药品");
return;
}
for (int K = 0; K < dgvMedicineInformation.Rows.Count; K++)
//遍历循环,如果dgvMedicineInformation的cbo还没选择,提示
{
int intSkinTestID = Convert.ToInt32(dgvMedicineInformation.Rows[K].Cells["SkinTestNo"].Value);
int intUsageID = Convert.ToInt32(dgvMedicineInformation.Rows[K].Cells["Usage"].Value);
int intUseMedicineFrequencyID = Convert.ToInt32(dgvMedicineInformation.Rows[K].Cells["UseMedicineFrequency"].Value);
int intAtEveryTurnDoseID = Convert.ToInt32(dgvMedicineInformation.Rows[K].Cells["AtEveryTurnDose"].Value);
int intOfficeID = Convert.ToInt32(dgvMedicineInformation.Rows[K].Cells["OfficeName"].Value);
if (intSkinTestID == 0 || intUsageID == 0 || intUseMedicineFrequencyID == 0 || intAtEveryTurnDoseID == 0 || intOfficeID == 0) //判断dgvMedicineInformation里面的cbo值是否为空
{
MessageBox.Show("尊敬的操作员,你还有东西没写完整呢?");
return;
}
}
intMenZhenRegisterID=PublicStatic.intMenZhenGuaHaoID;
strPrescriptionNumber=ShengChengDanHao(ZuiDaDingDanShu);
decTieNumber=Convert.ToDecimal(txtTieShu.Text);
dtmOpenBillsDate=DateTime.Now;
bitDealWithNo=true;
bitSettleAccountsNo = false;
strDiagnosis = "还没诊断";
dt = myFrm_MenZhenYiShengGongZuoZhanClient.Frm_MenZhenYiShengGongZuoZhan_InsertChuFangDan(intMenZhenRegisterID,
strPrescriptionNumber, decTieNumber, dtmOpenBillsDate, bitDealWithNo,
bitSettleAccountsNo, strDiagnosis).Tables[0];//新增处方单
intPrescriptionBills = Convert.ToInt32(dt.Rows[0][0]);//获取刚新增处方单的intPrescriptionBillsID
intPrescriptionBillsID = intPrescriptionBills;//给intPrescriptionBillsID赋值
myFrm_MenZhenYiShengGongZuoZhanClient.Frm_MenZhenYiShengGongZuoZhan_ZuiDaDanHaoShu();//修改最大单据数
int J=0;
int Seccess=0;
decimal decSumNumber=0;
foreach (DataGridViewRow dgvr in dgvMedicineInformation.Rows)
//病历dgvYaoPinXinXi,获取每一行的数据
{
intMedicineID = Convert.ToInt32(dgvr.Cells["MedicineID"].Value);
decimal decNumber = Convert.ToDecimal(dgvr.Cells["SumNumber"].Value);
bool bitSendOutMedicineNo=false;
int intSkinTestID = Convert.ToInt32(dgvr.Cells["SkinTestNo"].Value);
int intUsageID = Convert.ToInt32(dgvr.Cells["Usage"].Value);
int intUseMedicineFrequencyID = Convert.ToInt32(dgvr.Cells["UseMedicineFrequency"].Value);
decimal decAtEveryTurnNumber = Convert.ToDecimal(dgvr.Cells["AtEveryTurnNumber"].Value);
int intAtEveryTurnDoseID = Convert.ToInt32(dgvr.Cells["AtEveryTurnDose"].Value);
int intOfficeID = Convert.ToInt32(dgvr.Cells["OfficeName"].Value);
decimal decPayMoney = Convert.ToDecimal(dgvr.Cells["PayMoney"].Value);
decSumNumber = Convert.ToDecimal(dgvr.Cells["SumNumber"].Value);
int intStoreroomID = Convert.ToInt32(dgvr.Cells["StoreroomID"].Value);
myFrm_MenZhenYiShengGongZuoZhanClient.Frm_MenZhenYiShengGongZuoZhan_UpdateKuCunShu(decSumNumber, intMedicineID, intStoreroomID);
//根据药品ID和库房ID来修改库存数
J = myFrm_MenZhenYiShengGongZuoZhanClient.Frm_MenZhenYiShengGongZuoZhan_InsertChuFangDanMingXi(intMedicineID, decNumber,
intPrescriptionBillsID, bitSendOutMedicineNo, intSkinTestID, intUsageID, intUseMedicineFrequencyID, decAtEveryTurnNumber,
intAtEveryTurnDoseID, decPayMoney, intOfficeID);
}
if (J > 0 || Seccess > 0)
{
MessageBox.Show("保存成功!");
dgvMedicineInformation.Rows.Clear();
Frm_MenZhenYiShengGongZuoZhan_Load(null,null);//刷新
}
}
#endregion
编辑结束总数量单元格结束时改变自付金额和总金额
#region dgvMedicineInformation编辑状态事件时发生
int intYaoPinID; decimal JinE;
private void dgvMedicineInformation_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
try
{
intMedicineID2 = Convert.ToInt32(dgvMedicineInformation.CurrentRow.Cells["MedicineID"].Value);
DataTable dt = myFrm_MenZhenHuaJiaClient.Frm_MenZhenYiShengGongZuoZhan_SelectThirdPartyList(intYiLiaoFangShiID, intMedicineID2).Tables[0];
//根据医疗方式ID和药品ID查询折扣率
for (int i = 0; i < dgvMedicineInformation.Rows.Count; i++)//循环遍历dgvMedicineInformation的每一行
{
decimal ShuLiang = Convert.ToDecimal(dgvMedicineInformation.Rows[i].Cells["SumNumber"].Value);//获取dgvMedicineInformation每一行的数量
decimal DanJia = Convert.ToDecimal(dgvMedicineInformation.Rows[i].Cells["RetailPrice_J"].Value);//获取dgvMedicineInformation每一行的单价
decimal decAtEveryTurnNumber = Convert.ToDecimal(dgvMedicineInformation.Rows[i].Cells["AtEveryTurnNumber"].Value);
if (decAtEveryTurnNumber > ShuLiang)
{
MessageBox.Show("每次用的数量大于总数量,请重新输入");
return;
}
if (dt.Rows.Count > 0)//如果有折扣率就执行下面代码
{
decimal dec = Convert.ToDecimal(dt.Rows[0][0]);//获取折扣率
JinE = ShuLiang * DanJia;
dgvMedicineInformation.Rows[i].Cells["SumMoney"].Value = JinE.ToString("0.00"); ; //给dgvMedicineInformation每一行的总价赋值
dgvMedicineInformation.Rows[i].Cells["PayMoney"].Value = (JinE * dec).ToString("0.00");//总金额乘折扣率
intMedicineID2 = 0;
}
else//否则按原价
{
JinE = ShuLiang * DanJia;
dgvMedicineInformation.Rows[i].Cells["SumMoney"].Value = JinE.ToString("0.00"); //给dgvMedicineInformation每一行的总价赋值
dgvMedicineInformation.Rows[i].Cells["PayMoney"].Value = JinE;
}
}
decimal decZiFuJinE = 0;
decimal ShiShouJinE = 0;
for (int i = 0; i < dgvMedicineInformation.Rows.Count; i++)
{
decZiFuJinE = Convert.ToDecimal(dgvMedicineInformation.Rows[i].Cells["PayMoney"].Value);
ShiShouJinE += decZiFuJinE;//自付金额累加
}
txtSum.Text = ShiShouJinE.ToString(); //给文本框txtSum赋值
}
catch { }
}
#endregion
dgv数量和总数量的单元格只可以输入数字
public DataGridViewTextBoxEditingControl CellEdit = null;//声明一个CellEdit对象
private void dgvMedicineInformation_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
try
{
CellEdit = (DataGridViewTextBoxEditingControl)e.Control;//赋值CellEdit.SelectAll();
CellEdit.KeyPress += dgvMedicineInformation_KeyPress;//绑定控件
}
catch { }
}
private void dgvMedicineInformation_KeyPress(object sender, KeyPressEventArgs e)
{
if (dgvMedicineInformation.CurrentCellAddress.X == 9 || dgvMedicineInformation.CurrentCellAddress.X == 10)
{//当列索引为9、10时
if (!char.IsDigit(e.KeyChar) && !char.IsControl(e.KeyChar))
{//只可以输入数字和控制字符
e.Handled = true;
}
}
}
移除处方,从最后一行移除
#region 从最后一行开始移除
private void btnDeleteMedicinal_Click_1(object sender, EventArgs e)
{
if (dgvMedicineInformation.Rows.Count > 0)
{
dgvMedicineInformation.Rows.RemoveAt(dgvMedicineInformation.Rows.Count - 1);//从最后一行逐渐移除
}
}
#endregion
3:保存处方套餐
基本操作和保存处方一样,唯一不同的是就是选择处方的时候,如图(3):
图(3)
输入对应的拼音码就可以选择对应的套餐,方便操作。
代码如下:
在这个窗体跨窗体传值
Frm_MenZhenYiShengGongZuoZhanFrm;
publicFrm_MenZhenGongZuoZhanTaoCan(Frm_MenZhenYiShengGongZuoZhan frm)//跨窗体传值
{
Frm = frm;
InitializeComponent();
}
传值的时候把你需要的药品选择打钩:
private void btnSure_Click(object sender, EventArgs e)
{
foreach (DataGridViewRow dgvr in dgvMedicinalInformation.Rows)
{
bool 是否选中 = (bool)dgvr.Cells["check"].FormattedValue;
if (是否选中)
{
int rowIndex = Frm.dgvDealWithInformation.Rows.Add();
Frm.dgvDealWithInformation.Rows[rowIndex].Cells["MedicineID2"].Value = dgvr.Cells["MedicineID"].Value;
Frm.dgvDealWithInformation.Rows[rowIndex].Cells["MedicineName2"].Value = dgvr.Cells["MedicineName"].Value;
Frm.dgvDealWithInformation.Rows[rowIndex].Cells["Specification2"].Value = dgvr.Cells["Specification"].Value;
Frm.dgvDealWithInformation.Rows[rowIndex].Cells["RetailPrice_J2"].Value = dgvr.Cells["RetailPrice_J"].Value;
Frm.dgvDealWithInformation.Rows[rowIndex].Cells["ParturitionManufacturers2"].Value = dgvr.Cells["ParturitionManufacturers"].Value;
Frm.dgvDealWithInformation.Rows[rowIndex].Cells["MeteringUnit2"].Value = dgvr.Cells["MeteringUnit"].Value;
Frm.dgvDealWithInformation.Rows[rowIndex].Cells["StoreroomID2"].Value = dgvr.Cells["StoreroomID"].Value;
Frm.dgvDealWithInformation.Rows[rowIndex].Cells["MedicineName2"].ReadOnly = true;
Frm.dgvDealWithInformation.Rows[rowIndex].Cells["Number"].Value = "1";
}
this.Close();
}
}
就可以把你需要的药品一起传到主窗体了,然后填完完整信息,保存。保存套餐代码和保存不是套餐的代码一样,就不详细说明了。录入处方的过程就到这里结束了。
仅供参考,禁止用于商业用途,违者后果自负