Form_Main.cs 47 KB

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