StoreQuery.cs
上传用户:yongjiajia
上传日期:2021-01-30
资源大小:686k
文件大小:9k
开发平台:

ASP/ASPX

  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. namespace 医院管理系统
  7. {
  8. /// <summary>
  9. /// StoreQuery 的摘要说明。
  10. /// </summary>
  11. public class StoreQuery : System.Windows.Forms.Form
  12. {
  13. private System.Windows.Forms.GroupBox groupBox1;
  14. private System.Windows.Forms.DataGrid dataGrid1;
  15. private System.Data.SqlClient.SqlDataAdapter da1;
  16. private System.Data.DataView dataView1;
  17. private 医院管理系统.DataSet3 dataSet31;
  18. private System.Windows.Forms.Label label4;
  19. private System.Windows.Forms.Button btnSearch;
  20. private System.Windows.Forms.TextBox txt1;
  21. private System.Windows.Forms.TextBox txt2;
  22. private System.Windows.Forms.Label label5;
  23. private System.Windows.Forms.TextBox txt3;
  24. private System.Windows.Forms.Label label1;
  25. private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
  26. private System.Data.SqlClient.SqlConnection sqlConnection1;
  27. /// <summary>
  28. /// 必需的设计器变量。
  29. /// </summary>
  30. private System.ComponentModel.Container components = null;
  31. public StoreQuery()
  32. {
  33. //
  34. // Windows 窗体设计器支持所必需的
  35. //
  36. InitializeComponent();
  37. //
  38. // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
  39. //
  40. }
  41. /// <summary>
  42. /// 清理所有正在使用的资源。
  43. /// </summary>
  44. protected override void Dispose( bool disposing )
  45. {
  46. if( disposing )
  47. {
  48. if(components != null)
  49. {
  50. components.Dispose();
  51. }
  52. }
  53. base.Dispose( disposing );
  54. }
  55. #region Windows 窗体设计器生成的代码
  56. /// <summary>
  57. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  58. /// 此方法的内容。
  59. /// </summary>
  60. private void InitializeComponent()
  61. {
  62. System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(StoreQuery));
  63. this.groupBox1 = new System.Windows.Forms.GroupBox();
  64. this.label4 = new System.Windows.Forms.Label();
  65. this.btnSearch = new System.Windows.Forms.Button();
  66. this.txt1 = new System.Windows.Forms.TextBox();
  67. this.txt2 = new System.Windows.Forms.TextBox();
  68. this.label5 = new System.Windows.Forms.Label();
  69. this.txt3 = new System.Windows.Forms.TextBox();
  70. this.label1 = new System.Windows.Forms.Label();
  71. this.dataGrid1 = new System.Windows.Forms.DataGrid();
  72. this.dataView1 = new System.Data.DataView();
  73. this.dataSet31 = new 医院管理系统.DataSet3();
  74. this.da1 = new System.Data.SqlClient.SqlDataAdapter();
  75. this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
  76. this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
  77. this.groupBox1.SuspendLayout();
  78. ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
  79. ((System.ComponentModel.ISupportInitialize)(this.dataView1)).BeginInit();
  80. ((System.ComponentModel.ISupportInitialize)(this.dataSet31)).BeginInit();
  81. this.SuspendLayout();
  82. // 
  83. // groupBox1
  84. // 
  85. this.groupBox1.Controls.Add(this.label4);
  86. this.groupBox1.Controls.Add(this.btnSearch);
  87. this.groupBox1.Controls.Add(this.txt1);
  88. this.groupBox1.Controls.Add(this.txt2);
  89. this.groupBox1.Controls.Add(this.label5);
  90. this.groupBox1.Controls.Add(this.txt3);
  91. this.groupBox1.Controls.Add(this.label1);
  92. this.groupBox1.Location = new System.Drawing.Point(0, 0);
  93. this.groupBox1.Name = "groupBox1";
  94. this.groupBox1.Size = new System.Drawing.Size(520, 80);
  95. this.groupBox1.TabIndex = 0;
  96. this.groupBox1.TabStop = false;
  97. // 
  98. // label4
  99. // 
  100. this.label4.Location = new System.Drawing.Point(24, 24);
  101. this.label4.Name = "label4";
  102. this.label4.Size = new System.Drawing.Size(32, 16);
  103. this.label4.TabIndex = 7;
  104. this.label4.Text = "库房";
  105. // 
  106. // btnSearch
  107. // 
  108. this.btnSearch.Image = ((System.Drawing.Image)(resources.GetObject("btnSearch.Image")));
  109. this.btnSearch.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
  110. this.btnSearch.Location = new System.Drawing.Point(384, 32);
  111. this.btnSearch.Name = "btnSearch";
  112. this.btnSearch.Size = new System.Drawing.Size(80, 24);
  113. this.btnSearch.TabIndex = 5;
  114. this.btnSearch.Text = "搜索";
  115. this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
  116. // 
  117. // txt1
  118. // 
  119. this.txt1.Location = new System.Drawing.Point(24, 40);
  120. this.txt1.Name = "txt1";
  121. this.txt1.Size = new System.Drawing.Size(88, 21);
  122. this.txt1.TabIndex = 3;
  123. this.txt1.Text = "";
  124. // 
  125. // txt2
  126. // 
  127. this.txt2.Location = new System.Drawing.Point(144, 40);
  128. this.txt2.Name = "txt2";
  129. this.txt2.Size = new System.Drawing.Size(88, 21);
  130. this.txt2.TabIndex = 4;
  131. this.txt2.Text = "";
  132. // 
  133. // label5
  134. // 
  135. this.label5.Location = new System.Drawing.Point(144, 24);
  136. this.label5.Name = "label5";
  137. this.label5.Size = new System.Drawing.Size(64, 16);
  138. this.label5.TabIndex = 6;
  139. this.label5.Text = "药品编号";
  140. // 
  141. // txt3
  142. // 
  143. this.txt3.Location = new System.Drawing.Point(256, 40);
  144. this.txt3.Name = "txt3";
  145. this.txt3.Size = new System.Drawing.Size(96, 21);
  146. this.txt3.TabIndex = 4;
  147. this.txt3.Text = "";
  148. // 
  149. // label1
  150. // 
  151. this.label1.Location = new System.Drawing.Point(256, 24);
  152. this.label1.Name = "label1";
  153. this.label1.Size = new System.Drawing.Size(64, 16);
  154. this.label1.TabIndex = 6;
  155. this.label1.Text = "药品名称";
  156. // 
  157. // dataGrid1
  158. // 
  159. this.dataGrid1.CaptionVisible = false;
  160. this.dataGrid1.DataMember = "";
  161. this.dataGrid1.DataSource = this.dataView1;
  162. this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
  163. this.dataGrid1.Location = new System.Drawing.Point(0, 80);
  164. this.dataGrid1.Name = "dataGrid1";
  165. this.dataGrid1.ReadOnly = true;
  166. this.dataGrid1.Size = new System.Drawing.Size(520, 408);
  167. this.dataGrid1.TabIndex = 1;
  168. // 
  169. // dataView1
  170. // 
  171. this.dataView1.Table = this.dataSet31.药品库存;
  172. // 
  173. // dataSet31
  174. // 
  175. this.dataSet31.DataSetName = "DataSet3";
  176. this.dataSet31.Locale = new System.Globalization.CultureInfo("zh-CN");
  177. // 
  178. // da1
  179. // 
  180. this.da1.SelectCommand = this.sqlSelectCommand1;
  181. this.da1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
  182.   new System.Data.Common.DataTableMapping("Table", "药品库存", new System.Data.Common.DataColumnMapping[] {
  183.   new System.Data.Common.DataColumnMapping("名称", "名称"),
  184.   new System.Data.Common.DataColumnMapping("编号", "编号"),
  185.   new System.Data.Common.DataColumnMapping("库房", "库房"),
  186.   new System.Data.Common.DataColumnMapping("药品编号", "药品编号"),
  187.   new System.Data.Common.DataColumnMapping("药品数量", "药品数量"),
  188.   new System.Data.Common.DataColumnMapping("备注", "备注")})});
  189. // 
  190. // sqlSelectCommand1
  191. // 
  192. this.sqlSelectCommand1.CommandText = "SELECT b.名称, a.编号, a.库房, a.药品编号, a.药品数量, a.备注 FROM 药品库存 a INNER JOIN 药品资料 b ON a." +
  193. "药品编号 = b.编号";
  194. this.sqlSelectCommand1.Connection = this.sqlConnection1;
  195. // 
  196. // sqlConnection1
  197. // 
  198. this.sqlConnection1.ConnectionString = "workstation id=localhost;packet size=4096;integrated security=SSPI;data source="." +
  199. "";persist security info=False;initial catalog=hisbook";
  200. // 
  201. // StoreQuery
  202. // 
  203. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  204. this.ClientSize = new System.Drawing.Size(520, 485);
  205. this.Controls.Add(this.dataGrid1);
  206. this.Controls.Add(this.groupBox1);
  207. this.Name = "StoreQuery";
  208. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  209. this.Text = "【药品库存量】";
  210. this.Load += new System.EventHandler(this.StoreQuery_Load);
  211. this.groupBox1.ResumeLayout(false);
  212. ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
  213. ((System.ComponentModel.ISupportInitialize)(this.dataView1)).EndInit();
  214. ((System.ComponentModel.ISupportInitialize)(this.dataSet31)).EndInit();
  215. this.ResumeLayout(false);
  216. }
  217. #endregion
  218. //------------根据输入搜索药品库存信息-------------
  219. private void btnSearch_Click(object sender, System.EventArgs e)
  220. {
  221. string filter="";
  222. if(txt1.Text.Trim()!="")
  223. {
  224. filter+="库房 like '%"+txt1.Text.Trim()+"%' AND ";
  225. }
  226. if(txt2.Text.Trim()!="")
  227. {
  228. filter+="药品编号 like '%"+txt2.Text.Trim()+"%' AND ";
  229. }
  230. if(txt3.Text.Trim()!="")
  231. {
  232. filter+="名称 like '%"+txt3.Text.Trim()+"%' AND ";
  233. }
  234. int length=filter.Length;
  235. if(length>0)
  236. {
  237. filter=filter.Substring(0,length-5);
  238. }
  239. dataView1.RowFilter=filter;
  240. }
  241. //------------初始窗体时,填充数据集------------
  242. private void StoreQuery_Load(object sender, System.EventArgs e)
  243. {
  244. da1.Fill(dataSet31);
  245. }
  246. }
  247. }