BookmarkConfigDialog.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775
  1. using PaintDotNet.CustomControl;
  2. using PaintDotNet.DbOpreate.DbBll;
  3. using PaintDotNet.DbOpreate.DbModel;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Data;
  8. using System.Drawing;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Text.RegularExpressions;
  12. using System.Threading.Tasks;
  13. using System.Web.UI;
  14. using System.Windows.Forms;
  15. namespace PaintDotNet
  16. {
  17. /// <summary>
  18. /// 通用书签配置页
  19. /// </summary>
  20. internal class BookmarkConfigDialog : PdnBaseForm
  21. {
  22. private Label label1;
  23. private TextBox textBox1;
  24. private TextBox textBox2;
  25. private Label label2;
  26. private GroupBox groupBox2;
  27. private Button button2;
  28. private Button button1;
  29. private DataGridView dataGridView1;
  30. private Button button3;
  31. private GroupBox groupBox1;
  32. /// <summary>
  33. /// 当前分类下的书签数据集合
  34. /// </summary>
  35. private List<mic_module_infos> mic_module_infos;
  36. private GroupBox groupBox3;
  37. private TextBox textBox10;
  38. private TextBox textBox9;
  39. private TextBox textBox8;
  40. private TextBox textBox7;
  41. private TextBox textBox6;
  42. private TextBox textBox5;
  43. private TextBox textBox4;
  44. private TextBox textBox3;
  45. private Label label10;
  46. private Label label9;
  47. private Label label8;
  48. private Label label7;
  49. private Label label6;
  50. private Label label5;
  51. private Label label4;
  52. private Label label3;
  53. /// <summary>
  54. /// 书签分类名
  55. /// </summary>
  56. private string analyzeClassify;
  57. public BookmarkConfigDialog(string analyzeClassify,string languageName)
  58. {
  59. this.analyzeClassify = analyzeClassify;
  60. this.Text = this.analyzeClassify + "-"+ PdnResources.GetString("Menu.Bookmarksconfiguration.Text");
  61. //查询当前分类下的所有书签信息
  62. if (!string.IsNullOrEmpty(this.analyzeClassify))
  63. {
  64. mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeClassify);
  65. mic_module_infos.Reverse();
  66. }
  67. InitializeComponent();
  68. InitializeLanguageText();
  69. InitGridHeader();
  70. InitDataGridView();
  71. this.textBox3.Text = "itemNumber";
  72. this.textBox7.Text = "ratingDate";
  73. this.textBox4.Text = "inspectionPerson";
  74. this.textBox8.Text = "contact";
  75. this.textBox5.Text = "inspectionDepartment";
  76. this.textBox9.Text = "inspectionDate";
  77. this.textBox6.Text = "other";
  78. this.textBox10.Text = "picture";
  79. if (languageName == "Template.Manager.item2.AtlasComparison")
  80. {
  81. groupBox3.Enabled = false;
  82. groupBox1.Enabled = false;
  83. button1.Enabled = false;
  84. dataGridView1.Visible = false;
  85. }
  86. }
  87. private void InitializeLanguageText()
  88. {
  89. this.groupBox1.Text = PdnResources.GetString("Menu.Advancedbookmarkconfiguration.Text");
  90. this.button3.Text = PdnResources.GetString("Menu.Addto.text");
  91. this.label2.Text = PdnResources.GetString("Menu.Formposition.Text") + ":";
  92. this.label1.Text = PdnResources.GetString("Menu.Thename.Text") + ":";
  93. this.groupBox2.Text = PdnResources.GetString("Menu.operation.text");
  94. this.button1.Text = PdnResources.GetString("Menu.File.Save.Text");
  95. this.button2.Text = PdnResources.GetString("Menu.cancel.text");
  96. this.groupBox3.Text = PdnResources.GetString("Menu.Basedhebookmarks.Text");
  97. this.label10.Text = PdnResources.GetString("Menu.picture.Text") + ":";
  98. this.label8.Text = PdnResources.GetString("Menu.Contactperson.text") + ":";
  99. this.label9.Text = PdnResources.GetString("Menu.Inspectiondate.text") + ":";
  100. this.label7.Text = PdnResources.GetString("Menu.Ratingdate.text") + ":";
  101. this.label6.Text = PdnResources.GetString("Menu.other.text") + PdnResources.GetString("Menu.information.text") + ":";
  102. this.label5.Text = PdnResources.GetString("Menu.inspectiondepartment.text") + ":";
  103. this.label4.Text = PdnResources.GetString("Menu.Sender.text") + ":";
  104. this.label3.Text = PdnResources.GetString("Menu.projectnumber.text") + ":";
  105. }
  106. /// <summary>
  107. /// 初始化基础控件
  108. /// </summary>
  109. private void InitializeComponent()
  110. {
  111. this.groupBox1 = new System.Windows.Forms.GroupBox();
  112. this.button3 = new System.Windows.Forms.Button();
  113. this.dataGridView1 = new System.Windows.Forms.DataGridView();
  114. this.textBox2 = new System.Windows.Forms.TextBox();
  115. this.label2 = new System.Windows.Forms.Label();
  116. this.textBox1 = new System.Windows.Forms.TextBox();
  117. this.label1 = new System.Windows.Forms.Label();
  118. this.groupBox2 = new System.Windows.Forms.GroupBox();
  119. this.button2 = new System.Windows.Forms.Button();
  120. this.button1 = new System.Windows.Forms.Button();
  121. this.groupBox3 = new System.Windows.Forms.GroupBox();
  122. this.textBox10 = new System.Windows.Forms.TextBox();
  123. this.textBox9 = new System.Windows.Forms.TextBox();
  124. this.textBox8 = new System.Windows.Forms.TextBox();
  125. this.textBox7 = new System.Windows.Forms.TextBox();
  126. this.textBox6 = new System.Windows.Forms.TextBox();
  127. this.textBox5 = new System.Windows.Forms.TextBox();
  128. this.textBox4 = new System.Windows.Forms.TextBox();
  129. this.textBox3 = new System.Windows.Forms.TextBox();
  130. this.label10 = new System.Windows.Forms.Label();
  131. this.label9 = new System.Windows.Forms.Label();
  132. this.label8 = new System.Windows.Forms.Label();
  133. this.label7 = new System.Windows.Forms.Label();
  134. this.label6 = new System.Windows.Forms.Label();
  135. this.label5 = new System.Windows.Forms.Label();
  136. this.label4 = new System.Windows.Forms.Label();
  137. this.label3 = new System.Windows.Forms.Label();
  138. this.groupBox1.SuspendLayout();
  139. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
  140. this.groupBox2.SuspendLayout();
  141. this.groupBox3.SuspendLayout();
  142. this.SuspendLayout();
  143. //
  144. // groupBox1
  145. //
  146. this.groupBox1.Controls.Add(this.button3);
  147. this.groupBox1.Controls.Add(this.dataGridView1);
  148. this.groupBox1.Controls.Add(this.textBox2);
  149. this.groupBox1.Controls.Add(this.label2);
  150. this.groupBox1.Controls.Add(this.textBox1);
  151. this.groupBox1.Controls.Add(this.label1);
  152. this.groupBox1.Location = new System.Drawing.Point(12, 239);
  153. this.groupBox1.Name = "groupBox1";
  154. this.groupBox1.Size = new System.Drawing.Size(517, 241);
  155. this.groupBox1.TabIndex = 0;
  156. this.groupBox1.TabStop = false;
  157. this.groupBox1.Text = "高级书签配置";
  158. //
  159. // button3
  160. //
  161. this.button3.Location = new System.Drawing.Point(425, 27);
  162. this.button3.Name = "button3";
  163. this.button3.Size = new System.Drawing.Size(75, 23);
  164. this.button3.TabIndex = 5;
  165. this.button3.Text = "添加";
  166. this.button3.UseVisualStyleBackColor = true;
  167. this.button3.Click += new System.EventHandler(this.button3_Click);
  168. //
  169. // dataGridView1
  170. //
  171. this.dataGridView1.AllowUserToAddRows = false;
  172. this.dataGridView1.AllowUserToDeleteRows = false;
  173. this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
  174. | System.Windows.Forms.AnchorStyles.Right)));
  175. this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  176. this.dataGridView1.BackgroundColor = System.Drawing.Color.White;
  177. this.dataGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
  178. this.dataGridView1.Location = new System.Drawing.Point(20, 56);
  179. this.dataGridView1.MultiSelect = false;
  180. this.dataGridView1.Name = "dataGridView1";
  181. this.dataGridView1.RowHeadersVisible = false;
  182. this.dataGridView1.RowTemplate.Height = 23;
  183. this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect;
  184. this.dataGridView1.Size = new System.Drawing.Size(480, 179);
  185. this.dataGridView1.TabIndex = 4;
  186. this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick);
  187. //
  188. // textBox2
  189. //
  190. this.textBox2.Location = new System.Drawing.Point(277, 29);
  191. this.textBox2.MaxLength = 10;
  192. this.textBox2.Name = "textBox2";
  193. this.textBox2.Size = new System.Drawing.Size(110, 21);
  194. this.textBox2.TabIndex = 3;
  195. this.textBox2.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox2_KeyPress);
  196. //
  197. // label2
  198. //
  199. this.label2.AutoSize = true;
  200. this.label2.Location = new System.Drawing.Point(217, 32);
  201. this.label2.Name = "label2";
  202. this.label2.Size = new System.Drawing.Size(65, 12);
  203. this.label2.TabIndex = 2;
  204. this.label2.Text = "表格位置:";
  205. //
  206. // textBox1
  207. //
  208. this.textBox1.Location = new System.Drawing.Point(78, 29);
  209. this.textBox1.Name = "textBox1";
  210. this.textBox1.Size = new System.Drawing.Size(110, 21);
  211. this.textBox1.TabIndex = 1;
  212. //
  213. // label1
  214. //
  215. this.label1.AutoSize = true;
  216. this.label1.Location = new System.Drawing.Point(18, 32);
  217. this.label1.Name = "label1";
  218. this.label1.Size = new System.Drawing.Size(65, 12);
  219. this.label1.TabIndex = 0;
  220. this.label1.Text = "书签名称:";
  221. //
  222. // groupBox2
  223. //
  224. this.groupBox2.Controls.Add(this.button2);
  225. this.groupBox2.Controls.Add(this.button1);
  226. this.groupBox2.Location = new System.Drawing.Point(12, 13);
  227. this.groupBox2.Name = "groupBox2";
  228. this.groupBox2.Size = new System.Drawing.Size(517, 65);
  229. this.groupBox2.TabIndex = 1;
  230. this.groupBox2.TabStop = false;
  231. this.groupBox2.Text = "操作";
  232. //
  233. // button2
  234. //
  235. this.button2.Location = new System.Drawing.Point(425, 25);
  236. this.button2.Name = "button2";
  237. this.button2.Size = new System.Drawing.Size(75, 23);
  238. this.button2.TabIndex = 1;
  239. this.button2.Text = "取消";
  240. this.button2.UseVisualStyleBackColor = true;
  241. this.button2.Click += new System.EventHandler(this.button2_Click);
  242. //
  243. // button1
  244. //
  245. this.button1.Location = new System.Drawing.Point(328, 25);
  246. this.button1.Name = "button1";
  247. this.button1.Size = new System.Drawing.Size(75, 23);
  248. this.button1.TabIndex = 0;
  249. this.button1.Text = "保存";
  250. this.button1.UseVisualStyleBackColor = true;
  251. this.button1.Click += new System.EventHandler(this.button1_Click);
  252. //
  253. // groupBox3
  254. //
  255. this.groupBox3.Controls.Add(this.textBox10);
  256. this.groupBox3.Controls.Add(this.textBox9);
  257. this.groupBox3.Controls.Add(this.textBox8);
  258. this.groupBox3.Controls.Add(this.textBox7);
  259. this.groupBox3.Controls.Add(this.textBox6);
  260. this.groupBox3.Controls.Add(this.textBox5);
  261. this.groupBox3.Controls.Add(this.textBox4);
  262. this.groupBox3.Controls.Add(this.textBox3);
  263. this.groupBox3.Controls.Add(this.label10);
  264. this.groupBox3.Controls.Add(this.label9);
  265. this.groupBox3.Controls.Add(this.label8);
  266. this.groupBox3.Controls.Add(this.label7);
  267. this.groupBox3.Controls.Add(this.label6);
  268. this.groupBox3.Controls.Add(this.label5);
  269. this.groupBox3.Controls.Add(this.label4);
  270. this.groupBox3.Controls.Add(this.label3);
  271. this.groupBox3.Location = new System.Drawing.Point(13, 85);
  272. this.groupBox3.Name = "groupBox3";
  273. this.groupBox3.Size = new System.Drawing.Size(516, 137);
  274. this.groupBox3.TabIndex = 2;
  275. this.groupBox3.TabStop = false;
  276. this.groupBox3.Text = "基础书签";
  277. //
  278. // textBox10
  279. //
  280. this.textBox10.Location = new System.Drawing.Point(349, 108);
  281. this.textBox10.Name = "textBox10";
  282. this.textBox10.ReadOnly = true;
  283. this.textBox10.Size = new System.Drawing.Size(128, 21);
  284. this.textBox10.TabIndex = 15;
  285. //
  286. // textBox9
  287. //
  288. this.textBox9.Location = new System.Drawing.Point(349, 82);
  289. this.textBox9.Name = "textBox9";
  290. this.textBox9.ReadOnly = true;
  291. this.textBox9.Size = new System.Drawing.Size(128, 21);
  292. this.textBox9.TabIndex = 14;
  293. //
  294. // textBox8
  295. //
  296. this.textBox8.Location = new System.Drawing.Point(349, 52);
  297. this.textBox8.Name = "textBox8";
  298. this.textBox8.ReadOnly = true;
  299. this.textBox8.Size = new System.Drawing.Size(128, 21);
  300. this.textBox8.TabIndex = 13;
  301. //
  302. // textBox7
  303. //
  304. this.textBox7.Location = new System.Drawing.Point(349, 26);
  305. this.textBox7.Name = "textBox7";
  306. this.textBox7.ReadOnly = true;
  307. this.textBox7.Size = new System.Drawing.Size(128, 21);
  308. this.textBox7.TabIndex = 12;
  309. //
  310. // textBox6
  311. //
  312. this.textBox6.Location = new System.Drawing.Point(101, 108);
  313. this.textBox6.Name = "textBox6";
  314. this.textBox6.ReadOnly = true;
  315. this.textBox6.Size = new System.Drawing.Size(128, 21);
  316. this.textBox6.TabIndex = 11;
  317. //
  318. // textBox5
  319. //
  320. this.textBox5.Location = new System.Drawing.Point(101, 80);
  321. this.textBox5.Name = "textBox5";
  322. this.textBox5.ReadOnly = true;
  323. this.textBox5.Size = new System.Drawing.Size(128, 21);
  324. this.textBox5.TabIndex = 10;
  325. //
  326. // textBox4
  327. //
  328. this.textBox4.Location = new System.Drawing.Point(101, 52);
  329. this.textBox4.Name = "textBox4";
  330. this.textBox4.ReadOnly = true;
  331. this.textBox4.Size = new System.Drawing.Size(128, 21);
  332. this.textBox4.TabIndex = 9;
  333. //
  334. // textBox3
  335. //
  336. this.textBox3.Location = new System.Drawing.Point(101, 24);
  337. this.textBox3.Name = "textBox3";
  338. this.textBox3.ReadOnly = true;
  339. this.textBox3.Size = new System.Drawing.Size(128, 21);
  340. this.textBox3.TabIndex = 8;
  341. //
  342. // label10
  343. //
  344. this.label10.AutoSize = true;
  345. this.label10.Location = new System.Drawing.Point(274, 113);
  346. this.label10.Name = "label10";
  347. this.label10.Size = new System.Drawing.Size(41, 12);
  348. this.label10.TabIndex = 7;
  349. this.label10.Text = "图片:";
  350. //
  351. // label9
  352. //
  353. this.label9.AutoSize = true;
  354. this.label9.Location = new System.Drawing.Point(274, 85);
  355. this.label9.Name = "label9";
  356. this.label9.Size = new System.Drawing.Size(65, 12);
  357. this.label9.TabIndex = 6;
  358. this.label9.Text = "送检日期:";
  359. //
  360. // label8
  361. //
  362. this.label8.AutoSize = true;
  363. this.label8.Location = new System.Drawing.Point(274, 57);
  364. this.label8.Name = "label8";
  365. this.label8.Size = new System.Drawing.Size(53, 12);
  366. this.label8.TabIndex = 5;
  367. this.label8.Text = "联系人:";
  368. //
  369. // label7
  370. //
  371. this.label7.AutoSize = true;
  372. this.label7.Location = new System.Drawing.Point(274, 29);
  373. this.label7.Name = "label7";
  374. this.label7.Size = new System.Drawing.Size(65, 12);
  375. this.label7.TabIndex = 4;
  376. this.label7.Text = "评级日期:";
  377. //
  378. // label6
  379. //
  380. this.label6.AutoSize = true;
  381. this.label6.Location = new System.Drawing.Point(30, 113);
  382. this.label6.Name = "label6";
  383. this.label6.Size = new System.Drawing.Size(65, 12);
  384. this.label6.TabIndex = 3;
  385. this.label6.Text = "其他信息:";
  386. //
  387. // label5
  388. //
  389. this.label5.AutoSize = true;
  390. this.label5.Location = new System.Drawing.Point(30, 85);
  391. this.label5.Name = "label5";
  392. this.label5.Size = new System.Drawing.Size(65, 12);
  393. this.label5.TabIndex = 2;
  394. this.label5.Text = "送检单位:";
  395. //
  396. // label4
  397. //
  398. this.label4.AutoSize = true;
  399. this.label4.Location = new System.Drawing.Point(30, 57);
  400. this.label4.Name = "label4";
  401. this.label4.Size = new System.Drawing.Size(53, 12);
  402. this.label4.TabIndex = 1;
  403. this.label4.Text = "送检人:";
  404. //
  405. // label3
  406. //
  407. this.label3.AutoSize = true;
  408. this.label3.Location = new System.Drawing.Point(30, 29);
  409. this.label3.Name = "label3";
  410. this.label3.Size = new System.Drawing.Size(65, 12);
  411. this.label3.TabIndex = 0;
  412. this.label3.Text = "项目编号:";
  413. //
  414. // BookmarkConfigDialog
  415. //
  416. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  417. this.ClientSize = new System.Drawing.Size(541, 492);
  418. this.Controls.Add(this.groupBox3);
  419. this.Controls.Add(this.groupBox2);
  420. this.Controls.Add(this.groupBox1);
  421. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  422. this.MaximizeBox = false;
  423. this.MinimizeBox = false;
  424. this.Name = "BookmarkConfigDialog";
  425. this.Text = "书签配置";
  426. this.Controls.SetChildIndex(this.groupBox1, 0);
  427. this.Controls.SetChildIndex(this.groupBox2, 0);
  428. this.Controls.SetChildIndex(this.groupBox3, 0);
  429. this.groupBox1.ResumeLayout(false);
  430. this.groupBox1.PerformLayout();
  431. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
  432. this.groupBox2.ResumeLayout(false);
  433. this.groupBox3.ResumeLayout(false);
  434. this.groupBox3.PerformLayout();
  435. this.ResumeLayout(false);
  436. }
  437. /// <summary>
  438. /// 初始化表头
  439. /// </summary>
  440. private void InitGridHeader()
  441. {
  442. DataGridViewTextBoxColumn h1 = new DataGridViewTextBoxColumn();
  443. h1.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  444. h1.Width = 190;
  445. DataGridViewTextBoxColumn h2 = new DataGridViewTextBoxColumn();
  446. h2.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  447. h2.Width = 190;
  448. DataGridViewButtonColumn h3 = new DataGridViewButtonColumn();
  449. h3.Width = 80;
  450. this.dataGridView1.Columns.Add(h1);
  451. this.dataGridView1.Columns.Add(h2);
  452. this.dataGridView1.Columns.Add(h3);
  453. DataGridViewHelper helper = new DataGridViewHelper(this.dataGridView1);
  454. helper.Headers.Add(new DataGridViewHelper.TopHeader(0, 1, PdnResources.GetString("Menu.Booksigning.Text")));
  455. helper.Headers.Add(new DataGridViewHelper.TopHeader(1, 1, PdnResources.GetString("Menu.Celllocation.Text")));
  456. helper.Headers.Add(new DataGridViewHelper.TopHeader(2, 1, PdnResources.GetString("Menu.operation.text")));
  457. this.dataGridView1.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  458. this.dataGridView1.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
  459. this.dataGridView1.AllowUserToResizeRows = false;
  460. this.dataGridView1.AllowUserToResizeColumns = false;
  461. }
  462. /// <summary>
  463. /// 初始化表格信息
  464. /// </summary>
  465. private void InitDataGridView()
  466. {
  467. this.dataGridView1.Rows.Clear();
  468. if(mic_module_infos != null && mic_module_infos.Count > 0)
  469. {
  470. foreach(mic_module_infos info in mic_module_infos)
  471. {
  472. DataGridViewRow row = new DataGridViewRow();
  473. row.Cells.Add(CreateTextBoxCell(info.tag_name, "tagName"));
  474. row.Cells.Add(CreateTextBoxCell(info.cell_position, "cellPosition"));
  475. row.Cells.Add(CreateButtonCell(PdnResources.GetString("Menu.Edit.Delete.Text"), "delete"));
  476. this.dataGridView1.Rows.Add(row);
  477. }
  478. this.dataGridView1.ClearSelection();
  479. }
  480. }
  481. /// <summary>
  482. /// 添加内容单元格
  483. /// </summary>
  484. /// <param name="text"></param>
  485. /// <param name="tag"></param>
  486. /// <returns></returns>
  487. private DataGridViewTextBoxCell CreateTextBoxCell(string text, object tag)
  488. {
  489. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  490. textboxcell.Value = text;
  491. textboxcell.Tag = tag;
  492. return textboxcell;
  493. }
  494. /// <summary>
  495. /// 添加按钮单元格
  496. /// </summary>
  497. /// <param name="text"></param>
  498. /// <param name="tag"></param>
  499. /// <returns></returns>
  500. public DataGridViewButtonCell CreateButtonCell(string text, object tag)
  501. {
  502. DataGridViewButtonCell buttonCell = new DataGridViewButtonCell();
  503. buttonCell.Value = text;
  504. buttonCell.Tag = tag;
  505. return buttonCell;
  506. }
  507. /// <summary>
  508. /// 取消按钮
  509. /// </summary>
  510. /// <param name="sender"></param>
  511. /// <param name="e"></param>
  512. private void button2_Click(object sender, EventArgs e)
  513. {
  514. this.Close();
  515. }
  516. /// <summary>
  517. /// 保存按钮
  518. /// </summary>
  519. /// <param name="sender"></param>
  520. /// <param name="e"></param>
  521. private void button1_Click(object sender, EventArgs e)
  522. {
  523. try
  524. {
  525. if (mic_module_infos.Count > 0)
  526. {
  527. mic_module_infos_BLL.Del(this.analyzeClassify);
  528. }
  529. foreach (DataGridViewRow row in this.dataGridView1.Rows)//重新添加到数据库
  530. {
  531. mic_module_infos newInfo = new mic_module_infos();
  532. newInfo.analyze_classify = this.analyzeClassify;
  533. newInfo.tag_name = row.Cells[0].Value.ToString().Replace(" ","");
  534. newInfo.cell_position = row.Cells[1].Value.ToString().Replace(" ", "");
  535. mic_module_infos_BLL.Add(newInfo);
  536. }
  537. this.Close();
  538. }
  539. catch(Exception)
  540. {
  541. MessageBox.Show(PdnResources.GetString("Menu.Failedtosavebookmark.text"));
  542. }
  543. }
  544. /// <summary>
  545. /// 添加书签按钮
  546. /// </summary>
  547. /// <param name="sender"></param>
  548. /// <param name="e"></param>
  549. private void button3_Click(object sender, EventArgs e)
  550. {
  551. if (string.IsNullOrEmpty(this.textBox1.Text))
  552. {
  553. MessageBox.Show(PdnResources.GetString("Menu.Pleaseenterbookmarkname.text"));
  554. return;
  555. }
  556. if (string.IsNullOrEmpty(this.textBox2.Text))
  557. {
  558. MessageBox.Show(PdnResources.GetString("Menu.Pleaseentertheformlocation.text"));
  559. return;
  560. }
  561. if (!Regex.IsMatch(this.textBox2.Text, "[0-9]"))
  562. {
  563. MessageBox.Show(PdnResources.GetString("Menu.Thetableter.text"));
  564. return;
  565. }
  566. DataGridViewRow row = new DataGridViewRow();
  567. row.Cells.Add(CreateTextBoxCell(this.textBox1.Text.Replace(" ",""), "tagName"));
  568. row.Cells.Add(CreateTextBoxCell(this.textBox2.Text.Replace(" ", ""), "cellPosition"));
  569. row.Cells.Add(CreateButtonCell(PdnResources.GetString("Menu.Edit.Delete.Text"), "delete"));
  570. this.dataGridView1.Rows.Add(row);
  571. //选中最新添加的那一条
  572. this.dataGridView1.ClearSelection();
  573. this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Cells[0].Selected = true;
  574. //清空输入框
  575. this.textBox1.Text = "";
  576. this.textBox2.Text = "";
  577. }
  578. /// <summary>
  579. /// 点击删除按钮
  580. /// </summary>
  581. /// <param name="sender"></param>
  582. /// <param name="e"></param>
  583. private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
  584. {
  585. var senderGrid = (DataGridView)sender;
  586. if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
  587. e.RowIndex >= 0)
  588. {
  589. this.dataGridView1.Rows[e.RowIndex].Cells[0].Selected = true;
  590. if (MessageBox.Show(PdnResources.GetString("Menu.Areyousuretoedbookmark.text")+"?", PdnResources.GetString("Menu.Unrecoverableafterdeletion.text"), MessageBoxButtons.YesNo) == DialogResult.Yes)
  591. this.dataGridView1.Rows.Remove(this.dataGridView1.Rows[e.RowIndex]);
  592. }
  593. }
  594. /// <summary>
  595. /// 对单元格位置输入做限制
  596. /// </summary>
  597. /// <param name="sender"></param>
  598. /// <param name="e"></param>
  599. private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
  600. {
  601. //如果不是字符,数字,退格键
  602. if (!char.IsDigit(e.KeyChar) && !char.IsLetter(e.KeyChar) && (int)e.KeyChar != 8)
  603. {
  604. e.Handled = true;
  605. }
  606. //数字不能在第一位
  607. if (char.IsDigit(e.KeyChar))
  608. {
  609. if (this.textBox2.Text.Length <= 0)
  610. e.Handled = true;
  611. }
  612. //有数字后不允许再输入字符
  613. if (char.IsLetter(e.KeyChar))
  614. {
  615. if (Regex.IsMatch(this.textBox2.Text, "[0-9]"))
  616. e.Handled = true;
  617. }
  618. }
  619. /// <summary>
  620. /// 编辑gatagridview的单元格,未完成
  621. /// </summary>
  622. /// <param name="sender"></param>
  623. /// <param name="e"></param>
  624. private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
  625. {
  626. if(this.dataGridView1.CurrentCell.ColumnIndex == 1)
  627. {
  628. (this.dataGridView1.CurrentCell as DataGridViewTextBoxCell).MaxInputLength = 10;
  629. e.Control.KeyPress -= girdTextbox_KeyPress;
  630. e.Control.KeyPress += new KeyPressEventHandler(girdTextbox_KeyPress);
  631. }
  632. }
  633. /// <summary>
  634. /// 添加编辑时的事件控制
  635. /// </summary>
  636. /// <param name="sender"></param>
  637. /// <param name="e"></param>
  638. private void girdTextbox_KeyPress(object sender, KeyPressEventArgs e)
  639. {
  640. //如果不是字符,数字,退格键
  641. if (!char.IsDigit(e.KeyChar) && !char.IsLetter(e.KeyChar) && (int)e.KeyChar != 8)
  642. {
  643. e.Handled = true;
  644. }
  645. TextBox gridTextBox = (TextBox)sender;
  646. string strMatchValue = gridTextBox.Text;
  647. //判断是否为退格键
  648. if(e.KeyChar == 8)
  649. {
  650. //判断输入控件选择文本的长度
  651. if (gridTextBox.SelectionLength == 0)
  652. {//未选中时
  653. }
  654. else
  655. {
  656. }
  657. }
  658. else
  659. {
  660. //判断输入控件选择文本的长度
  661. if (gridTextBox.SelectionLength == 0)
  662. {//未选中时
  663. //将当前输入的字符插入到原来的字符串中
  664. strMatchValue = strMatchValue.Insert(gridTextBox.SelectionStart, e.KeyChar.ToString());
  665. }
  666. else
  667. {
  668. //用当前输入的字符替换选中的字符串
  669. strMatchValue = strMatchValue.Replace(strMatchValue.Substring(gridTextBox.SelectionStart, gridTextBox.SelectionLength), e.KeyChar.ToString());
  670. }
  671. }
  672. if (!Regex.IsMatch(strMatchValue, "^[a-zA-Z]+[0-9]+$"))
  673. e.Handled = true;
  674. //string strMathchValue = tb.Text;
  675. ////判断是否为退格键
  676. //if (kc == 8)
  677. //{
  678. // ///判断输入控件选择文本的长度
  679. // if (tb.SelectionLength == 0)
  680. // {//未选文本中时处理
  681. // if (tb.SelectionStart > 0)
  682. // {//选择的开始位置大于0时处理
  683. // //strMathchValue.Remove(tb.SelectionStart, 1);
  684. // strMathchValue.Remove(tb.SelectionStart - 1, 1);
  685. // }
  686. // }
  687. // else
  688. // {//有选中文本时处理
  689. // strMathchValue.Remove(tb.SelectionStart, tb.SelectionLength);
  690. // }
  691. //}
  692. //else
  693. //{
  694. // //将当前输入的字符号插入到原来的字符串中
  695. // strMathchValue = strMathchValue.Insert(((TextBox)sender).SelectionStart, e.KeyChar.ToString());
  696. //}
  697. //Regex rx = new Regex(@"^\+?[1-9][0-9]*$", RegexOptions.IgnoreCase);
  698. //if (rx.IsMatch(strMathchValue) == false)
  699. //{
  700. // e.Handled = true;
  701. //}
  702. ////数字不能在第一位
  703. //if (char.IsDigit(e.KeyChar))
  704. //{
  705. // if (gridTextBox.Text.Length <= 0)
  706. // e.Handled = true;
  707. //}
  708. ////有数字后不允许再输入字符
  709. //if (char.IsLetter(e.KeyChar))
  710. //{
  711. // if (Regex.IsMatch(gridTextBox.Text, "[0-9]"))
  712. // e.Handled = true;
  713. //}
  714. }
  715. }
  716. }