184 lines
6.5 KiB
C#
184 lines
6.5 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 frmMedicalItem : Form
|
|
{
|
|
public AIMSExtension.EditState _state;
|
|
public int SelectMedicalItemRowId = 0;
|
|
public frmMedicalItem()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void frmMedicalItem_Load(object sender, EventArgs e)
|
|
{
|
|
this.treeView1.BackColor = System.Drawing.Color.Snow;
|
|
InitTreeView();
|
|
}
|
|
private void InitTreeView()
|
|
{
|
|
treeView1.Nodes.Clear();
|
|
AIMSExtension.PublicMethod.SetDgvAttribute(dgvMedicalItem);
|
|
AIMSExtension.PublicMethod.SetDgvAttribute(dgvMedicamentPrice);
|
|
_state = AIMSExtension.EditState.BROWSE;
|
|
DataTable dt = AIMSExtension.PublicMethod.GetNewDataTable(BMedicalItemKind.GetDataTable(), "IsMed='药品'", "");
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
TreeNode Node = treeView1.Nodes.Add(dt.Rows[i]["Id"].ToString(), dt.Rows[i]["Name"].ToString());
|
|
DataTable dt1 = BDrugKind.GetDataTable(dt.Rows[i]["Id"].ToString());
|
|
for (int j = 0; j < dt1.Rows.Count; j++)
|
|
{
|
|
Node.Nodes.Add(dt1.Rows[j]["Id"].ToString(), dt1.Rows[j]["Name"].ToString());
|
|
}
|
|
}
|
|
}
|
|
|
|
private void tsbAdd_Click(object sender, EventArgs e)
|
|
{
|
|
frmMedicalItemDetail frmMedicalItemDetail = new frmMedicalItemDetail();
|
|
frmMedicalItemDetail._State = AIMSExtension.EditState.ADD;
|
|
TreeNode sNode = treeView1.SelectedNode;
|
|
|
|
if (sNode != null)
|
|
{
|
|
DrugKind DrugKindObj = new DrugKind();
|
|
frmMedicalItemDetail.DrugKindId =int.Parse(sNode.Name);
|
|
}
|
|
|
|
frmMedicalItemDetail.ShowDialog();
|
|
}
|
|
|
|
private void tsbModify_Click(object sender, EventArgs e)
|
|
{
|
|
if (dgvMedicalItem.Rows.Count > 0)
|
|
{
|
|
frmMedicalItemDetail frmMedicalItemDetail = new frmMedicalItemDetail();
|
|
frmMedicalItemDetail._State = AIMSExtension.EditState.EDIT;
|
|
frmMedicalItemDetail.MedicalItemEditId = int.Parse(dgvMedicalItem.CurrentRow.Cells["Id"].Value.ToString());
|
|
frmMedicalItemDetail.ShowDialog();
|
|
}
|
|
}
|
|
private void tsbExit_Click(object sender, EventArgs e)
|
|
{
|
|
Close();
|
|
}
|
|
|
|
private void btnFind_Click(object sender, EventArgs e)
|
|
{
|
|
int IsValid = 0;
|
|
if (chkIsValid.Checked)
|
|
{
|
|
IsValid = 1;
|
|
}
|
|
dgvMedicalItem.DataSource = BMedicalItem.GetMedicalItemDrugDataTable(txtInput.Text.Trim(), IsValid);
|
|
if (dgvMedicalItem.Rows.Count > 0)
|
|
{
|
|
dgvMedicalItem.ClearSelection();
|
|
dgvMedicalItem.Rows[0].Selected = false;
|
|
dgvMedicalItem.Rows[dgvMedicalItem.Rows.Count - 1].Selected = true;
|
|
}
|
|
|
|
}
|
|
|
|
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
|
|
{
|
|
TreeNode sNode = treeView1.SelectedNode;
|
|
|
|
if (sNode != null)
|
|
{
|
|
DrugKind DrugKindObj = new DrugKind();
|
|
dgvMedicalItem.DataSource = BMedicalItem.GetMedicalItemByDrugKindId(int.Parse(sNode.Name));
|
|
}
|
|
|
|
}
|
|
|
|
private void btnAddPrice_Click(object sender, EventArgs e)
|
|
{
|
|
if (dgvMedicalItem.Rows.Count > 0)
|
|
{
|
|
frmMedicamentPrice frmMedicamentPrice = new frmMedicamentPrice();
|
|
frmMedicamentPrice._state = AIMSExtension.EditState.ADD;
|
|
frmMedicamentPrice.FormClosed += new FormClosedEventHandler(frmMedicamentPrice_FormClosed);
|
|
if (dgvMedicamentPrice.Rows.Count > 0)
|
|
{
|
|
frmMedicamentPrice.MedicamentPriceId = int.Parse(dgvMedicamentPrice.CurrentRow.Cells["IdColumn1"].Value.ToString());
|
|
}
|
|
frmMedicamentPrice.SelectRowMedicalItemObj = BMedicalItem.GetModel(int.Parse(dgvMedicalItem.CurrentRow.Cells["Id"].Value.ToString()));
|
|
frmMedicamentPrice.ShowDialog();
|
|
}
|
|
}
|
|
|
|
void frmMedicamentPrice_FormClosed(object sender, FormClosedEventArgs e)
|
|
{
|
|
//throw new NotImplementedException();
|
|
GetMedicamentPriceData();
|
|
}
|
|
|
|
private void btnDeletePrice_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
if (dgvMedicamentPrice.Rows.Count > 0)
|
|
{
|
|
frmMedicamentPrice frmMedicamentPrice = new frmMedicamentPrice();
|
|
frmMedicamentPrice._state = AIMSExtension.EditState.EDIT;
|
|
frmMedicamentPrice.MedicamentPriceId = int.Parse(dgvMedicamentPrice.CurrentRow.Cells["IdColumn1"].Value.ToString());
|
|
frmMedicamentPrice.FormClosed += new FormClosedEventHandler(frmMedicamentPrice_FormClosed);
|
|
frmMedicamentPrice.ShowDialog();
|
|
}
|
|
}
|
|
|
|
private void dgvMedicalItem_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
|
|
{
|
|
if (dgvMedicalItem.Rows.Count > 0)
|
|
{
|
|
GetMedicamentPriceData();
|
|
}
|
|
}
|
|
|
|
private void dgvMedicalItem_KeyPress(object sender, KeyPressEventArgs e)
|
|
{
|
|
if (dgvMedicalItem.CurrentRow != null)
|
|
{
|
|
GetMedicamentPriceData();
|
|
}
|
|
}
|
|
|
|
private void dgvMedicalItem_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.KeyData == Keys.Enter)
|
|
{
|
|
if (dgvMedicalItem.Rows.Count > 0)
|
|
{
|
|
GetMedicamentPriceData();
|
|
}
|
|
}
|
|
}
|
|
|
|
private void dgvMedicalItem_CurrentCellChanged(object sender, EventArgs e)
|
|
{
|
|
if (dgvMedicalItem.CurrentRow != null)
|
|
{
|
|
GetMedicamentPriceData();
|
|
}
|
|
}
|
|
private void GetMedicamentPriceData()
|
|
{
|
|
if (dgvMedicalItem.Rows.Count > 0)
|
|
{
|
|
int MedicalItemId = int.Parse(dgvMedicalItem.CurrentRow.Cells["Id"].Value.ToString());
|
|
dgvMedicamentPrice.DataSource = BMedicamentPrice.GetDataTable(MedicalItemId);
|
|
}
|
|
}
|
|
}
|
|
}
|