📄 patientframe.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Drawing.Printing;
using System.Text;
using System.Windows.Forms;
using Youzi.Model;
using Youzi.BLL;
namespace Youzi.View
{
public partial class PatientFrame : Form
{
public PatientFrame()
{
InitializeComponent();
}
private void PatientFrame_Load(object sender, EventArgs e)
{
PatientBLL bll = new PatientBLL();
DataSet ds1 = new DataSet();
DataSet ds2 = new DataSet();
ds1 = bll.Select();
ds2 = bll.SelectRegisterType();
dataGridView1.DataSource = ds1.Tables[0];
dataGridView2.DataSource = ds2.Tables[0];
cboCureType.Items.Add("初诊");
cboCureType.Items.Add("复诊");
cboCureType.SelectedItem = "初诊";
cboSex.Items.Add("男");
cboSex.Items.Add("女");
cboSex.SelectedItem = "男";
cboAge.Items.Add("岁");
cboAge.Items.Add("月");
cboAge.Items.Add("日");
cboAge.SelectedItem = "岁";
txtOperateDate.Text = DateTime.Now.ToString();
txtOperator.Text = Users.userName;
}
private void button4_Click(object sender, EventArgs e)
{
this.Hide();
}
private void button3_Click(object sender, EventArgs e)
{
ClearField();
}
private void ClearField()
{
txtUserName.Text = "";
txtAge.Text = "";
txtDepartment.Text = "";
txtAddress.Text = "";
txtOfficeName.Text = "";
txtCureCost.Text = "";
cboDoctorName.Items.Clear();
txtRegisterType.Text = "";
txtRegisterCost.Text = "";
txtOperateDate.Text = DateTime.Now.ToString();
}
private void dataGridView1_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
int index = dataGridView1.CurrentRow.Index;
txtOfficeName.Text = dataGridView1[0, index].Value.ToString();
txtCureCost.Text = dataGridView1[1, index].Value.ToString();
cboDoctorName.Items.Clear();
string DoctorName = dataGridView1[2, index].Value.ToString();
cboDoctorName.Items.Add(DoctorName);
cboDoctorName.SelectedItem = DoctorName;
}
private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
int index = dataGridView1.CurrentRow.Index;
txtOfficeName.Text = dataGridView1[0, index].Value.ToString();
txtCureCost.Text = dataGridView1[1, index].Value.ToString();
cboDoctorName.Items.Clear();
string DoctorName = dataGridView1[2, index].Value.ToString();
cboDoctorName.Items.Add(DoctorName);
cboDoctorName.SelectedItem = DoctorName;
}
private void dataGridView2_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
int index = dataGridView2.CurrentRow.Index;
txtRegisterType.Text = dataGridView2[0, index].Value.ToString();
txtRegisterCost.Text = dataGridView2[1, index].Value.ToString();
}
private void dataGridView2_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
int index = dataGridView2.CurrentRow.Index;
txtRegisterType.Text = dataGridView2[0, index].Value.ToString();
txtRegisterCost.Text = dataGridView2[1, index].Value.ToString();
}
private void butRegister_Click(object sender, EventArgs e)
{
if (txtUserName.Text == string.Empty)
{
MessageBox.Show("用户名不能为空");
return;
}
if (txtAge.Text == string.Empty)
{
MessageBox.Show("年龄不能为空");
return;
}
if (txtDepartment.Text == string.Empty)
{
MessageBox.Show("单位不能为空");
return;
}
if (txtAddress.Text == string.Empty)
{
MessageBox.Show("住址不能为空");
return;
}
if (txtOfficeName.Text == string.Empty)
{
MessageBox.Show("就诊科室不能为空");
return;
}
if (txtCureCost.Text == string.Empty)
{
MessageBox.Show("诊疗费用不能为空");
return;
}
if (txtOfficeName.Text == string.Empty)
{
MessageBox.Show("科室名称不能为空");
return;
}
if (cboDoctorName.Text == string.Empty)
{
MessageBox.Show("医师名称不能为空");
return;
}
if (txtRegisterType.Text == string.Empty)
{
MessageBox.Show("挂号名称不能为空");
return;
}
if (txtRegisterCost.Text == string.Empty)
{
MessageBox.Show("挂号费不能为空");
return;
}
try
{
PatientBLL pbll = new PatientBLL();
PatientInfo pentity = new PatientInfo();
pentity.PatientName = txtUserName.Text;
pentity.PatientSex = cboSex.Text;
pentity.PatientAge = txtAge.Text;
pentity.Department = txtDepartment.Text;
pentity.Address = txtAddress.Text;
pentity.OperateDate = txtOperateDate.Text;
pentity.Operator = txtOperator.Text;
int i = pbll.InsertPatient(pentity);
RegisterBLL rbll = new RegisterBLL();
RegisterInfo rentity = new RegisterInfo();
rentity.PatientInfo.PatientName = txtUserName.Text;
rentity.CureType = cboCureType.Text;
rentity.OfficeInfo.CureCost = txtCureCost.Text;
rentity.RegisterTypeInfo.RegisterTypeName = txtRegisterType.Text;
rentity.RegisterTypeInfo.RegisterTypeCost = txtRegisterCost.Text;
rentity.OfficeInfo.OfficeName = txtOfficeName.Text;
rentity.DoctorInfo.DoctorName = cboDoctorName.Text;
rentity.OperateDate = txtOperateDate.Text;
rentity.Operator = txtOperator.Text;
int ii = rbll.InsertRegister(rentity);
if (i > 0 && ii > 0)
{
MessageBox.Show("挂号成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
ClearField();
//打印预览
TestPrintDoc printDoc = new TestPrintDoc(rentity); //传一个实体过去
PrintPreviewDialog ppd = new PrintPreviewDialog();
ppd.Document = printDoc;
//设置打印预览的页面设置
ppd.Document.DefaultPageSettings = pageSetting;
ppd.ShowDialog();
}
}
catch (SqlException ex)
{
MessageBox.Show( ex.Message);
}
}
PageSettings pageSetting = new PageSettings();
private void butPageSetting_Click(object sender, EventArgs e)
{
PageSetupDialog psd = new PageSetupDialog();
psd.PageSettings = pageSetting;
psd.ShowDialog();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -