?? cliniccharge.cs
字號:
// dataView2
//
this.dataView2.Table = this.dataSet21.門診劃價明細;
//
// txt5
//
this.txt5.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataView1, "劃價金額"));
this.txt5.Location = new System.Drawing.Point(72, 496);
this.txt5.Name = "txt5";
this.txt5.ReadOnly = true;
this.txt5.TabIndex = 3;
this.txt5.Text = "";
//
// txt6
//
this.txt6.Location = new System.Drawing.Point(264, 496);
this.txt6.Name = "txt6";
this.txt6.TabIndex = 3;
this.txt6.Text = "";
this.txt6.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txt6_KeyPress);
this.txt6.TextChanged += new System.EventHandler(this.txt6_TextChanged);
//
// txt7
//
this.txt7.Location = new System.Drawing.Point(432, 496);
this.txt7.Name = "txt7";
this.txt7.ReadOnly = true;
this.txt7.TabIndex = 3;
this.txt7.Text = "";
//
// label1
//
this.label1.Location = new System.Drawing.Point(72, 480);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(100, 16);
this.label1.TabIndex = 4;
this.label1.Text = "合計金額";
//
// label2
//
this.label2.Location = new System.Drawing.Point(264, 480);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(100, 16);
this.label2.TabIndex = 4;
this.label2.Text = "收款";
//
// label3
//
this.label3.Location = new System.Drawing.Point(432, 480);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(100, 16);
this.label3.TabIndex = 4;
this.label3.Text = "找零";
//
// btnCash
//
this.btnCash.Image = ((System.Drawing.Image)(resources.GetObject("btnCash.Image")));
this.btnCash.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btnCash.Location = new System.Drawing.Point(576, 488);
this.btnCash.Name = "btnCash";
this.btnCash.TabIndex = 5;
this.btnCash.Text = "收費";
this.btnCash.Click += new System.EventHandler(this.btnCash_Click);
//
// 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";
//
// 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.是否收費 = \'否\')";
this.sqlSelectCommand2.Connection = this.sqlConnection1;
//
// ClinicCharge
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(720, 525);
this.Controls.Add(this.btnCash);
this.Controls.Add(this.label1);
this.Controls.Add(this.txt5);
this.Controls.Add(this.dataGrid2);
this.Controls.Add(this.dataGrid1);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.txt6);
this.Controls.Add(this.txt7);
this.Controls.Add(this.label2);
this.Controls.Add(this.label3);
this.Name = "ClinicCharge";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "【門診收費】";
this.Load += new System.EventHandler(this.ClinicCharge_Load);
this.groupBox1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataView1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataSet21)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataGrid2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataView2)).EndInit();
this.ResumeLayout(false);
}
#endregion
//---------初始化窗體,填充數據集----------
private void ClinicCharge_Load(object sender, System.EventArgs e)
{
//填充數據集
da1.Fill(dataSet21);
da2.Fill(dataSet21);
//顯示時,首先顯示第一個劃價單的明細
dataView2.RowFilter="劃價編號='"+dataGrid1[0,2].ToString().Trim()+"'";
//明細數據根據選擇的劃價單編號而變化
dataGrid1.CurrentCellChanged+=new EventHandler(dataGrid1_CurrentCellChanged);
}
//-------------顯示劃價單明細----------------
private void dataGrid1_CurrentCellChanged(object sender, EventArgs e)
{
txt6.Clear();
txt7.Clear();
int i=dataGrid1.CurrentRowIndex;
dataView2.RowFilter="劃價編號='"+dataGrid1[i,2].ToString().Trim()+"'";
}
//------------根據輸入條件檢索劃價數據--------------
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 txt6_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
//除小數點,數字和Del鍵之外,不相應其他鍵
if(!(e.KeyChar=='.'||(e.KeyChar>='0'&&e.KeyChar<='9'))||e.KeyChar=='8')
{
e.Handled=true;
}
}
//-----------隨時計算找零金額------------
private void txt6_TextChanged(object sender, System.EventArgs e)
{
if(txt5.Text.Trim()=="")//無合計金額不計算
{
return;
}
decimal money=0;
money=Convert.ToDecimal(txt6.Text)-Convert.ToDecimal(txt5.Text);
txt7.Text=money.ToString();
}
//------------執行收費-----------
private void btnCash_Click(object sender, System.EventArgs e)
{
if(txt7.Text=="")//檢查收款金額
{
MessageBox.Show("未輸入收款金額","提示",MessageBoxButtons.OK,MessageBoxIcon.Stop);
return;
}
if(Convert.ToDecimal(txt7.Text)<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="update 門診劃價 set 是否收費='是',收費時間='"+System.DateTime.Now.ToString()
+"' where 編號='"+dataGrid1[dataGrid1.CurrentRowIndex,2].ToString().Trim()+"'";
cmd.ExecuteNonQuery();
dataSet21.Clear();//刷新數據集
da1.Fill(dataSet21);
da2.Fill(dataSet21);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -