photo.cs
上传用户:yiyuerguo
上传日期:2014-09-27
资源大小:3781k
文件大小:5k
源码类别:

C#编程

开发平台:

Others

  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. using System.Data;
  7. using System.Data.OleDb;
  8. using System.IO;
  9. namespace photo
  10. {
  11. /// <summary>
  12. /// Summary description for Form1.
  13. /// </summary>
  14. public class Form1 : System.Windows.Forms.Form
  15. {
  16. image_query img_query;
  17. private System.Windows.Forms.TextBox textBox1;
  18. private System.Windows.Forms.PictureBox pictureBox1;
  19. private System.Windows.Forms.Button button1;
  20. private System.Windows.Forms.Button button2;
  21. private System.Windows.Forms.OpenFileDialog FileOpenDlg;
  22. /// <summary>
  23. /// Required designer variable.
  24. /// </summary>
  25. private System.ComponentModel.Container components = null;
  26.         private Model model=new Model();
  27.         
  28. public Form1()
  29. {
  30. // Required for Windows Form Designer support
  31. //
  32. InitializeComponent();
  33. //
  34. // TODO: Add any constructor code after InitializeComponent call
  35. //
  36. img_query = new image_query();
  37. if (img_query.get_row()) 
  38. {
  39. this.textBox1.Text = img_query.get_filename();
  40. this.pictureBox1.Image = img_query.get_image();
  41. else 
  42. {
  43. this.textBox1.Text = "DONE";
  44. this.pictureBox1.Image = null;
  45. }
  46. }
  47. /// <summary>
  48. /// Clean up any resources being used.
  49. /// </summary>
  50. protected override void Dispose( bool disposing )
  51. {
  52. img_query.end_query();
  53. if( disposing )
  54. {
  55. if (components != null) 
  56. {
  57. components.Dispose();
  58. }
  59. }
  60. base.Dispose( disposing );
  61. }
  62. #region Windows Form Designer generated code
  63. /// <summary>
  64. /// Required method for Designer support - do not modify
  65. /// the contents of this method with the code editor.
  66. /// </summary>
  67. private void InitializeComponent()
  68. {
  69. this.textBox1 = new System.Windows.Forms.TextBox();
  70. this.pictureBox1 = new System.Windows.Forms.PictureBox();
  71. this.button1 = new System.Windows.Forms.Button();
  72. this.button2 = new System.Windows.Forms.Button();
  73. this.FileOpenDlg = new System.Windows.Forms.OpenFileDialog();
  74. this.SuspendLayout();
  75. // 
  76. // textBox1
  77. // 
  78. this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
  79. this.textBox1.Location = new System.Drawing.Point(8, 224);
  80. this.textBox1.Name = "textBox1";
  81. this.textBox1.Size = new System.Drawing.Size(160, 21);
  82. this.textBox1.TabIndex = 0;
  83. this.textBox1.Text = "";
  84. // 
  85. // pictureBox1
  86. // 
  87. this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
  88. | System.Windows.Forms.AnchorStyles.Left) 
  89. | System.Windows.Forms.AnchorStyles.Right)));
  90. this.pictureBox1.BackColor = System.Drawing.SystemColors.Desktop;
  91. this.pictureBox1.Location = new System.Drawing.Point(16, 24);
  92. this.pictureBox1.Name = "pictureBox1";
  93. this.pictureBox1.Size = new System.Drawing.Size(152, 176);
  94. this.pictureBox1.TabIndex = 1;
  95. this.pictureBox1.TabStop = false;
  96. // 
  97. // button1
  98. // 
  99. this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  100. this.button1.Location = new System.Drawing.Point(184, 80);
  101. this.button1.Name = "button1";
  102. this.button1.Size = new System.Drawing.Size(72, 28);
  103. this.button1.TabIndex = 2;
  104. this.button1.Text = "下一张";
  105. this.button1.Click += new System.EventHandler(this.button1_Click);
  106. // 
  107. // button2
  108. // 
  109. this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  110. this.button2.Location = new System.Drawing.Point(184, 144);
  111. this.button2.Name = "button2";
  112. this.button2.TabIndex = 3;
  113. this.button2.Text = "载入图片";
  114. this.button2.Click += new System.EventHandler(this.button2_Click);
  115. // 
  116. // Form1
  117. // 
  118. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  119. this.ClientSize = new System.Drawing.Size(280, 270);
  120. this.Controls.Add(this.button2);
  121. this.Controls.Add(this.button1);
  122. this.Controls.Add(this.pictureBox1);
  123. this.Controls.Add(this.textBox1);
  124. this.Name = "Form1";
  125. this.Text = "Form1";
  126. this.ResumeLayout(false);
  127. }
  128. #endregion
  129. /// <summary>
  130. /// The main entry point for the application.
  131. /// </summary>
  132. [STAThread]
  133. static void Main() 
  134. {
  135. Application.Run(new Form1());
  136. }
  137. private void button1_Click(object sender, System.EventArgs e)
  138. {
  139. if (img_query.get_row()) 
  140. {
  141. this.textBox1.Text = img_query.get_filename();
  142. this.pictureBox1.Image = img_query.get_image();
  143. else 
  144. {
  145. this.textBox1.Text = "DONE";
  146. this.pictureBox1.Image = null;
  147. }
  148. }
  149. private void button2_Click(object sender, System.EventArgs e)
  150. {
  151. if( DialogResult.OK == FileOpenDlg.ShowDialog() )
  152. {
  153. //在打开的选择框中选择照片——可以是多选
  154. foreach( string file in FileOpenDlg.FileNames )
  155. {
  156. //通知模型对数据库进行操作
  157. //像数据库中插入一条记录
  158. model.addphoto2(file);
  159. //打开当前添加的dfsgdf照片mm
  160. //model.select(newid);
  161. }
  162. }
  163. }
  164. }
  165. }