bedzhao.aspx.cs
上传用户:clhb88
上传日期:2009-09-26
资源大小:3468k
文件大小:8k
源码类别:

医药行业

开发平台:

C#

  1. using System;
  2. using System.Collections;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Web;
  7. using System.Web.SessionState;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.HtmlControls;
  11. namespace 医院管理系统
  12. {
  13. /// <summary>
  14. /// bedzhao 的摘要说明。
  15. /// </summary>
  16. public class bedzhao : System.Web.UI.Page
  17. {
  18. protected System.Web.UI.WebControls.TextBox tname;
  19. protected System.Web.UI.WebControls.Button button1;
  20. protected System.Data.SqlClient.SqlCommand sqlSelectCommand1;
  21. protected System.Data.SqlClient.SqlCommand sqlInsertCommand1;
  22. protected System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
  23. protected System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
  24. protected System.Data.SqlClient.SqlDataAdapter sda;
  25. protected System.Data.SqlClient.SqlConnection cnn;
  26. protected System.Data.SqlClient.SqlCommand sqlSelectCommand2;
  27. protected System.Data.SqlClient.SqlCommand sqlInsertCommand2;
  28. protected System.Data.SqlClient.SqlCommand sqlUpdateCommand2;
  29. protected System.Data.SqlClient.SqlCommand sqlDeleteCommand2;
  30. protected System.Data.SqlClient.SqlDataAdapter sda2;
  31. protected System.Web.UI.WebControls.TextBox tnum;
  32. protected 医院管理系统.allpepole allpepole1;
  33. protected System.Web.UI.WebControls.DropDownList d1;
  34. protected System.Web.UI.WebControls.Button Button2;
  35. protected System.Web.UI.WebControls.Image Image1;
  36. protected System.Web.UI.WebControls.Button Button3;
  37. protected System.Web.UI.WebControls.DataGrid DataGrid1;
  38. private void Page_Load(object sender, System.EventArgs e)
  39. {
  40. fills();
  41. }
  42. private void fills()
  43. {
  44. if(cnn.State==0) cnn.Open();
  45. sda.SelectCommand.ExecuteNonQuery();
  46. allpepole1.Clear(); 
  47. sda.Fill(allpepole1); 
  48. cnn.Close();
  49. DataGrid1.DataBind(); 
  50. }
  51. #region Web 窗体设计器生成的代码
  52. override protected void OnInit(EventArgs e)
  53. {
  54. //
  55. // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
  56. //
  57. InitializeComponent();
  58. base.OnInit(e);
  59. }
  60. /// <summary>
  61. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  62. /// 此方法的内容。
  63. /// </summary>
  64. private void InitializeComponent()
  65. {    
  66. this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
  67. this.cnn = new System.Data.SqlClient.SqlConnection();
  68. this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
  69. this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
  70. this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
  71. this.sda = new System.Data.SqlClient.SqlDataAdapter();
  72. this.sqlSelectCommand2 = new System.Data.SqlClient.SqlCommand();
  73. this.sqlInsertCommand2 = new System.Data.SqlClient.SqlCommand();
  74. this.sqlUpdateCommand2 = new System.Data.SqlClient.SqlCommand();
  75. this.sqlDeleteCommand2 = new System.Data.SqlClient.SqlCommand();
  76. this.sda2 = new System.Data.SqlClient.SqlDataAdapter();
  77. this.allpepole1 = new 医院管理系统.allpepole();
  78. ((System.ComponentModel.ISupportInitialize)(this.allpepole1)).BeginInit();
  79. this.d1.SelectedIndexChanged += new System.EventHandler(this.button1_Click);
  80. this.button1.Click += new System.EventHandler(this.button1_Click);
  81. this.Button2.Click += new System.EventHandler(this.Button2_Click);
  82. this.DataGrid1.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.DataGrid1_PageIndexChanged);
  83. // 
  84. // sqlSelectCommand1
  85. // 
  86. this.sqlSelectCommand1.CommandText = "[allpepole]";
  87. this.sqlSelectCommand1.CommandType = System.Data.CommandType.StoredProcedure;
  88. this.sqlSelectCommand1.Connection = this.cnn;
  89. this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));
  90. // 
  91. // cnn
  92. // 
  93. this.cnn.ConnectionString = "workstation id="802-HUANGHAI";packet size=4096;integrated security=SSPI;data sour" +
  94. "ce=".";persist security info=False;initial catalog=医院管理系统";
  95. // 
  96. // sqlDeleteCommand1
  97. // 
  98. this.sqlDeleteCommand1.CommandText = "[z5]";
  99. this.sqlDeleteCommand1.CommandType = System.Data.CommandType.StoredProcedure;
  100. this.sqlDeleteCommand1.Connection = this.cnn;
  101. this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));
  102. this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@num", System.Data.SqlDbType.NVarChar, 20));
  103. // 
  104. // sda
  105. // 
  106. this.sda.DeleteCommand = this.sqlDeleteCommand1;
  107. this.sda.InsertCommand = this.sqlInsertCommand1;
  108. this.sda.SelectCommand = this.sqlSelectCommand1;
  109. this.sda.UpdateCommand = this.sqlUpdateCommand1;
  110. // 
  111. // sqlSelectCommand2
  112. // 
  113. this.sqlSelectCommand2.CommandText = "[selpe]";
  114. this.sqlSelectCommand2.CommandType = System.Data.CommandType.StoredProcedure;
  115. this.sqlSelectCommand2.Connection = this.cnn;
  116. this.sqlSelectCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));
  117. this.sqlSelectCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@name", System.Data.SqlDbType.NVarChar, 20));
  118. this.sqlSelectCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@num", System.Data.SqlDbType.NVarChar, 10));
  119. this.sqlSelectCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@进出实况", System.Data.SqlDbType.NVarChar, 20));
  120. // 
  121. // sda2
  122. // 
  123. this.sda2.DeleteCommand = this.sqlDeleteCommand2;
  124. this.sda2.InsertCommand = this.sqlInsertCommand2;
  125. this.sda2.SelectCommand = this.sqlSelectCommand2;
  126. this.sda2.UpdateCommand = this.sqlUpdateCommand2;
  127. // 
  128. // allpepole1
  129. // 
  130. this.allpepole1.DataSetName = "allpepole";
  131. this.allpepole1.Locale = new System.Globalization.CultureInfo("zh-CN");
  132. this.Button3.Click += new System.EventHandler(this.Button3_Click);
  133. this.Load += new System.EventHandler(this.Page_Load);
  134. ((System.ComponentModel.ISupportInitialize)(this.allpepole1)).EndInit();
  135. }
  136. #endregion
  137. private void button1_Click(object sender, System.EventArgs e)
  138. {
  139. if(cnn.State==0) cnn.Open();
  140. sda2.SelectCommand.Parameters["@name"].Value=tname.Text;
  141. sda2.SelectCommand.Parameters["@num"].Value=tnum.Text;
  142.             sda2.SelectCommand.Parameters["@进出实况"].Value=d1.SelectedValue ;
  143. sda2.SelectCommand.ExecuteNonQuery ();
  144.    allpepole1.Clear(); 
  145. sda2.Fill(allpepole1); 
  146. DataGrid1.DataBind();
  147. cnn.Close();
  148. this.DataGrid1.SelectedIndex=-1;
  149. }
  150. private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
  151. {
  152. DataGrid1.CurrentPageIndex = e.NewPageIndex;
  153. fills();
  154. }
  155. private void Button2_Click(object sender, System.EventArgs e)
  156. {
  157. this.Response.Redirect("bedid.aspx");
  158. }
  159. private void Button3_Click(object sender, System.EventArgs e)
  160. {
  161. if(DataGrid1.SelectedIndex==-1)
  162. {
  163. Response.Write("<script language=javascript>alert('你还没选择!');</script>") ;
  164. }
  165. else
  166. {
  167. if(cnn.State==0) cnn.Open();
  168. sda.DeleteCommand.Parameters["@num"].Value=DataGrid1.SelectedItem.Cells[0].Text;
  169. sda.DeleteCommand.ExecuteNonQuery ();
  170. cnn.Close();
  171. fills();
  172. this.DataGrid1.SelectedIndex=-1;
  173. }
  174. }
  175. }
  176. }