199 lines
7.6 KiB
C#
199 lines
7.6 KiB
C#
using AIMSBLL;
|
|
using AIMSModel;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
namespace DrugManagement.UI
|
|
{
|
|
public partial class frmMedicamentPrice : Form
|
|
{
|
|
public AIMSExtension.EditState _state;
|
|
public MedicalItem SelectRowMedicalItemObj;
|
|
public int DrugManufacturerId =0;
|
|
public string DrugManufacturerName;
|
|
private frmDrugManufacturerList frmDrugManufacturerList;
|
|
public int MedicamentPriceId = 0;
|
|
public frmMedicamentPrice()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void frmMedicamentPrice_Load(object sender, EventArgs e)
|
|
{
|
|
int x = (System.Windows.Forms.SystemInformation.WorkingArea.Width - this.Size.Width) / 2;
|
|
int y = (System.Windows.Forms.SystemInformation.WorkingArea.Height - this.Size.Height) / 2 -150;
|
|
this.StartPosition = FormStartPosition.Manual;
|
|
this.Location = (Point)new Size(x, y);
|
|
|
|
|
|
if (_state == AIMSExtension.EditState.ADD)
|
|
{
|
|
txtNo.Enabled = false;
|
|
txtName.Enabled = false;
|
|
txtPackingUnit.Enabled = false;
|
|
|
|
txtNo.Text = SelectRowMedicalItemObj.No;
|
|
txtName.Text = SelectRowMedicalItemObj.Name;
|
|
txtPackingUnit.Text = SelectRowMedicalItemObj.PackingUnit;
|
|
|
|
chkIsValid.Checked = true;
|
|
}
|
|
if (_state == AIMSExtension.EditState.EDIT)
|
|
{
|
|
|
|
txtNo.Enabled = false;
|
|
txtName.Enabled = false;
|
|
txtPackingUnit.Enabled = false;
|
|
txtPurchasePrice.Enabled = false;
|
|
txtTradePrice.Enabled = false;
|
|
txtRetailPrice.Enabled = false;
|
|
txtDrugManufacturer.Enabled = false;
|
|
|
|
MedicamentPrice MedicamentPriceObj = BMedicamentPrice.GetModel(MedicamentPriceId);
|
|
MedicalItem MedicalItemObj = BMedicalItem.GetModel(MedicamentPriceObj.MedicalItemId.Value);
|
|
txtNo.Text = MedicalItemObj.No;
|
|
txtName.Text = MedicalItemObj.Name;
|
|
txtPackingUnit.Text = MedicalItemObj.PackingUnit;
|
|
|
|
txtDrugManufacturer.Text = BDrugManufacturer.GetModel(MedicamentPriceObj.DrugManufacturerId.Value).Name;
|
|
txtPurchasePrice.Text = MedicamentPriceObj.PurchasePrice.ToString();
|
|
txtRetailPrice.Text = MedicamentPriceObj.RetailPrice.ToString();
|
|
txtTradePrice.Text = MedicamentPriceObj.TradePrice.ToString();
|
|
|
|
|
|
if (MedicamentPriceObj.IsValid == 1)
|
|
{
|
|
chkIsValid.Checked = true;
|
|
}
|
|
else
|
|
{
|
|
chkIsValid.Checked = false;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private void btnDrugManufacturer_Click(object sender, EventArgs e)
|
|
{
|
|
frmDrugManufacturerList = new frmDrugManufacturerList();
|
|
frmDrugManufacturerList.FormClosed += new FormClosedEventHandler(frmDrugManufacturerList_FormClosed);
|
|
frmDrugManufacturerList.ShowDialog();
|
|
|
|
}
|
|
|
|
void frmDrugManufacturerList_FormClosed(object sender, FormClosedEventArgs e)
|
|
{
|
|
DrugManufacturerId = frmDrugManufacturerList.DrugManufacturerId;
|
|
txtDrugManufacturer.Text = frmDrugManufacturerList.DrugManufacturerName;
|
|
DrugManufacturerName = frmDrugManufacturerList.DrugManufacturerName;
|
|
txtPurchasePrice.Select();
|
|
txtPurchasePrice.Focus();
|
|
|
|
|
|
}
|
|
|
|
private void btnReturn_Click(object sender, EventArgs e)
|
|
{
|
|
Close();
|
|
}
|
|
|
|
private void txtPurchasePrice_KeyPress(object sender, KeyPressEventArgs e)
|
|
{
|
|
AIMSExtension.PublicMethod.KeyPressByIsMatch(e, txtPurchasePrice);
|
|
}
|
|
|
|
private void txtTradePrice_KeyPress(object sender, KeyPressEventArgs e)
|
|
{
|
|
AIMSExtension.PublicMethod.KeyPressByIsMatch(e, txtTradePrice);
|
|
}
|
|
|
|
private void txtRetailPrice_KeyPress(object sender, KeyPressEventArgs e)
|
|
{
|
|
AIMSExtension.PublicMethod.KeyPressByIsMatch(e, txtRetailPrice);
|
|
}
|
|
|
|
private void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (ValidInput())
|
|
{
|
|
if (txtDrugManufacturer.Text == DrugManufacturerName)
|
|
{
|
|
if (_state == AIMSExtension.EditState.ADD)
|
|
{
|
|
MedicamentPrice MedicamentPriceObj = new MedicamentPrice();
|
|
MedicamentPriceObj.MedicalItemId = SelectRowMedicalItemObj.Id;
|
|
MedicamentPriceObj.DrugManufacturerId = DrugManufacturerId;
|
|
MedicamentPriceObj.PurchasePrice = decimal.Parse(txtPurchasePrice.Text.Trim());
|
|
MedicamentPriceObj.TradePrice = decimal.Parse(txtTradePrice.Text.Trim());
|
|
MedicamentPriceObj.RetailPrice = decimal.Parse(txtRetailPrice.Text.Trim());
|
|
MedicamentPriceObj.IsValid = int.Parse(chkIsValid.Checked ? "1" : "0");
|
|
MedicamentPriceObj.OperatorNo = AIMSExtension.PublicMethod.OperatorNo;
|
|
MedicamentPriceObj.OperatorName = AIMSExtension.PublicMethod.OperatorName;
|
|
MedicamentPriceObj.OperateDate = AIMSExtension.PublicMethod.SystemDate();
|
|
BMedicamentPrice.Add(MedicamentPriceObj);
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("厂家名称只能选择!");
|
|
}
|
|
}
|
|
|
|
if (_state == AIMSExtension.EditState.EDIT)
|
|
{
|
|
MedicamentPrice MedicamentPriceObj = new MedicamentPrice();
|
|
MedicamentPriceObj.Id = MedicamentPriceId;
|
|
MedicamentPriceObj.IsValid = int.Parse(chkIsValid.Checked ? "1" : "0");
|
|
MedicamentPriceObj.OperatorNo = AIMSExtension.PublicMethod.OperatorNo;
|
|
MedicamentPriceObj.OperatorName = AIMSExtension.PublicMethod.OperatorName;
|
|
MedicamentPriceObj.OperateDate = AIMSExtension.PublicMethod.SystemDate();
|
|
BMedicamentPrice.Update(MedicamentPriceObj);
|
|
}
|
|
Close();
|
|
}
|
|
}
|
|
private bool ValidInput()
|
|
{
|
|
bool result = false;
|
|
|
|
if (txtNo.Text.Trim().Length < 1)
|
|
{
|
|
MessageBox.Show("编码不能为空!");
|
|
}
|
|
else if (txtName.Text.Trim().Length < 1)
|
|
{
|
|
MessageBox.Show("名称不能为空!");
|
|
}
|
|
else if (txtDrugManufacturer.Text.Trim().Length < 1)
|
|
{
|
|
MessageBox.Show("厂家不能为空!");
|
|
}
|
|
else if (this.txtPurchasePrice.Text.Trim().Length < 1)
|
|
{
|
|
MessageBox.Show("进价不能为空!");
|
|
}
|
|
else if (this.txtTradePrice.Text.Trim().Length < 1)
|
|
{
|
|
MessageBox.Show("批发价格不能为空!");
|
|
}
|
|
else if (this.txtRetailPrice.Text.Trim().Length < 1)
|
|
{
|
|
MessageBox.Show("零售价格不能为空!");
|
|
}
|
|
else
|
|
{
|
|
result = true;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
}
|
|
}
|