📄 sy_hsxc.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data;
namespace PDA_test
{
/// <summary>
/// SY_HSXC 的摘要说明。
/// </summary>
public class SY_HSXC : System.Windows.Forms.Form
{
public System.Data.SqlClient.SqlConnection Sql_conn_str;
public string cf_no ;//处方号
public string br_jbxx;//病人基本信息
public string mzh;//门诊号码
public string ch;//床号
private System.Windows.Forms.TextBox textBox_brjbxx;
private System.Windows.Forms.TextBox textBox_ywsyqk;
private System.Windows.Forms.Button button_start;
private System.Windows.Forms.Button button_end;
private System.Windows.Forms.Button button_back;
private System.Data.SqlClient.SqlDataAdapter sql_da;
private System.Data.SqlClient.SqlCommandBuilder sql_cb;
private System.Data.SqlClient.SqlDataReader sql_dr;
private System.Data.SqlClient.SqlCommand sql_cmd;
private System.Windows.Forms.ListBox listBox1;
private System.Data.DataTable data_test;
public SY_HSXC()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.textBox_brjbxx = new System.Windows.Forms.TextBox();
this.textBox_ywsyqk = new System.Windows.Forms.TextBox();
this.button_start = new System.Windows.Forms.Button();
this.button_end = new System.Windows.Forms.Button();
this.button_back = new System.Windows.Forms.Button();
this.listBox1 = new System.Windows.Forms.ListBox();
//
// textBox_brjbxx
//
this.textBox_brjbxx.Location = new System.Drawing.Point(16, 8);
this.textBox_brjbxx.Size = new System.Drawing.Size(208, 21);
this.textBox_brjbxx.Text = "";
//
// textBox_ywsyqk
//
this.textBox_ywsyqk.Location = new System.Drawing.Point(16, 32);
this.textBox_ywsyqk.Size = new System.Drawing.Size(208, 21);
this.textBox_ywsyqk.Text = "";
//
// button_start
//
this.button_start.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular);
this.button_start.Location = new System.Drawing.Point(8, 232);
this.button_start.Size = new System.Drawing.Size(72, 32);
this.button_start.Text = "开始";
this.button_start.Click += new System.EventHandler(this.button_start_Click);
//
// button_end
//
this.button_end.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular);
this.button_end.Location = new System.Drawing.Point(88, 232);
this.button_end.Size = new System.Drawing.Size(72, 32);
this.button_end.Text = "完成";
this.button_end.Click += new System.EventHandler(this.button_end_Click);
//
// button_back
//
this.button_back.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular);
this.button_back.Location = new System.Drawing.Point(168, 232);
this.button_back.Size = new System.Drawing.Size(72, 32);
this.button_back.Text = "返回";
this.button_back.Click += new System.EventHandler(this.button_back_Click);
//
// listBox1
//
this.listBox1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular);
this.listBox1.Location = new System.Drawing.Point(16, 56);
this.listBox1.Size = new System.Drawing.Size(208, 162);
//
// SY_HSXC
//
this.Controls.Add(this.listBox1);
this.Controls.Add(this.button_back);
this.Controls.Add(this.button_end);
this.Controls.Add(this.button_start);
this.Controls.Add(this.textBox_ywsyqk);
this.Controls.Add(this.textBox_brjbxx);
this.Text = "SY_HSXC";
this.Load += new System.EventHandler(this.SY_HSXC_Load);
}
#endregion
private void SY_HSXC_Load(object sender, System.EventArgs e)
{
//MessageBox.Show(this.Sql_conn_str.ToString());
this.textBox_brjbxx.Text=this.br_jbxx.ToString();
this.textBox_ywsyqk.Text=this.cf_no.ToString();
string lc_sql_cmd="select * from 输液_配药明细 where 处方编号='"+this.cf_no.ToString().Trim()+"'";
data_test=new DataTable();
try
{
string sql_conn=this.Sql_conn_str.ConnectionString.ToString().Trim();
this.Sql_conn_str=new SqlConnection(sql_conn);
this.Sql_conn_str.Open();
sql_da =new SqlDataAdapter(lc_sql_cmd, Sql_conn_str);
sql_cb =new SqlCommandBuilder( sql_da );
sql_da.Fill(data_test);
this.Sql_conn_str.Close();
//this.dataGrid1.DataSource=data_test;
}
catch (SqlException ex)
{
MessageBox.Show( "Error connecting to the server: " + ex.Message );
}
//对list控件进行赋值
this.listBox1.Items.Clear();
if (this.data_test.Rows.Count>0)
{
string lcnr="";
foreach (DataRow tmp_DR in data_test.Rows)
{
lcnr="";
lcnr=tmp_DR["名称"].ToString()+","+tmp_DR["剂量"].ToString()+tmp_DR["单位"].ToString()+","+tmp_DR["规格"].ToString();
this.listBox1.Items.Add(lcnr);
}
}
}
private void button_back_Click(object sender, System.EventArgs e)
{
this.Hide();
}
private void button_start_Click(object sender, System.EventArgs e)
{
//输液开始
int lcret=0;
sql_cmd=new SqlCommand();
sql_cmd.Connection=Sql_conn_str;
string lc_bg_time=DateTime.Now.ToShortTimeString();
string up_cmd="update 输液_输液登记表 set 状态='2',备注= 备注+'开始时间:"+lc_bg_time.ToString()+"'"+
" where 状态='2' and 门诊号='"+mzh.ToString().Trim()+"' and 床位号='"+ch.ToString().Trim()+"'";
try
{
this.Sql_conn_str.Open();
//MessageBox.Show(up_cmd.ToString());
sql_cmd.CommandText=up_cmd.ToString();
lcret=sql_cmd.ExecuteNonQuery();
//sql_da =new SqlDataAdapter(up_cmd, Sql_conn_str);
//sql_cb =new SqlCommandBuilder( sql_da );
this.Sql_conn_str.Close();
MessageBox.Show(lcret.ToString());
}
catch (SqlException ex)
{
MessageBox.Show( "Error connecting to the server: " + ex.Message );
}
}
private void button_end_Click(object sender, System.EventArgs e)
{
//输液完成
int lcret=0;
sql_cmd=new SqlCommand();
sql_cmd.Connection=Sql_conn_str;
string lc_bg_time=DateTime.Now.ToShortTimeString();
string up_cmd="update 输液_输液登记表 set 状态='3',备注= 备注+'结束时间:"+lc_bg_time.ToString()+"'"+
" where 状态='2' and 门诊号='"+mzh.ToString().Trim()+"' and 床位号='"+ch.ToString().Trim()+"'";
try
{
this.Sql_conn_str.Open();
//MessageBox.Show(up_cmd.ToString());
sql_cmd.CommandText=up_cmd.ToString();
lcret=sql_cmd.ExecuteNonQuery();
//sql_da =new SqlDataAdapter(up_cmd, Sql_conn_str);
//sql_cb =new SqlCommandBuilder( sql_da );
this.Sql_conn_str.Close();
MessageBox.Show(lcret.ToString());
}
catch (SqlException ex)
{
MessageBox.Show( "Error connecting to the server: " + ex.Message );
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -