SendMedicine.cs
资源名称:VCSDB.rar [点击查看]
上传用户:hjieqiu
上传日期:2013-05-11
资源大小:16494k
文件大小:16k
源码类别:
企业管理
开发平台:
C#
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Data;
- using System.Data.SqlClient;
- namespace 医院管理系统
- {
- /// <summary>
- /// SendMedicine 的摘要说明。
- /// </summary>
- public class SendMedicine : System.Windows.Forms.Form
- {
- private System.Windows.Forms.DataGrid dataGrid2;
- private System.Data.DataView dataView2;
- private System.Windows.Forms.DataGrid dataGrid1;
- private System.Data.DataView dataView1;
- private System.Data.SqlClient.SqlDataAdapter da2;
- private System.Windows.Forms.GroupBox groupBox1;
- private System.Windows.Forms.Label label8;
- private System.Windows.Forms.Label label4;
- private System.Windows.Forms.Button btnSearch;
- private System.Windows.Forms.TextBox txt1;
- private System.Windows.Forms.TextBox txt2;
- private System.Windows.Forms.Label label5;
- private System.Windows.Forms.TextBox txt4;
- private System.Windows.Forms.TextBox txt3;
- private System.Windows.Forms.Label label6;
- private System.Windows.Forms.Label label7;
- private System.Data.SqlClient.SqlDataAdapter da1;
- private 医院管理系统.DataSet3 dataSet31;
- private System.Windows.Forms.Button btnSend;
- private System.Data.SqlClient.SqlCommand sqlSelectCommand2;
- private System.Data.SqlClient.SqlConnection sqlConnection1;
- private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
- /// <summary>
- /// 必需的设计器变量。
- /// </summary>
- private System.ComponentModel.Container components = null;
- public SendMedicine()
- {
- //
- // Windows 窗体设计器支持所必需的
- //
- InitializeComponent();
- //
- // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
- //
- }
- /// <summary>
- /// 清理所有正在使用的资源。
- /// </summary>
- protected override void Dispose( bool disposing )
- {
- if( disposing )
- {
- if(components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose( disposing );
- }
- #region Windows 窗体设计器生成的代码
- /// <summary>
- /// 设计器支持所需的方法 - 不要使用代码编辑器修改
- /// 此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(SendMedicine));
- this.dataGrid2 = new System.Windows.Forms.DataGrid();
- this.dataView2 = new System.Data.DataView();
- this.dataSet31 = new 医院管理系统.DataSet3();
- this.dataGrid1 = new System.Windows.Forms.DataGrid();
- this.dataView1 = new System.Data.DataView();
- this.da2 = new System.Data.SqlClient.SqlDataAdapter();
- this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
- this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.btnSend = new System.Windows.Forms.Button();
- this.label8 = new System.Windows.Forms.Label();
- this.label4 = new System.Windows.Forms.Label();
- this.btnSearch = new System.Windows.Forms.Button();
- this.txt1 = new System.Windows.Forms.TextBox();
- this.txt2 = new System.Windows.Forms.TextBox();
- this.label5 = new System.Windows.Forms.Label();
- this.txt4 = new System.Windows.Forms.TextBox();
- this.txt3 = new System.Windows.Forms.TextBox();
- this.label6 = new System.Windows.Forms.Label();
- this.label7 = new System.Windows.Forms.Label();
- this.da1 = new System.Data.SqlClient.SqlDataAdapter();
- this.sqlSelectCommand2 = new System.Data.SqlClient.SqlCommand();
- ((System.ComponentModel.ISupportInitialize)(this.dataGrid2)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataView2)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataSet31)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataView1)).BeginInit();
- this.groupBox1.SuspendLayout();
- this.SuspendLayout();
- //
- // dataGrid2
- //
- this.dataGrid2.CaptionVisible = false;
- this.dataGrid2.DataMember = "";
- this.dataGrid2.DataSource = this.dataView2;
- this.dataGrid2.HeaderForeColor = System.Drawing.SystemColors.ControlText;
- this.dataGrid2.Location = new System.Drawing.Point(0, 304);
- this.dataGrid2.Name = "dataGrid2";
- this.dataGrid2.ReadOnly = true;
- this.dataGrid2.Size = new System.Drawing.Size(712, 168);
- this.dataGrid2.TabIndex = 5;
- //
- // dataView2
- //
- this.dataView2.Table = this.dataSet31.门诊划价明细;
- //
- // dataSet31
- //
- this.dataSet31.DataSetName = "DataSet3";
- this.dataSet31.Locale = new System.Globalization.CultureInfo("zh-CN");
- //
- // dataGrid1
- //
- this.dataGrid1.CaptionVisible = false;
- this.dataGrid1.DataMember = "";
- this.dataGrid1.DataSource = this.dataView1;
- this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
- this.dataGrid1.Location = new System.Drawing.Point(0, 104);
- this.dataGrid1.Name = "dataGrid1";
- this.dataGrid1.ReadOnly = true;
- this.dataGrid1.Size = new System.Drawing.Size(712, 200);
- this.dataGrid1.TabIndex = 4;
- //
- // dataView1
- //
- this.dataView1.Table = this.dataSet31.门诊划价;
- //
- // da2
- //
- this.da2.SelectCommand = this.sqlSelectCommand1;
- this.da2.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
- new System.Data.Common.DataTableMapping("Table", "门诊划价明细", new System.Data.Common.DataColumnMapping[] {
- new System.Data.Common.DataColumnMapping("编号", "编号"),
- new System.Data.Common.DataColumnMapping("药品编号", "药品编号"),
- new System.Data.Common.DataColumnMapping("名称", "名称"),
- new System.Data.Common.DataColumnMapping("单价", "单价"),
- new System.Data.Common.DataColumnMapping("数量", "数量"),
- new System.Data.Common.DataColumnMapping("金额", "金额"),
- new System.Data.Common.DataColumnMapping("划价编号", "划价编号")})});
- //
- // sqlSelectCommand1
- //
- this.sqlSelectCommand1.CommandText = "SELECT DISTINCT a.编号, a.药品编号, b.名称, a.单价, a.数量, a.金额, a.划价编号 FROM 门诊划价明细 a INNER " +
- "JOIN v收费项目及药品 b ON a.药品编号 = b.编号";
- this.sqlSelectCommand1.Connection = this.sqlConnection1;
- //
- // sqlConnection1
- //
- this.sqlConnection1.ConnectionString = "workstation id=localhost;packet size=4096;integrated security=SSPI;data source="." +
- "";persist security info=False;initial catalog=hisbook";
- //
- // groupBox1
- //
- this.groupBox1.Controls.Add(this.btnSend);
- this.groupBox1.Controls.Add(this.label8);
- this.groupBox1.Controls.Add(this.label4);
- this.groupBox1.Controls.Add(this.btnSearch);
- this.groupBox1.Controls.Add(this.txt1);
- this.groupBox1.Controls.Add(this.txt2);
- this.groupBox1.Controls.Add(this.label5);
- this.groupBox1.Controls.Add(this.txt4);
- this.groupBox1.Controls.Add(this.txt3);
- this.groupBox1.Controls.Add(this.label6);
- this.groupBox1.Controls.Add(this.label7);
- this.groupBox1.Location = new System.Drawing.Point(0, 2);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(712, 100);
- this.groupBox1.TabIndex = 3;
- this.groupBox1.TabStop = false;
- this.groupBox1.Text = "搜索";
- //
- // btnSend
- //
- this.btnSend.Image = ((System.Drawing.Image)(resources.GetObject("btnSend.Image")));
- this.btnSend.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
- this.btnSend.Location = new System.Drawing.Point(608, 56);
- this.btnSend.Name = "btnSend";
- this.btnSend.TabIndex = 6;
- this.btnSend.Text = "发药";
- this.btnSend.Click += new System.EventHandler(this.btnSend_Click);
- //
- // label8
- //
- this.label8.Location = new System.Drawing.Point(352, 56);
- this.label8.Name = "label8";
- this.label8.Size = new System.Drawing.Size(144, 16);
- this.label8.TabIndex = 3;
- this.label8.Text = "格式如'2004-1-1'";
- //
- // label4
- //
- this.label4.Location = new System.Drawing.Point(64, 37);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(32, 16);
- this.label4.TabIndex = 2;
- this.label4.Text = "编号";
- //
- // btnSearch
- //
- this.btnSearch.Image = ((System.Drawing.Image)(resources.GetObject("btnSearch.Image")));
- this.btnSearch.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
- this.btnSearch.Location = new System.Drawing.Point(512, 56);
- this.btnSearch.Name = "btnSearch";
- this.btnSearch.Size = new System.Drawing.Size(80, 24);
- this.btnSearch.TabIndex = 1;
- this.btnSearch.Text = "搜索";
- this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
- //
- // txt1
- //
- this.txt1.Location = new System.Drawing.Point(96, 32);
- this.txt1.Name = "txt1";
- this.txt1.Size = new System.Drawing.Size(144, 21);
- this.txt1.TabIndex = 0;
- this.txt1.Text = "";
- //
- // txt2
- //
- this.txt2.Location = new System.Drawing.Point(96, 72);
- this.txt2.Name = "txt2";
- this.txt2.Size = new System.Drawing.Size(144, 21);
- this.txt2.TabIndex = 0;
- this.txt2.Text = "";
- //
- // label5
- //
- this.label5.Location = new System.Drawing.Point(64, 72);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(32, 16);
- this.label5.TabIndex = 2;
- this.label5.Text = "姓名";
- //
- // txt4
- //
- this.txt4.Location = new System.Drawing.Point(352, 72);
- this.txt4.Name = "txt4";
- this.txt4.Size = new System.Drawing.Size(144, 21);
- this.txt4.TabIndex = 0;
- this.txt4.Text = "";
- //
- // txt3
- //
- this.txt3.Location = new System.Drawing.Point(352, 32);
- this.txt3.Name = "txt3";
- this.txt3.Size = new System.Drawing.Size(144, 21);
- this.txt3.TabIndex = 0;
- this.txt3.Text = "";
- //
- // label6
- //
- this.label6.Location = new System.Drawing.Point(296, 36);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(56, 16);
- this.label6.TabIndex = 2;
- this.label6.Text = "开始时间";
- //
- // label7
- //
- this.label7.Location = new System.Drawing.Point(296, 76);
- this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(56, 16);
- this.label7.TabIndex = 2;
- this.label7.Text = "结束时间";
- //
- // da1
- //
- this.da1.SelectCommand = this.sqlSelectCommand2;
- this.da1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
- new System.Data.Common.DataTableMapping("Table", "门诊划价", new System.Data.Common.DataColumnMapping[] {
- new System.Data.Common.DataColumnMapping("姓名", "姓名"),
- new System.Data.Common.DataColumnMapping("性别", "性别"),
- new System.Data.Common.DataColumnMapping("编号", "编号"),
- new System.Data.Common.DataColumnMapping("科室", "科室"),
- new System.Data.Common.DataColumnMapping("挂号编号", "挂号编号"),
- new System.Data.Common.DataColumnMapping("医生", "医生"),
- new System.Data.Common.DataColumnMapping("划价时间", "划价时间"),
- new System.Data.Common.DataColumnMapping("划价员", "划价员"),
- new System.Data.Common.DataColumnMapping("是否收费", "是否收费"),
- new System.Data.Common.DataColumnMapping("收费员", "收费员"),
- new System.Data.Common.DataColumnMapping("收费时间", "收费时间"),
- new System.Data.Common.DataColumnMapping("划价金额", "划价金额"),
- new System.Data.Common.DataColumnMapping("是否发药", "是否发药"),
- new System.Data.Common.DataColumnMapping("发药时间", "发药时间"),
- new System.Data.Common.DataColumnMapping("发药员", "发药员")})});
- //
- // sqlSelectCommand2
- //
- this.sqlSelectCommand2.CommandText = "SELECT b.姓名, b.性别, a.编号, a.科室, a.挂号编号, a.医生, a.划价时间, a.划价员, a.是否收费, a.收费员, a.收费时间" +
- ", a.划价金额, a.是否发药, a.发药时间, a.发药员 FROM 门诊划价 a INNER JOIN 门诊挂号 b ON a.挂号编号 = b.编号 W" +
- "HERE (a.是否发药 = '否') AND (a.是否收费 = '是')";
- this.sqlSelectCommand2.Connection = this.sqlConnection1;
- //
- // SendMedicine
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
- this.ClientSize = new System.Drawing.Size(712, 477);
- this.Controls.Add(this.dataGrid2);
- this.Controls.Add(this.dataGrid1);
- this.Controls.Add(this.groupBox1);
- this.Name = "SendMedicine";
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- this.Text = "【药房发药】";
- this.Load += new System.EventHandler(this.SendMedicine_Load);
- ((System.ComponentModel.ISupportInitialize)(this.dataGrid2)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataView2)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataSet31)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataView1)).EndInit();
- this.groupBox1.ResumeLayout(false);
- this.ResumeLayout(false);
- }
- #endregion
- //------------初始化窗体时读入全部数据-------------
- private void SendMedicine_Load(object sender, System.EventArgs e)
- {
- //填充数据集
- da1.Fill(dataSet31);
- da2.Fill(dataSet31);
- //显示时,首先显示第一个划价单的明细
- dataView2.RowFilter="划价编号='"+dataGrid1[0,2].ToString().Trim()+"'";
- //明细数据根据选择的划价单编号而变化
- dataGrid1.CurrentCellChanged+=new EventHandler(dataGrid1_CurrentCellChanged);
- }
- //------------根据输入条件检索划价数据--------------
- private void btnSearch_Click(object sender, System.EventArgs e)
- {
- string filter="";
- if(txt1.Text.Trim()!="")
- {
- filter+="编号 like '%"+txt1.Text.Trim()+"%' AND ";
- }
- if(txt2.Text.Trim()!="")
- {
- filter+="姓名 like '%"+txt2.Text.Trim()+"%' AND ";
- }
- if(txt3.Text.Trim()!="")
- {
- filter+="划价时间>='"+txt3.Text.Trim()+"' AND ";
- }
- if(txt4.Text.Trim()!="")
- {
- filter+="划价时间<='"+txt4.Text.Trim()+"' AND ";
- }
- int length=filter.Length;
- if(length>0)
- {
- filter=filter.Substring(0,length-5);
- }
- dataView1.RowFilter=filter;
- if(dataView1.Count>0)//有确定的划价数据再显示明细
- {
- dataView2.RowFilter="划价编号='"+dataGrid1[0,2].ToString().Trim()+"'";
- }
- }
- //------------执行收费-----------
- private void btnSend_Click(object sender, System.EventArgs e)
- {
- if(dataView1.Count==0)//必须有选中的数据
- {
- MessageBox.Show("表中为空,无法执行发药","提示",MessageBoxButtons.OK,MessageBoxIcon.Stop);
- return;
- }
- //执行发药,更新数据库
- string strConn="workstation id=localhost;Integrated Security=SSPI;Database=hisbook;";
- SqlConnection cn=new SqlConnection(strConn);
- cn.Open();
- SqlCommand cmd=cn.CreateCommand();
- cmd.CommandText="exec sf_药品发出 "+dataGrid1[dataGrid1.CurrentRowIndex,2].ToString().Trim();
- cmd.ExecuteNonQuery();
- dataSet31.Clear();//刷新数据集
- da1.Fill(dataSet31);
- da2.Fill(dataSet31);
- if(dataView1.Count>0)//若已收费的划价单已空,则不需要再显示明细
- {
- dataView2.RowFilter="划价编号='"+dataGrid1[0,2].ToString().Trim()+"'";
- }
- }
- //-------------显示单据明细----------------
- private void dataGrid1_CurrentCellChanged(object sender, EventArgs e)
- {
- int i=dataGrid1.CurrentRowIndex;
- dataView2.RowFilter="划价编号='"+dataGrid1[i,2].ToString().Trim()+"'";
- }
- }
- }