Form_Main.cs 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034
  1. using OTS.WinFormsUI.Docking;
  2. using SourceGrid;
  3. using SpectrumSTDEditor.BaseClass;
  4. using System;
  5. using System.Collections;
  6. using System.Collections.Generic;
  7. using System.Data;
  8. using System.Drawing;
  9. using System.Linq;
  10. using System.Windows.Forms;
  11. namespace SpectrumSTDEditor
  12. {
  13. public partial class Form_Main : Form
  14. {
  15. public STDRuleslist m_STDRuleslist = null;
  16. public Attributes m_Attributes = null;
  17. public SubMidWindow m_SubMidWindow = null;
  18. //public STDEditor m_STDEditor = null;
  19. /// <summary>
  20. /// 实际存储的字典
  21. /// </summary>
  22. public Dictionary<int, STDdata> STDDictionary = new Dictionary<int, STDdata>();
  23. /// <summary>
  24. /// 原始数据字典用于在关闭时比较是否弹出保存提示
  25. /// </summary>
  26. private Dictionary<int, STDdata> STDDictionaryInitial = new Dictionary<int, STDdata>();
  27. public Dictionary<int, string> GroupIdDictionaryFromId = new Dictionary<int, string>();
  28. public Dictionary<string, int> GroupIdDictionaryFromName = new Dictionary<string, int>();
  29. public string STDDBAddress = "";
  30. /// <summary>
  31. /// 0:正在打开的标准库路径;1:所增加标准的颗粒所在结果库位置;2:所增加标准的颗粒FieldId;3:所增加标准的颗粒ParticleId;4:所增加标准的颗粒XRayId
  32. /// </summary>
  33. List<string> ImportArgs = new List<string>();
  34. //国际化
  35. public Language lan;
  36. Hashtable table;
  37. //是否做出过更改
  38. public bool IsModified { set; get; }
  39. public bool Isoldversion { set; get; }
  40. //public static readonly string[] ColorGroup = { "#FFB6C1", "#FFC0CB", "#DC143C", "#FFF0F5", "#DB7093", "#FF69B4", "#FF1493", "#C71585", "#DA70D6", "#D8BFD8", "#DDA0DD", "#EE82EE", "#FF00FF", "#8B008B", "#800080", "#BA55D3", "#9400D3", "#9932CC", "#4B0082", "#8A2BE2", "#9370DB","#7B68EE", "#6A5ACD", "#483D8B", "#E6E6FA", "#F8F8FF", "#0000FF", "#0000CD", "#191970", "#00008B", "#000080", "#4169E1" , "#6495ED", "#B0C4DE", "#778899", "#708090", "#1E90FF", "#F0F8FF", "#00FFFF" };
  41. public Form_Main()
  42. {
  43. InitializeComponent();
  44. m_STDRuleslist = new STDRuleslist(this);
  45. m_Attributes = new Attributes(this);
  46. //m_STDEditor = new STDEditor(this, m_MainForm.STDDBAddress);
  47. m_SubMidWindow = new SubMidWindow(this);
  48. }
  49. public Form_Main(string[] ImportStandardLibraryArgs)
  50. {
  51. InitializeComponent();
  52. m_STDRuleslist = new STDRuleslist(this);
  53. m_Attributes = new Attributes(this);
  54. m_SubMidWindow = new SubMidWindow(this);
  55. foreach (var it in ImportStandardLibraryArgs)
  56. {
  57. ImportArgs.Add(it);
  58. }
  59. }
  60. private void Form_Main_Load(object sender, EventArgs e)
  61. {
  62. lan = new Language(this);
  63. table = lan.GetNameTable("Form_Main");
  64. if (STDDBAddress != "")
  65. {
  66. InitForms(STDDBAddress);
  67. this.Text = this.Text.Split(' ')[0] + " " + STDDBAddress;
  68. IsModified = false;
  69. //if (ImportArgs.Count > 1)
  70. //{
  71. // ImportStandardLibraryTypeSelection m_importStandardLibraryTypeSelection = new ImportStandardLibraryTypeSelection();
  72. // var result = m_importStandardLibraryTypeSelection.ShowDialog();
  73. // if (m_importStandardLibraryTypeSelection.SelectEvent == "expression")
  74. // {
  75. // int STDId = AddSTDDictionaryItem();
  76. // m_STDRuleslist.AddNewRow(STDId, "NewClassify", Attributes.string10ToColor(STDDictionary[STDId].Color));
  77. // }
  78. //}
  79. }
  80. }
  81. bool LoadClassifyToDictionary(string DBAddress, ref Dictionary<int, STDdata> STDDictionary)
  82. {
  83. try
  84. {
  85. //STDDictionaryInitial.Clear();
  86. System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + DBAddress + "'");
  87. m_dbConnection.Open();
  88. System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select * from STDMinerals order by orderid", m_dbConnection);
  89. DataSet ds = new DataSet();
  90. m_dataAdapter.Fill(ds);
  91. DataTable dt = ds.Tables[0];
  92. if (dt != null)
  93. {
  94. rbSave.Enabled = true;
  95. Isoldversion = false;
  96. if (dt.Rows.Count > 0)
  97. {
  98. foreach (DataRow item in dt.Rows)
  99. {
  100. STDdata new_STDdata = new STDdata();
  101. new_STDdata.Hardness = item["rigiditymod"].ToString();
  102. new_STDdata.Density = item["density"].ToString();
  103. //new_STDdata.Electrical_conductivity = item["Electrical_conductivity"].ToString();
  104. new_STDdata.BSE = item["BSEValue"].ToString();
  105. new_STDdata.Formula = item["formula"].ToString();
  106. new_STDdata.Element = item["element"].ToString();
  107. new_STDdata.StrName = item["name"].ToString();
  108. new_STDdata.ChineseName = item["chinesename"].ToString();
  109. //new_STDdata.Expression = item["Expression"].ToString();
  110. new_STDdata.Color = item["Color"].ToString();
  111. //new_STDdata.KeyElementList = item["KeyElementList"].ToString();
  112. //new_STDdata.SubElementList = item["SubElementList"].ToString();
  113. //new_STDdata.GroupId = item["GroupId"].ToString();
  114. new_STDdata.OrderId = item["orderid"].ToString();
  115. //new_STDdata.GroupId = item["GroupId"].ToString();
  116. //if (dt.Columns.Contains("IfElementAnalysis"))
  117. //{
  118. // if (Convert.ToBoolean(item["IfElementAnalysis"]))
  119. // {
  120. // new_STDdata.IfElementAnalysis = true;
  121. // }
  122. // else
  123. // {
  124. // new_STDdata.IfElementAnalysis = false;
  125. // }
  126. //}
  127. STDDictionary.Add(int.Parse(item["id"].ToString()), new_STDdata);
  128. }
  129. }
  130. }
  131. return true;
  132. }
  133. catch /*(Exception ee)*/
  134. {
  135. MessageBox.Show("The selected standard library is formatted incorrectly, please open the correct standard library!", "Tip");
  136. return false;
  137. }
  138. }
  139. public void ChangeSTDEditorAndGrid_Attributes(int STDId)
  140. {
  141. m_SubMidWindow.SelSTDXray(STDId, STDDictionary[STDId]);
  142. m_Attributes.SetDatatoGrid_Attributes(STDId);
  143. }
  144. private void rbBackup_Click(object sender, EventArgs e)
  145. {
  146. if (m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row >= 0)
  147. {
  148. SaveDataOfSelRule(m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Column);
  149. }
  150. try
  151. {
  152. SaveFileDialog saveFile = new SaveFileDialog();
  153. saveFile.Title = "Please select the path which to save the file";
  154. saveFile.Filter = "Database File(*.db)|*.db";
  155. saveFile.InitialDirectory = Application.StartupPath + "\\Config\\SysData\\";
  156. saveFile.OverwritePrompt = false; //是否覆盖当前文件
  157. if (saveFile.ShowDialog() == DialogResult.OK)
  158. {
  159. if (STDDBAddress == saveFile.FileName)
  160. {
  161. MessageBox.Show("不能另存为同名文件!", "Tip");
  162. return;
  163. }
  164. FormForWaiting forWaiting = new FormForWaiting();
  165. forWaiting.Show();
  166. System.IO.File.Copy(STDDBAddress, saveFile.FileName, true);
  167. bool result = SaveAsDictionaryToClassify(saveFile.FileName);
  168. if (result)
  169. {
  170. m_SubMidWindow.m_STDEditor.SaveSTDXray();
  171. STDDictionaryInitial.Clear();
  172. STDDictionaryInitial = Clone(STDDictionary) as Dictionary<int, STDdata>;
  173. STDDBAddress = saveFile.FileName;
  174. this.Text = this.Text.Split(' ')[0] + " " + saveFile.FileName;
  175. IsModified = false;
  176. forWaiting.Close();
  177. MessageBox.Show("Save successful!", "Tip");
  178. }
  179. else
  180. {
  181. forWaiting.Close();
  182. MessageBox.Show("Save failed!", "Tip");
  183. }
  184. }
  185. else
  186. {
  187. return;
  188. }
  189. }
  190. catch (Exception ex)
  191. {
  192. MessageBox.Show(ex.Message);
  193. }
  194. }
  195. public bool ClearDb(string DBAddress, string DBTableName)
  196. {
  197. try
  198. {
  199. System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + DBAddress + "'");
  200. m_dbConnection.Open();
  201. System.Data.SQLite.SQLiteCommand cmm = m_dbConnection.CreateCommand();
  202. cmm.CommandText = "delete from " + DBTableName;
  203. cmm.ExecuteNonQuery();
  204. m_dbConnection.Close();
  205. return true;
  206. }
  207. catch (Exception ex)
  208. {
  209. MessageBox.Show(ex.ToString());
  210. return false;
  211. }
  212. }
  213. object Clone(Dictionary<int, STDdata> STDDictionary)
  214. {
  215. Dictionary<int, STDdata> STDDictionaryInitial = new Dictionary<int, STDdata>();
  216. foreach (var key in STDDictionary.Keys)
  217. {
  218. STDdata tDdata = new STDdata();
  219. tDdata = tDdata.Clone(STDDictionary[key]) as STDdata;
  220. STDDictionaryInitial.Add(key, tDdata);
  221. }
  222. return STDDictionaryInitial;
  223. }
  224. private void rbSave_Click(object sender, EventArgs e)
  225. {
  226. if (m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row > 0)
  227. {
  228. SaveDataOfSelRule(m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0);
  229. }
  230. //if (RuleformatcheckAndSave())
  231. //{
  232. FormForWaiting forWaiting = new FormForWaiting();
  233. forWaiting.Show();
  234. bool result = SaveDictionaryToClassify(STDDBAddress);
  235. if (result)
  236. {
  237. m_SubMidWindow.m_STDEditor.SaveSTDXray();
  238. STDDictionaryInitial.Clear();
  239. STDDictionaryInitial = Clone(STDDictionary) as Dictionary<int, STDdata>;
  240. forWaiting.Close();
  241. IsModified = false;
  242. MessageBox.Show("Save successful!", "Tip");
  243. }
  244. else
  245. {
  246. forWaiting.Close();
  247. MessageBox.Show("Save failed!", "Tip");
  248. }
  249. //}
  250. //else
  251. //{
  252. // return;
  253. //}
  254. }
  255. bool RuleformatcheckAndSave()
  256. {
  257. foreach (var ite in STDDictionary)
  258. {
  259. Position pos = new Position(Convert.ToInt32(ite.Value.OrderId), 0);
  260. m_STDRuleslist.Grid_Minerals[Convert.ToInt32(ite.Value.OrderId), 0].Grid.Select();
  261. m_STDRuleslist.Grid_Minerals.Selection.Focus(pos, true);
  262. m_STDRuleslist.Grid_Minerals.Refresh();
  263. ChangeSTDEditorAndGrid_Attributes(ite.Key);
  264. m_STDRuleslist.PreRow = Convert.ToInt32(ite.Value.OrderId);
  265. return false;
  266. }
  267. return true;
  268. }
  269. ///// <summary>
  270. ///// [颜色:RGB转成16进制]
  271. ///// </summary>
  272. ///// <param name="R">红 int</param>
  273. ///// <param name="G">绿 int</param>
  274. ///// <param name="B">蓝 int</param>
  275. ///// <returns></returns>
  276. //public static string colorRGBtoHx16(int R, int G, int B)
  277. //{
  278. // return System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.FromArgb(R, G, B));
  279. //}
  280. /// <summary>
  281. /// 属性检测
  282. /// </summary>
  283. /// <param name="ddata"></param>
  284. /// <returns></returns>
  285. public bool CheckAttributes(STDdata ddata)
  286. {
  287. if (string.IsNullOrEmpty(ddata.StrName))
  288. {
  289. MessageBox.Show("Rule name can not be null !", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  290. }
  291. //if (string.IsNullOrEmpty(ddata.g)
  292. //{
  293. // if (!GroupIdDictionaryFromName.ContainsKey(m_Attributes.Grid_Attributes[11, 1].Value.ToString()))
  294. // {
  295. // Position pos = new Position(11, 1);
  296. // m_Attributes.Grid_Attributes.Selection.Focus(pos, true);
  297. // MessageBox.Show("This group name is not included, please fill in again!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  298. // return false;
  299. // }
  300. //}
  301. #region 化学式和元素暂无限制
  302. //if (m_Attributes.Grid_Attributes[7, 1].Value.ToString())
  303. //{
  304. // Position pos = new Position(7, 1);
  305. // m_Attributes.Grid_Attributes.Selection.Focus(pos, true);
  306. // MessageBox.Show(table["message10"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
  307. // return false;
  308. //}
  309. //if (m_Attributes.Grid_Attributes[8, 1].Value.ToString())
  310. //{
  311. // Position pos = new Position(8, 1);
  312. // m_Attributes.Grid_Attributes.Selection.Focus(pos, true);
  313. // MessageBox.Show(table["message10"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
  314. // return false;
  315. //}
  316. #endregion
  317. return true;
  318. }
  319. public void SaveDataOfSelRule(int PreRow, int PreColumn)
  320. {
  321. STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].StrName = Convert.ToString(m_Attributes.Grid_Attributes[2, 1].Value);
  322. STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].ChineseName = Convert.ToString(m_Attributes.Grid_Attributes[3, 1].Value);
  323. STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Color = shareFunction.ColorTostring10(m_Attributes.Grid_Attributes[4, 1].View.BackColor);
  324. //STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].IfElementAnalysis = Convert.ToBoolean(m_Attributes.Grid_Attributes[4, 1].Value);
  325. STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Hardness = Convert.ToString(m_Attributes.Grid_Attributes[5, 1].Value);
  326. STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Density = Convert.ToString(m_Attributes.Grid_Attributes[6, 1].Value);
  327. //STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Electrical_conductivity = Convert.ToString(m_Attributes.Grid_Attributes[7, 1].Value);
  328. STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].BSE = Convert.ToString(m_Attributes.Grid_Attributes[7, 1].Value);
  329. if (m_Attributes.Grid_Attributes[8, 1].Value != null)
  330. {
  331. STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Formula = Convert.ToString(m_Attributes.Grid_Attributes[8, 1].Value);
  332. }
  333. else
  334. {
  335. STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Formula = "";
  336. }
  337. if (m_Attributes.Grid_Attributes[9, 1].Value != null)
  338. {
  339. STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Element = Convert.ToString(m_Attributes.Grid_Attributes[9, 1].Value);
  340. }
  341. else
  342. {
  343. STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Element = "";
  344. }
  345. //if (m_Attributes.Grid_Attributes[11, 1].Value != null)
  346. //{
  347. // STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].GroupId = GroupIdDictionaryFromName[Convert.ToString(m_Attributes.Grid_Attributes[11, 1].Value)].ToString();
  348. //}
  349. //else
  350. //{
  351. // STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].GroupId = "0";
  352. //}
  353. //STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Expression = "";
  354. //string sKeyElements = "";
  355. //string sSubElements = "";
  356. //STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].KeyElementList = sKeyElements;
  357. //STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].SubElementList = sSubElements;
  358. STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].OrderId = PreRow.ToString();
  359. }
  360. /// <summary>
  361. /// 保存ClassifySTD库和MineralElements库
  362. /// </summary>
  363. /// <param name="DBAddress"></param>
  364. /// <returns></returns>
  365. bool SaveDictionaryToClassify(string DBAddress)
  366. {
  367. //保存列表顺序
  368. for (int i = 1; i < m_STDRuleslist.Grid_Minerals.RowsCount; i++)
  369. {
  370. STDDictionary[(int)m_STDRuleslist.Grid_Minerals[i, 0].Tag].OrderId = i.ToString();
  371. }
  372. try
  373. {
  374. System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + DBAddress + "'");
  375. m_dbConnection.Open();
  376. System.Data.SQLite.SQLiteCommand cmm = m_dbConnection.CreateCommand();
  377. cmm.CommandText = "delete from STDMinerals";
  378. try
  379. {
  380. cmm.ExecuteNonQuery();
  381. }
  382. catch (Exception ex)
  383. {
  384. MessageBox.Show(ex.ToString());
  385. return false;
  386. }
  387. System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select * from STDMinerals", m_dbConnection);
  388. System.Data.SQLite.SQLiteCommandBuilder qLiteCommandBuilder = new System.Data.SQLite.SQLiteCommandBuilder(m_dataAdapter);
  389. DataSet ds = new DataSet();
  390. m_dataAdapter.Fill(ds, "STDMinerals");
  391. DataTable dt = ds.Tables["STDMinerals"];
  392. dt.Clear();
  393. foreach (KeyValuePair<int, STDdata> kv in STDDictionary)
  394. {
  395. DataRow newRow = dt.NewRow();
  396. newRow["id"] = kv.Key;
  397. newRow["name"] = kv.Value.StrName;
  398. newRow["chinesename"] = kv.Value.ChineseName;
  399. newRow["color"] = kv.Value.Color;
  400. newRow["rigiditymod"] = kv.Value.Hardness;
  401. newRow["density"] = kv.Value.Density;
  402. newRow["BSEValue"] = int.Parse(kv.Value.BSE);
  403. newRow["formula"] = kv.Value.Formula;
  404. newRow["element"] = kv.Value.Element;
  405. newRow["orderid"] = kv.Value.OrderId;
  406. dt.Rows.Add(newRow);
  407. }
  408. m_dataAdapter.Update(ds, "STDMinerals");
  409. m_dbConnection.Close();
  410. }
  411. catch (Exception ex)
  412. {
  413. MessageBox.Show(ex.ToString());
  414. return false;
  415. }
  416. return true;
  417. }
  418. bool SaveAsDictionaryToClassify(string DBAddress)
  419. {
  420. try
  421. {
  422. System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + DBAddress + "'");
  423. m_dbConnection.Open();
  424. System.Data.SQLite.SQLiteCommand cmm = m_dbConnection.CreateCommand();
  425. cmm.CommandText = "drop table STDMinerals";
  426. cmm.ExecuteNonQuery();
  427. cmm.CommandText = "CREATE TABLE STDMinerals (id INTEGER,name TEXT,chinesename TEXT,formula TEXT,density FLOAT,BSEValue INTEGER,rigiditymod FLOAT,color INTEGER,SPEC BLOB,element TEXT,orderid INTEGER)";
  428. cmm.ExecuteNonQuery();
  429. System.Data.Common.DbTransaction trans = m_dbConnection.BeginTransaction();
  430. trans.Commit();
  431. System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select * from STDMinerals", m_dbConnection);
  432. System.Data.SQLite.SQLiteCommandBuilder qLiteCommandBuilder = new System.Data.SQLite.SQLiteCommandBuilder(m_dataAdapter);
  433. DataSet ds = new DataSet();
  434. m_dataAdapter.Fill(ds, "STDMinerals");
  435. DataTable dt = ds.Tables["STDMinerals"];
  436. foreach (KeyValuePair<int, STDdata> kv in STDDictionary)
  437. {
  438. DataRow newRow = dt.NewRow();
  439. newRow["id"] = kv.Key;
  440. newRow["name"] = kv.Value.StrName;
  441. newRow["chinesename"] = kv.Value.ChineseName;
  442. newRow["color"] = kv.Value.Color;
  443. newRow["rigiditymod"] = kv.Value.Hardness;
  444. newRow["density"] = kv.Value.Density;
  445. newRow["BSEValue"] = int.Parse(kv.Value.BSE);
  446. newRow["formula"] = kv.Value.Formula;
  447. newRow["element"] = kv.Value.Element;
  448. newRow["orderid"] = kv.Value.OrderId;
  449. dt.Rows.Add(newRow);
  450. }
  451. m_dataAdapter.Update(ds, "STDMinerals");
  452. m_dbConnection.Close();
  453. }
  454. catch (Exception ex)
  455. {
  456. MessageBox.Show(ex.ToString());
  457. return false;
  458. }
  459. return true;
  460. }
  461. public int AddSTDDictionaryItem()
  462. {
  463. STDdata new_STDdata = new STDdata();
  464. new_STDdata.Hardness = "1";
  465. new_STDdata.Density = "1";
  466. new_STDdata.BSE = "1";
  467. new_STDdata.Formula = "1";
  468. new_STDdata.Element = "1";
  469. new_STDdata.StrName = "NewRuleName";
  470. new_STDdata.ChineseName = "新建标准";
  471. Random random = new Random();
  472. new_STDdata.Color = shareFunction.ObtainRandomColor();
  473. int STDId = 40000;
  474. foreach (KeyValuePair<int, STDdata> kv in STDDictionary)
  475. {
  476. if (STDId < kv.Key)
  477. {
  478. STDId = kv.Key;
  479. }
  480. }
  481. STDDictionary.Add(STDId + 1, new_STDdata);
  482. return STDId + 1;
  483. }
  484. public void RemoveSTDDictionaryItem(int STDId)
  485. {
  486. STDDictionary.Remove(STDId);
  487. }
  488. public void ChangeStrName(int RowNum, string NewStrName)
  489. {
  490. STDDictionary[(int)m_STDRuleslist.Grid_Minerals[RowNum, 0].Tag].StrName = NewStrName;
  491. m_Attributes.Grid_Attributes[2, 1].Value = NewStrName;
  492. }
  493. public void ChangeSTDRulesLISTBackColor()
  494. {
  495. int stdid = m_STDRuleslist.ChangeSTDRulesLISTBackColor();
  496. m_SubMidWindow.SelSTDXray(stdid, STDDictionary[stdid]);
  497. }
  498. public void ChangeSTDRuleName(String RuleName)
  499. {
  500. m_STDRuleslist.Grid_Minerals[m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0].Value = RuleName;
  501. }
  502. public void SetNull()
  503. {
  504. //m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text = "";
  505. for (int i = 1; i < m_Attributes.Grid_Attributes.RowsCount - 1; i++)
  506. {
  507. if (m_Attributes.Grid_Attributes[i, 1].Value != null)
  508. {
  509. if (m_Attributes.Grid_Attributes[i, 1].View is SourceGrid.Cells.Views.CheckBox)
  510. {
  511. m_Attributes.Grid_Attributes[i, 1].Value = true;
  512. }
  513. else
  514. {
  515. m_Attributes.Grid_Attributes[i, 1].Value = "";
  516. }
  517. }
  518. }
  519. SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
  520. view.BackColor = Color.White;
  521. m_Attributes.Grid_Attributes[2, 1].View = view;
  522. }
  523. public void AddSTDGroupsToAttribute()
  524. {
  525. try
  526. {
  527. System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + STDDBAddress + "'");
  528. m_dbConnection.Open();
  529. System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select name,id from STDGroups order by iorder", m_dbConnection);
  530. DataSet ds = new DataSet();
  531. m_dataAdapter.Fill(ds);
  532. DataTable dt = ds.Tables[0];
  533. if (dt != null)
  534. {
  535. if (dt.Rows.Count >= 0)
  536. {
  537. GroupIdDictionaryFromId.Clear();
  538. GroupIdDictionaryFromName.Clear();
  539. List<string> ss = new List<string>();
  540. if (dt.Select("id='0'").Length == 0)
  541. {
  542. GroupIdDictionaryFromId.Add(0, "Default");
  543. GroupIdDictionaryFromName.Add("Default", 0);
  544. ss.Add("Default");
  545. }
  546. foreach (DataRow item in dt.Rows)
  547. {
  548. ss.Add(item["name"].ToString());
  549. GroupIdDictionaryFromName.Add(item["name"].ToString(), int.Parse(item["id"].ToString()));
  550. GroupIdDictionaryFromId.Add(int.Parse(item["id"].ToString()), item["name"].ToString());
  551. }
  552. SourceGrid.Cells.Editors.ComboBox GroupIdCBBox = new SourceGrid.Cells.Editors.ComboBox(typeof(string));
  553. GroupIdCBBox.StandardValues = ss;
  554. GroupIdCBBox.EditableMode = SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.Focus;
  555. m_Attributes.Grid_Attributes[11, 1] = new SourceGrid.Cells.Cell("Default", GroupIdCBBox);
  556. GroupIdCBBox.Control.DropDownStyle = ComboBoxStyle.DropDownList; //设置下拉框为不可以编辑的状态
  557. }
  558. }
  559. //string ConstantsStr = dt.Rows[0][0].ToString();
  560. m_dbConnection.Close();
  561. }
  562. catch (Exception ee)
  563. {
  564. MessageBox.Show(ee.ToString());
  565. }
  566. }
  567. //void SetNonexistentGroupsToDefault()
  568. //{
  569. // foreach (KeyValuePair<int, STDdata> kv in STDDictionary)
  570. // {
  571. // if (!GroupIdDictionaryFromId.Keys.Contains(int.Parse(kv.Value.GroupId)))
  572. // {
  573. // kv.Value.GroupId = "0";
  574. // }
  575. // }
  576. // m_Attributes.Grid_Attributes.Refresh();
  577. //}
  578. //private void ribbon_GroupNameMaintenance_Click(object sender, EventArgs e)
  579. //{
  580. // //STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0].Tag.ToString())].GroupId = GroupIdDictionaryFromName[m_Attributes.Grid_Attributes[10, 1].Value.ToString()].ToString();
  581. // int selGroupId = GroupIdDictionaryFromName[m_Attributes.Grid_Attributes[11, 1].Value.ToString()];
  582. // Form_GroupId form_GroupId = new Form_GroupId(STDDBAddress, this);
  583. // DialogResult dialogResult = form_GroupId.ShowDialog();
  584. // if (dialogResult == DialogResult.Yes)
  585. // {
  586. // AddSTDGroupsToAttribute();
  587. // //SetNonexistentGroupsToDefault();
  588. // m_Attributes.Grid_Attributes[11, 1].Value = GroupIdDictionaryFromId[selGroupId];
  589. // }
  590. //}
  591. private void ribbon_Exit_Click(object sender, EventArgs e)
  592. {
  593. this.Close();
  594. }
  595. private void rbClose_Click(object sender, EventArgs e)
  596. {
  597. if (!Isoldversion)
  598. {
  599. if (!EqualsBetweenDictionary(STDDictionaryInitial, STDDictionary) || IsModified)
  600. {
  601. DialogResult dr = MessageBox.Show("Whether to save the current modification?", "Tip", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  602. if (dr == DialogResult.Yes)
  603. {
  604. if (m_STDRuleslist.Grid_Minerals.RowsCount > 1)
  605. {
  606. if ((m_STDRuleslist.Grid_Minerals[m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0].Value.ToString().Replace(" ", "").Trim() != ""))
  607. {
  608. SaveDataOfSelRule(m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0);
  609. }
  610. else
  611. {
  612. return;
  613. }
  614. }
  615. else
  616. {
  617. STDDictionaryInitial.Clear();
  618. }
  619. FormForWaiting forWaiting = new FormForWaiting();
  620. forWaiting.Show();
  621. bool result = SaveDictionaryToClassify(STDDBAddress);
  622. if (result)
  623. {
  624. forWaiting.Close();
  625. }
  626. else
  627. {
  628. forWaiting.Close();
  629. MessageBox.Show("Save failed!", "Tip");
  630. }
  631. }
  632. }
  633. }
  634. m_Attributes.Close();
  635. m_STDRuleslist.Close();
  636. m_SubMidWindow.m_STDEditor.Close();
  637. m_SubMidWindow.m_ComparativeLibrary.Close();
  638. m_SubMidWindow.Close();
  639. ButtonStatusClose();
  640. if (this.Text.Split(' ').Count() != 0)
  641. {
  642. this.Text = this.Text.Split(' ')[0];
  643. }
  644. }
  645. private void rbOpen_Click(object sender, EventArgs e)
  646. {
  647. OpenFileDialog openFileDialog = new OpenFileDialog();
  648. openFileDialog.Filter = "(*.db)|*.db";
  649. openFileDialog.RestoreDirectory = true;
  650. openFileDialog.InitialDirectory = Application.StartupPath + "\\Config\\SysData\\";
  651. openFileDialog.FilterIndex = 1;
  652. if (openFileDialog.ShowDialog() == DialogResult.OK)
  653. {
  654. try
  655. {
  656. this.Cursor = Cursors.WaitCursor;
  657. STDDBAddress = openFileDialog.FileName;
  658. InitForms(STDDBAddress);
  659. this.Text = this.Text.Split(' ')[0] + " " + STDDBAddress;
  660. IsModified = false;
  661. this.Cursor = Cursors.Default;
  662. //CheckAccuracyofZeroRules();
  663. }
  664. catch(Exception ex)
  665. {
  666. MessageBox.Show(ex.ToString(), "Tip");
  667. this.Cursor = Cursors.Default;
  668. }
  669. }
  670. }
  671. void ButtonStatusOpen()
  672. {
  673. rbOpen.Enabled = false;
  674. rbClose.Enabled = true;
  675. //rbRecover.Enabled = true;
  676. rbBackup.Enabled = true;
  677. rbSave.Enabled = true;
  678. rbNew.Enabled = false;
  679. }
  680. void ButtonStatusClose()
  681. {
  682. rbOpen.Enabled = true;
  683. rbClose.Enabled = false;
  684. //rbRecover.Enabled = false;
  685. rbBackup.Enabled = false;
  686. rbSave.Enabled = false;
  687. rbNew.Enabled = true;
  688. }
  689. void InitForms(string DBAddress)
  690. {
  691. STDDictionary.Clear();
  692. ButtonStatusOpen();
  693. bool ret = LoadClassifyToDictionary(DBAddress, ref STDDictionary);
  694. STDDictionaryInitial = Clone(STDDictionary) as Dictionary<int, STDdata>;
  695. if (!ret)
  696. {
  697. return;
  698. }
  699. m_STDRuleslist = new STDRuleslist(this);
  700. m_Attributes = new Attributes(this);
  701. m_SubMidWindow = new SubMidWindow(this);
  702. m_STDRuleslist.Show(dockPanel1, DockState.DockLeft);
  703. m_Attributes.Show(dockPanel1, DockState.DockRight);
  704. m_SubMidWindow.Show(dockPanel1, DockState.Document);
  705. dockPanel1.DockLeftPortion = 360;
  706. dockPanel1.DockRightPortion = 381;
  707. if (m_SubMidWindow.m_STDEditor.m_sc != null)
  708. {
  709. m_SubMidWindow.m_STDEditor.m_sc.CloseDB();
  710. }
  711. m_SubMidWindow.m_STDEditor.m_sc = new SqlLiteClass(DBAddress);
  712. //AddSTDGroupsToAttribute();
  713. //m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text = "";
  714. if (m_STDRuleslist.Grid_Minerals.RowsCount > 1)
  715. {
  716. m_STDRuleslist.button_UpOrder.Enabled = false;
  717. if (m_STDRuleslist.Grid_Minerals.RowsCount == 2) //就一条时向下按钮置灰
  718. {
  719. m_STDRuleslist.button_DownOrder.Enabled = false;
  720. }
  721. ChangeSTDEditorAndGrid_Attributes(int.Parse(m_STDRuleslist.Grid_Minerals[1, 0].Tag.ToString()));
  722. Position pos = new Position(1, 0);
  723. m_STDRuleslist.Grid_Minerals[1, 0].Grid.Select();
  724. m_STDRuleslist.Grid_Minerals.Selection.Focus(pos, true);
  725. }
  726. }
  727. bool EqualsBetweenDictionary(Dictionary<int, STDdata> STDDictionaryInitial, Dictionary<int, STDdata> STDDictionary)
  728. {
  729. if (STDDictionaryInitial.Count != STDDictionary.Count)
  730. {
  731. return false;
  732. }
  733. foreach (var key in STDDictionaryInitial.Keys)
  734. {
  735. if (STDDictionary.Keys.Contains(key))
  736. {
  737. if (!STDDictionaryInitial[key].Equals(STDDictionary[key]))
  738. {
  739. return false;
  740. }
  741. }
  742. else
  743. {
  744. return false;
  745. }
  746. }
  747. return true;
  748. }
  749. private void Form_ConstantsEditor2_FormClosing(object sender, FormClosingEventArgs e)
  750. {
  751. if (Isoldversion)
  752. {
  753. return;
  754. }
  755. if (m_STDRuleslist.Text != "")
  756. {
  757. if (!EqualsBetweenDictionary(STDDictionaryInitial, STDDictionary) || IsModified)
  758. {
  759. DialogResult dr = MessageBox.Show("Whether to save the current modification", "Tip", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  760. if (dr == DialogResult.Yes)
  761. {
  762. if (m_STDRuleslist.Grid_Minerals.RowsCount > 1)
  763. {
  764. if (m_STDRuleslist.Grid_Minerals[m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0].Value.ToString().Replace(" ", "").Trim() != "")
  765. {
  766. SaveDataOfSelRule(m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0);
  767. }
  768. else
  769. {
  770. e.Cancel = true;
  771. return;
  772. }
  773. }
  774. else
  775. {
  776. STDDictionaryInitial.Clear();
  777. }
  778. FormForWaiting forWaiting = new FormForWaiting();
  779. forWaiting.Show();
  780. bool result = SaveDictionaryToClassify(STDDBAddress);
  781. if (result)
  782. {
  783. forWaiting.Close();
  784. }
  785. else
  786. {
  787. forWaiting.Close();
  788. MessageBox.Show("Save failed!", "Tip");
  789. }
  790. }
  791. else
  792. {
  793. //foreach (KeyValuePair<int, STDdata> kv in STDDictionary)
  794. //{
  795. // if (!GroupIdDictionaryFromId.Keys.Contains(int.Parse(kv.Value.GroupId)))
  796. // {
  797. // MessageBox.Show("There is non-existent grouping informations in the classification, please adjust!");
  798. // e.Cancel = true;
  799. // return;
  800. // }
  801. //}
  802. }
  803. }
  804. }
  805. }
  806. private void rbNew_Click(object sender, EventArgs e)
  807. {
  808. SaveFileDialog saveFile = new SaveFileDialog();
  809. saveFile.Title = table["message23"].ToString();
  810. saveFile.Filter = table["message36"].ToString();
  811. saveFile.OverwritePrompt = true; //是否覆盖当前文件
  812. saveFile.RestoreDirectory = true; //还原上次目录
  813. if (saveFile.ShowDialog() == DialogResult.OK)
  814. {
  815. try
  816. {
  817. System.Data.SQLite.SQLiteConnection.CreateFile(saveFile.FileName);
  818. System.Data.SQLite.SQLiteConnection m_OtsDatabaseConnection = new System.Data.SQLite.SQLiteConnection("data source='" + saveFile.FileName + "'");
  819. m_OtsDatabaseConnection.Open();
  820. System.Data.SQLite.SQLiteCommand OtsDatabaseCommand = m_OtsDatabaseConnection.CreateCommand();
  821. OtsDatabaseCommand.CommandText = "CREATE TABLE STDMinerals (id INTEGER,name TEXT,chinesename TEXT,formula TEXT,density FLOAT,BSEValue INTEGER,rigiditymod FLOAT,color INTEGER,SPEC BLOB,element TEXT,orderid INTEGER)";
  822. OtsDatabaseCommand.ExecuteNonQuery();
  823. System.Data.Common.DbTransaction trans = m_OtsDatabaseConnection.BeginTransaction();
  824. trans.Commit();
  825. }
  826. catch (Exception ex)
  827. {
  828. MessageBox.Show(ex.ToString());
  829. return;
  830. }
  831. STDDBAddress = saveFile.FileName;
  832. InitForms(STDDBAddress);
  833. this.Text = this.Text.Split(' ')[0] + " " + STDDBAddress;
  834. IsModified = false;
  835. }
  836. else
  837. {
  838. return;
  839. }
  840. }
  841. //void CheckAccuracyofZeroRules()
  842. //{
  843. // System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + STDDBAddress + "'");
  844. // m_dbConnection.Open();
  845. // System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select * from ZeroElementRules", m_dbConnection);
  846. // DataSet ds = new DataSet();
  847. // m_dataAdapter.Fill(ds);
  848. // DataTable dt = ds.Tables[0];
  849. // DataTable dt2 = dt.Copy();
  850. // if (dt != null)
  851. // {
  852. // if (dt.Columns[dt.Columns.Count - 1].ColumnName != "Expression")
  853. // {
  854. // System.Data.SQLite.SQLiteCommand cmm = m_dbConnection.CreateCommand();
  855. // cmm.CommandText = "CREATE TABLE sqlitestudio_temp_table AS SELECT * FROM ZeroElementRules";
  856. // cmm.ExecuteNonQuery();
  857. // cmm.CommandText = "DROP TABLE ZeroElementRules";
  858. // cmm.ExecuteNonQuery();
  859. // cmm.CommandText = "CREATE TABLE ZeroElementRules (ZeroElement TEXT,UsingElementList TEXT,UsingImgPropertyList TEXT,UsingOtherPropertyList TEXT,Expression TEXT)";
  860. // cmm.ExecuteNonQuery();
  861. // cmm.CommandText = @"INSERT INTO ZeroElementRules (
  862. // ZeroElement,
  863. // UsingElementList,
  864. // UsingImgPropertyList,
  865. // UsingOtherPropertyList,
  866. // Expression
  867. // )
  868. // SELECT ZeroElement,
  869. // UsingElementList,
  870. // UsingImgPropertyList,
  871. // UsingOtherPropertyList,
  872. // Expression
  873. // FROM sqlitestudio_temp_table; ";
  874. // cmm.ExecuteNonQuery();
  875. // cmm.CommandText = "DROP TABLE sqlitestudio_temp_table";
  876. // cmm.ExecuteNonQuery();
  877. // m_dbConnection.Close();
  878. // MessageBox.Show("检测到该数据库零元素规则格式错误,已进行修正!");
  879. // }
  880. // }
  881. //}
  882. private void ribbonOrbMenuItem_Convert_Click(object sender, EventArgs e)
  883. {
  884. DataTable OreDatabasedt = new DataTable();
  885. OpenFileDialog openFileDialog = new OpenFileDialog();
  886. openFileDialog.Title = "Please select the database you want to convert";
  887. openFileDialog.Filter = "(*.db)|*.db";
  888. openFileDialog.RestoreDirectory = true;
  889. openFileDialog.FilterIndex = 1;
  890. if (openFileDialog.ShowDialog() == DialogResult.OK)
  891. {
  892. try
  893. {
  894. string OreDatabaseAddress = openFileDialog.FileName;
  895. System.Data.SQLite.SQLiteConnection m_OreDatabaseConnection = new System.Data.SQLite.SQLiteConnection("data source='" + OreDatabaseAddress + "'");
  896. m_OreDatabaseConnection.Open();
  897. System.Data.SQLite.SQLiteDataAdapter m_OreDatabasedataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select * from STDMinerals", m_OreDatabaseConnection);
  898. DataSet OreDatabaseds = new DataSet();
  899. m_OreDatabasedataAdapter.Fill(OreDatabaseds);
  900. OreDatabasedt = OreDatabaseds.Tables[0];
  901. int listnum = 1;
  902. SaveFileDialog saveFile = new SaveFileDialog();
  903. saveFile.Title = table["message23"].ToString();
  904. saveFile.Filter = table["message36"].ToString();
  905. saveFile.OverwritePrompt = true;
  906. saveFile.RestoreDirectory = true;
  907. if (saveFile.ShowDialog() == DialogResult.OK)
  908. {
  909. System.Data.SQLite.SQLiteConnection.CreateFile(saveFile.FileName);
  910. System.Data.SQLite.SQLiteConnection m_OtsDatabaseConnection = new System.Data.SQLite.SQLiteConnection("data source='" + saveFile.FileName + "'");
  911. m_OtsDatabaseConnection.Open();
  912. System.Data.SQLite.SQLiteCommand OtsDatabaseCommand = m_OtsDatabaseConnection.CreateCommand();
  913. OtsDatabaseCommand.CommandText = "CREATE TABLE STDMinerals (id INTEGER,name TEXT,chinesename TEXT,formula TEXT,density FLOAT,BSEValue INTEGER,rigiditymod FLOAT,color INTEGER,SPEC BLOB,element TEXT,orderid INTEGER)";
  914. OtsDatabaseCommand.ExecuteNonQuery();
  915. System.Data.Common.DbTransaction trans = m_OtsDatabaseConnection.BeginTransaction();
  916. foreach (DataRow item in OreDatabasedt.Rows)
  917. {
  918. OtsDatabaseCommand.CommandText = "insert into STDMinerals (id,name,chinesename,formula,density,BSEValue,rigiditymod,color,SPEC,element,orderid) values (@id, @name, @chinesename, @formula, @density, @BSEValue, @rigiditymod, @color,@SPEC,@element, @orderid)";
  919. OtsDatabaseCommand.Parameters.Add("id", DbType.Int32).Value = item["id"];
  920. OtsDatabaseCommand.Parameters.Add("name", DbType.String).Value = item["name"];
  921. OtsDatabaseCommand.Parameters.Add("chinesename", DbType.String).Value = " ";
  922. OtsDatabaseCommand.Parameters.Add("formula", DbType.String).Value = item["formula"].ToString();
  923. OtsDatabaseCommand.Parameters.Add("density", DbType.String).Value = item["density"];
  924. OtsDatabaseCommand.Parameters.Add("BSEValue", DbType.String).Value = item["BSEValue"];
  925. OtsDatabaseCommand.Parameters.Add("rigiditymod", DbType.String).Value = item["rigiditymod"];
  926. OtsDatabaseCommand.Parameters.Add("color", DbType.String).Value = item["color"];
  927. OtsDatabaseCommand.Parameters.Add("SPEC", DbType.Binary).Value = item["SPEC"];
  928. OtsDatabaseCommand.Parameters.Add("element", DbType.String).Value = " ";
  929. OtsDatabaseCommand.Parameters.Add("orderid", DbType.String).Value = listnum.ToString();
  930. OtsDatabaseCommand.ExecuteNonQuery();
  931. }
  932. trans.Commit();
  933. MessageBox.Show("successful");
  934. }
  935. else
  936. {
  937. return;
  938. }
  939. }
  940. catch (Exception ex)
  941. {
  942. MessageBox.Show(ex.ToString());
  943. }
  944. }
  945. else
  946. {
  947. return;
  948. }
  949. }
  950. }
  951. }