|
@@ -24,11 +24,8 @@ namespace OTSPartA_STDEditor
|
|
|
private Dictionary<int, STDdata> STDDictionaryInitial=new Dictionary<int, STDdata>();
|
|
|
public Dictionary<int,string> GroupIdDictionaryFromId = new Dictionary<int,string>();
|
|
|
public Dictionary<string, int> GroupIdDictionaryFromName = new Dictionary<string, int>();
|
|
|
- //string STDDBAddress = Application.StartupPath + "\\Config\\SysData\\" + "OTSCleanlinesSTD.db";
|
|
|
- //string STDDBAddress_backup = Application.StartupPath + "\\Config\\SysData\\LibBackup\\" + "OTSCleanlinesSTD_backup.db";
|
|
|
string STDDBAddress_backupDirectory = Application.StartupPath + "\\Config\\SysData\\LibBackup\\";
|
|
|
public string STDDBAddress = "";
|
|
|
- //public string STDDBAddress_backup = "";
|
|
|
|
|
|
//国际化
|
|
|
public Language lan;
|
|
@@ -68,11 +65,14 @@ namespace OTSPartA_STDEditor
|
|
|
DataSet ds = new DataSet();
|
|
|
m_dataAdapter.Fill(ds);
|
|
|
DataTable dt = ds.Tables[0];
|
|
|
- string ConstantsStr = dt.Rows[0][0].ToString();
|
|
|
- ConstantsStr = ConstantsStr.Replace(" ", "");
|
|
|
- string[] ConstantsStr2 = ConstantsStr.Split(',');
|
|
|
- m_SubMidWindow.m_STDEditor.comboBox_Constants.Items.Clear();
|
|
|
- m_SubMidWindow.m_STDEditor.comboBox_Constants.Items.AddRange(ConstantsStr2);
|
|
|
+ if (dt.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ string ConstantsStr = dt.Rows[0][0].ToString();
|
|
|
+ ConstantsStr = ConstantsStr.Replace(" ", "");
|
|
|
+ string[] ConstantsStr2 = ConstantsStr.Split(',');
|
|
|
+ m_SubMidWindow.m_STDEditor.comboBox_Constants.Items.Clear();
|
|
|
+ m_SubMidWindow.m_STDEditor.comboBox_Constants.Items.AddRange(ConstantsStr2);
|
|
|
+ }
|
|
|
m_dbConnection.Close();
|
|
|
}
|
|
|
catch (Exception ee)
|
|
@@ -118,7 +118,6 @@ namespace OTSPartA_STDEditor
|
|
|
new_STDdata.GroupId = item["GroupId"].ToString();
|
|
|
|
|
|
STDDictionary.Add(int.Parse(item["STDId"].ToString()), new_STDdata);
|
|
|
- //STDDictionaryInitial = new Dictionary<int, STDdata>(STDDictionary);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -337,138 +336,150 @@ namespace OTSPartA_STDEditor
|
|
|
public bool Checktextbox_STDEditor()
|
|
|
{
|
|
|
string str_RemoveBlank = m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text.ToString().Replace(" ", "");
|
|
|
- str_RemoveBlank = str_RemoveBlank.Replace("\r\n", "");
|
|
|
- //分割符号检验
|
|
|
- string[] Symbol = { "and", "or", "+", "-", "*", "/", "=", ">", "<" };
|
|
|
- for (int i = 0; i < Symbol.Length; i++)
|
|
|
+ if (str_RemoveBlank != "")
|
|
|
{
|
|
|
- for (int j = 0; j < Symbol.Length; j++)
|
|
|
+ str_RemoveBlank = str_RemoveBlank.Replace("\r\n", "");
|
|
|
+ //分割符号检验
|
|
|
+ string[] Symbol = { "and", "or", "+", "-", "*", "/", "=", ">", "<" };
|
|
|
+ for (int i = 0; i < Symbol.Length; i++)
|
|
|
{
|
|
|
- if ((Symbol[i] + Symbol[j]) != ">=" && (Symbol[i] + Symbol[j]) != "<=")
|
|
|
+ for (int j = 0; j < Symbol.Length; j++)
|
|
|
{
|
|
|
- if (str_RemoveBlank.Contains(Symbol[i] + Symbol[j]))
|
|
|
+ if ((Symbol[i] + Symbol[j]) != ">=" && (Symbol[i] + Symbol[j]) != "<=")
|
|
|
{
|
|
|
- MessageBox.Show(table["message18"].ToString() + Symbol[i] + Symbol[j], table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return false;
|
|
|
+ if (str_RemoveBlank.Contains(Symbol[i] + Symbol[j]))
|
|
|
+ {
|
|
|
+ MessageBox.Show(table["message18"].ToString() + Symbol[i] + Symbol[j], table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ if (str_RemoveBlank.Contains(Symbol[i] + ")") || str_RemoveBlank.Contains("(" + Symbol[i]))
|
|
|
+ {
|
|
|
+ MessageBox.Show(table["message18"].ToString() + Symbol[i] + ")", table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (str_RemoveBlank.Contains("(" + Symbol[i]))
|
|
|
+ {
|
|
|
+ MessageBox.Show(table["message18"].ToString() + "(" + Symbol[i], table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
- if (str_RemoveBlank.Contains(Symbol[i] + ")") || str_RemoveBlank.Contains("(" + Symbol[i]))
|
|
|
- {
|
|
|
- MessageBox.Show(table["message18"].ToString() + Symbol[i] + ")", table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (str_RemoveBlank.Contains("(" + Symbol[i]))
|
|
|
- {
|
|
|
- MessageBox.Show(table["message18"].ToString() + "(" + Symbol[i], table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- if ((str_RemoveBlank != null) && (str_RemoveBlank != ""))
|
|
|
- {
|
|
|
- //左右括号匹配检验
|
|
|
- int BracketsNum = 0;
|
|
|
- for (int i = 0; i < str_RemoveBlank.Length; i++)
|
|
|
- {
|
|
|
- if (str_RemoveBlank[i] == '(') BracketsNum++;
|
|
|
- if (str_RemoveBlank[i] == ')') BracketsNum--;
|
|
|
- }
|
|
|
- if (BracketsNum != 0)
|
|
|
- {
|
|
|
- MessageBox.Show(table["message19"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return false;
|
|
|
- }
|
|
|
- //首字符检测
|
|
|
- if ((str_RemoveBlank[0] == '+') || (str_RemoveBlank[0] == '-') || (str_RemoveBlank[0] == '*') || (str_RemoveBlank[0] == '/') || (str_RemoveBlank[0] == '>') || (str_RemoveBlank[0] == '<') || (str_RemoveBlank[0] == '=') || (str_RemoveBlank[0] == ')') || (str_RemoveBlank[str_RemoveBlank.Length - 1] == '('))
|
|
|
- {
|
|
|
- MessageBox.Show(table["message20"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- if (str_RemoveBlank.Length >= 3)
|
|
|
+ if ((str_RemoveBlank != null) && (str_RemoveBlank != ""))
|
|
|
{
|
|
|
- if ((str_RemoveBlank.Substring(0, 3) == "and") || (str_RemoveBlank.Substring(0, 3) == "end"))
|
|
|
+ //左右括号匹配检验
|
|
|
+ int BracketsNum = 0;
|
|
|
+ for (int i = 0; i < str_RemoveBlank.Length; i++)
|
|
|
+ {
|
|
|
+ if (str_RemoveBlank[i] == '(') BracketsNum++;
|
|
|
+ if (str_RemoveBlank[i] == ')') BracketsNum--;
|
|
|
+ }
|
|
|
+ if (BracketsNum != 0)
|
|
|
+ {
|
|
|
+ MessageBox.Show(table["message19"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ //首字符检测
|
|
|
+ if ((str_RemoveBlank[0] == '+') || (str_RemoveBlank[0] == '-') || (str_RemoveBlank[0] == '*') || (str_RemoveBlank[0] == '/') || (str_RemoveBlank[0] == '>') || (str_RemoveBlank[0] == '<') || (str_RemoveBlank[0] == '=') || (str_RemoveBlank[0] == ')') || (str_RemoveBlank[str_RemoveBlank.Length - 1] == '('))
|
|
|
{
|
|
|
MessageBox.Show(table["message20"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
return false;
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- //forth_elem干扰or分隔符,故先行去掉
|
|
|
- str_RemoveBlank = str_RemoveBlank.Replace("forth_elem", "");
|
|
|
-
|
|
|
- string[] str_Removeand = System.Text.RegularExpressions.Regex.Split(str_RemoveBlank, "and", System.Text.RegularExpressions.RegexOptions.None);
|
|
|
- List<string> str_Removeandor = new List<string>();
|
|
|
- for (int i = 0; i < str_Removeand.Length; i++)
|
|
|
- {
|
|
|
- str_Removeandor.AddRange(System.Text.RegularExpressions.Regex.Split(str_Removeand[i], "or", System.Text.RegularExpressions.RegexOptions.None));
|
|
|
- }
|
|
|
- List<string> list_all = new List<string>();
|
|
|
- for (int i = 0; i < str_Removeandor.Count; i++)
|
|
|
- {
|
|
|
- list_all.AddRange(str_Removeandor[i].Split(new char[] { '+', '-', '*', '/', '=', '>', '<', '(', ')' }));
|
|
|
- }
|
|
|
+ if (str_RemoveBlank.Length >= 3)
|
|
|
+ {
|
|
|
+ if ((str_RemoveBlank.Substring(0, 3) == "and") || (str_RemoveBlank.Substring(0, 3) == "end"))
|
|
|
+ {
|
|
|
+ MessageBox.Show(table["message20"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- //常量
|
|
|
- List<string> Constantslist = new List<string>();
|
|
|
- for (int j = 0; j < m_SubMidWindow.m_STDEditor.comboBox_Constants.Items.Count; j++)
|
|
|
- {
|
|
|
- Constantslist.Add(m_SubMidWindow.m_STDEditor.comboBox_Constants.Items[j].ToString().Split('=')[0]);
|
|
|
- }
|
|
|
+ //forth_elem干扰or分隔符,故先行去掉
|
|
|
+ str_RemoveBlank = str_RemoveBlank.Replace("forth_elem", "");
|
|
|
|
|
|
- for (int i = 0; i < list_all.Count; i++)
|
|
|
- {
|
|
|
- //周期元素?
|
|
|
- if (this.m_SubMidWindow.m_STDEditor.comboBox_PeriodicTable.Items.Contains(list_all[i]))
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
- //first_elem?
|
|
|
- if (this.m_SubMidWindow.m_STDEditor.comboBox_Elem1.Items.Contains(list_all[i]))
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
- //Element1?
|
|
|
- if (this.m_SubMidWindow.m_STDEditor.comboBox_Elem.Items.Contains(list_all[i]))
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
- //其它元素?
|
|
|
- if (this.m_SubMidWindow.m_STDEditor.comboBox_ImgProperty.Items.Contains(list_all[i]))
|
|
|
+ string[] str_Removeand = System.Text.RegularExpressions.Regex.Split(str_RemoveBlank, "and", System.Text.RegularExpressions.RegexOptions.None);
|
|
|
+ List<string> str_Removeandor = new List<string>();
|
|
|
+ for (int i = 0; i < str_Removeand.Length; i++)
|
|
|
{
|
|
|
- continue;
|
|
|
+ str_Removeandor.AddRange(System.Text.RegularExpressions.Regex.Split(str_Removeand[i], "or", System.Text.RegularExpressions.RegexOptions.None));
|
|
|
}
|
|
|
- //常量?
|
|
|
- if (Constantslist.Contains(list_all[i]))
|
|
|
+ List<string> list_all = new List<string>();
|
|
|
+ for (int i = 0; i < str_Removeandor.Count; i++)
|
|
|
{
|
|
|
- continue;
|
|
|
+ list_all.AddRange(str_Removeandor[i].Split(new char[] { '+', '-', '*', '/', '=', '>', '<', '(', ')' }));
|
|
|
}
|
|
|
- //数字?
|
|
|
- double DNum = 0;
|
|
|
- if (double.TryParse(list_all[i], out DNum))
|
|
|
+
|
|
|
+ //常量
|
|
|
+ List<string> Constantslist = new List<string>();
|
|
|
+ for (int j = 0; j < m_SubMidWindow.m_STDEditor.comboBox_Constants.Items.Count; j++)
|
|
|
{
|
|
|
- continue;
|
|
|
+ Constantslist.Add(m_SubMidWindow.m_STDEditor.comboBox_Constants.Items[j].ToString().Split('=')[0]);
|
|
|
}
|
|
|
- //>=? <=?等其它情况
|
|
|
- if (list_all[i] == "")
|
|
|
+
|
|
|
+ for (int i = 0; i < list_all.Count; i++)
|
|
|
{
|
|
|
- continue;
|
|
|
+ //周期元素?
|
|
|
+ if (this.m_SubMidWindow.m_STDEditor.comboBox_PeriodicTable.Items.Contains(list_all[i]))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //first_elem?
|
|
|
+ if (this.m_SubMidWindow.m_STDEditor.comboBox_Elem1.Items.Contains(list_all[i]))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //Element1?
|
|
|
+ if (this.m_SubMidWindow.m_STDEditor.comboBox_Elem.Items.Contains(list_all[i]))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //其它元素?
|
|
|
+ if (this.m_SubMidWindow.m_STDEditor.comboBox_ImgProperty.Items.Contains(list_all[i]))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //常量?
|
|
|
+ if (Constantslist.Contains(list_all[i]))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //数字?
|
|
|
+ double DNum = 0;
|
|
|
+ if (double.TryParse(list_all[i], out DNum))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //>=? <=?等其它情况
|
|
|
+ if (list_all[i] == "")
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //true false?
|
|
|
+ if ((list_all[i] == "true") || (list_all[i] == "false"))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ MessageBox.Show(table["message21"].ToString() + list_all[i], table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
+ return false;
|
|
|
}
|
|
|
- //true false?
|
|
|
- if ((list_all[i] == "true") || (list_all[i] == "false"))
|
|
|
+ //检测是否有<>= true,false
|
|
|
+ if (!m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text.ToString().Contains("<") && !m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text.ToString().Contains(">") && !m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text.ToString().Contains("=") && m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text.ToString() != "true" && m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text.ToString() != "false")
|
|
|
{
|
|
|
- continue;
|
|
|
+ MessageBox.Show(table["message22"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
+ return false;
|
|
|
}
|
|
|
-
|
|
|
- MessageBox.Show(table["message21"].ToString() + list_all[i], table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return false;
|
|
|
}
|
|
|
- //检测是否有<>= true,false
|
|
|
- if (!m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text.ToString().Contains("<") && !m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text.ToString().Contains(">") && !m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text.ToString().Contains("=") && m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text.ToString() != "true" && m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text.ToString() != "false")
|
|
|
+ else
|
|
|
{
|
|
|
- MessageBox.Show(table["message22"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return false;
|
|
|
+ var XrayInfo = m_SubMidWindow.m_STDEditor.m_STDXrayList.Find(STDXray => STDXray.StdID == m_STDRuleslist.Grid_Minerals[m_STDRuleslist.PreRow, 0].Tag.ToString());
|
|
|
+ if (XrayInfo==null||XrayInfo.XrayData==null)
|
|
|
+ {
|
|
|
+ MessageBox.Show(table["message38"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
@@ -497,13 +508,13 @@ namespace OTSPartA_STDEditor
|
|
|
// MessageBox.Show(table["message12"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
// return false;
|
|
|
//}
|
|
|
- if (int.Parse(m_Attributes.Grid_Attributes[7, 1].Value.ToString()) <= 0)
|
|
|
- {
|
|
|
- Position pos = new Position(7, 1);
|
|
|
- m_Attributes.Grid_Attributes.Selection.Focus(pos, true);
|
|
|
- MessageBox.Show(table["message9"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return false;
|
|
|
- }
|
|
|
+ //if (int.Parse(m_Attributes.Grid_Attributes[7, 1].Value.ToString()) <= 0)
|
|
|
+ //{
|
|
|
+ // Position pos = new Position(7, 1);
|
|
|
+ // m_Attributes.Grid_Attributes.Selection.Focus(pos, true);
|
|
|
+ // MessageBox.Show(table["message9"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
+ // return false;
|
|
|
+ //}
|
|
|
if (m_Attributes.Grid_Attributes[10, 1].Value != null)
|
|
|
{
|
|
|
if (!GroupIdDictionaryFromName.ContainsKey(m_Attributes.Grid_Attributes[10, 1].Value.ToString()))
|
|
@@ -541,7 +552,7 @@ namespace OTSPartA_STDEditor
|
|
|
STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, PreColumn].Tag.ToString())].Hardness = m_Attributes.Grid_Attributes[4, 1].Value.ToString();
|
|
|
STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, PreColumn].Tag.ToString())].Density = m_Attributes.Grid_Attributes[5, 1].Value.ToString();
|
|
|
STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, PreColumn].Tag.ToString())].Electrical_conductivity = m_Attributes.Grid_Attributes[6, 1].Value.ToString();
|
|
|
- STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, PreColumn].Tag.ToString())].BSE = m_Attributes.Grid_Attributes[7, 1].Value.ToString();
|
|
|
+ STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, PreColumn].Tag.ToString())].BSE = m_Attributes.Grid_Attributes[7, 1].Value.ToString();
|
|
|
|
|
|
|
|
|
if (m_Attributes.Grid_Attributes[8, 1].Value!= null)
|
|
@@ -772,39 +783,6 @@ namespace OTSPartA_STDEditor
|
|
|
dt.Rows.Add(newRow);
|
|
|
}
|
|
|
m_dataAdapter.Update(ds,"ClassifySTD");
|
|
|
- //m_dataAdapter.Update(ds, "ClassifySTD_Backup");
|
|
|
-
|
|
|
- //Dictionary<int, string> MineralElements = new Dictionary<int, string>();
|
|
|
- //foreach (KeyValuePair<int, STDdata> kv in STDDictionary)
|
|
|
- //{
|
|
|
- // string[] ConstantsStr = kv.Value.Element.Split(',');
|
|
|
- // //string[] ConstantsStrnew=new
|
|
|
- // //for (int i = 0; i < ConstantsStr.Length; i++)
|
|
|
- // //{
|
|
|
-
|
|
|
- // //}
|
|
|
- // for (int i = 0; i < ConstantsStr.Length; i++)
|
|
|
- // {
|
|
|
-
|
|
|
- // string[] ConstantsStr2 = ConstantsStr[i].Split(':');
|
|
|
- // double elementPercentage=0;
|
|
|
- // if (ConstantsStr2.Length == 2)
|
|
|
- // {
|
|
|
- // if (double.TryParse(ConstantsStr2[1], out elementPercentage) && m_SubMidWindow.m_STDEditor.comboBox_PeriodicTable.Items.Contains(ConstantsStr2[0]))
|
|
|
- // {
|
|
|
- // int elementID = GetelementID(ConstantsStr2[0]);
|
|
|
-
|
|
|
- // string insertstr = "Insert into MineralElements(mineralID,elementID,elementName,elementPercentage)";
|
|
|
- // string aa="values(" + kv.Key + ",'" + elementID + "','" + ConstantsStr2[0] + "','" + elementPercentage + "')";
|
|
|
- // cmm.CommandText = insertstr+aa;
|
|
|
- // cmm.ExecuteNonQuery();
|
|
|
- // }
|
|
|
-
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- //}
|
|
|
-
|
|
|
m_dbConnection.Close();
|
|
|
}
|
|
|
catch (Exception ex)
|
|
@@ -815,351 +793,6 @@ namespace OTSPartA_STDEditor
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- //int GetelementID(string elementName)
|
|
|
- //{
|
|
|
- // int elementID = 0;
|
|
|
- // switch (elementName)
|
|
|
- // {
|
|
|
- // case "H":
|
|
|
- // elementID = 1;
|
|
|
- // break;
|
|
|
- // case "He":
|
|
|
- // elementID = 2;
|
|
|
- // break;
|
|
|
- // case "Li":
|
|
|
- // elementID = 3;
|
|
|
- // break;
|
|
|
- // case "Be":
|
|
|
- // elementID = 4;
|
|
|
- // break;
|
|
|
- // case "B":
|
|
|
- // elementID = 5;
|
|
|
- // break;
|
|
|
- // case "C":
|
|
|
- // elementID = 6;
|
|
|
- // break;
|
|
|
- // case "N":
|
|
|
- // elementID = 7;
|
|
|
- // break;
|
|
|
- // case "O":
|
|
|
- // elementID = 8;
|
|
|
- // break;
|
|
|
- // case "F":
|
|
|
- // elementID = 9;
|
|
|
- // break;
|
|
|
- // case "Ne":
|
|
|
- // elementID = 10;
|
|
|
- // break;
|
|
|
- // case "Na":
|
|
|
- // elementID = 11;
|
|
|
- // break;
|
|
|
- // case "Mg":
|
|
|
- // elementID = 12;
|
|
|
- // break;
|
|
|
- // case "Al":
|
|
|
- // elementID = 13;
|
|
|
- // break;
|
|
|
- // case "Si":
|
|
|
- // elementID = 14;
|
|
|
- // break;
|
|
|
- // case "P":
|
|
|
- // elementID = 15;
|
|
|
- // break;
|
|
|
- // case "S":
|
|
|
- // elementID = 16;
|
|
|
- // break;
|
|
|
- // case "Cl":
|
|
|
- // elementID = 17;
|
|
|
- // break;
|
|
|
- // case "Ar":
|
|
|
- // elementID = 18;
|
|
|
- // break;
|
|
|
- // case "K":
|
|
|
- // elementID = 19;
|
|
|
- // break;
|
|
|
- // case "Ca":
|
|
|
- // elementID = 20;
|
|
|
- // break;
|
|
|
- // case "Sc":
|
|
|
- // elementID = 21;
|
|
|
- // break;
|
|
|
- // case "Ti":
|
|
|
- // elementID = 22;
|
|
|
- // break;
|
|
|
- // case "V":
|
|
|
- // elementID = 23;
|
|
|
- // break;
|
|
|
- // case "Cr":
|
|
|
- // elementID = 24;
|
|
|
- // break;
|
|
|
- // case "Mn":
|
|
|
- // elementID = 25;
|
|
|
- // break;
|
|
|
- // case "Fe":
|
|
|
- // elementID = 26;
|
|
|
- // break;
|
|
|
- // case "Co":
|
|
|
- // elementID = 27;
|
|
|
- // break;
|
|
|
- // case "Ni":
|
|
|
- // elementID = 28;
|
|
|
- // break;
|
|
|
- // case "Cu":
|
|
|
- // elementID = 29;
|
|
|
- // break;
|
|
|
- // case "Zn":
|
|
|
- // elementID = 30;
|
|
|
- // break;
|
|
|
- // case "Ga":
|
|
|
- // elementID = 31;
|
|
|
- // break;
|
|
|
- // case "Ge":
|
|
|
- // elementID = 32;
|
|
|
- // break;
|
|
|
- // case "As":
|
|
|
- // elementID = 33;
|
|
|
- // break;
|
|
|
- // case "Se":
|
|
|
- // elementID = 34;
|
|
|
- // break;
|
|
|
- // case "Br":
|
|
|
- // elementID = 35;
|
|
|
- // break;
|
|
|
- // case "Kr":
|
|
|
- // elementID = 36;
|
|
|
- // break;
|
|
|
- // case "Rb":
|
|
|
- // elementID = 37;
|
|
|
- // break;
|
|
|
- // case "Sr":
|
|
|
- // elementID = 38;
|
|
|
- // break;
|
|
|
- // case "Y":
|
|
|
- // elementID = 39;
|
|
|
- // break;
|
|
|
- // case "Zr":
|
|
|
- // elementID = 40;
|
|
|
- // break;
|
|
|
- // case "Nb":
|
|
|
- // elementID = 41;
|
|
|
- // break;
|
|
|
- // case "Mo":
|
|
|
- // elementID = 42;
|
|
|
- // break;
|
|
|
- // case "Tc":
|
|
|
- // elementID = 43;
|
|
|
- // break;
|
|
|
- // case "Ru":
|
|
|
- // elementID = 44;
|
|
|
- // break;
|
|
|
- // case "Rh":
|
|
|
- // elementID = 45;
|
|
|
- // break;
|
|
|
- // case "Pd":
|
|
|
- // elementID = 46;
|
|
|
- // break;
|
|
|
- // case "Ag":
|
|
|
- // elementID = 47;
|
|
|
- // break;
|
|
|
- // case "Cd":
|
|
|
- // elementID = 48;
|
|
|
- // break;
|
|
|
- // case "In":
|
|
|
- // elementID = 49;
|
|
|
- // break;
|
|
|
- // case "Sn":
|
|
|
- // elementID = 50;
|
|
|
- // break;
|
|
|
- // case "Sb":
|
|
|
- // elementID = 51;
|
|
|
- // break;
|
|
|
- // case "Te":
|
|
|
- // elementID = 52;
|
|
|
- // break;
|
|
|
- // case "I":
|
|
|
- // elementID = 53;
|
|
|
- // break;
|
|
|
- // case "Xe":
|
|
|
- // elementID = 54;
|
|
|
- // break;
|
|
|
- // case "Cs":
|
|
|
- // elementID = 55;
|
|
|
- // break;
|
|
|
- // case "Ba":
|
|
|
- // elementID = 56;
|
|
|
- // break;
|
|
|
- // case "La":
|
|
|
- // elementID = 57;
|
|
|
- // break;
|
|
|
- // case "Ce":
|
|
|
- // elementID = 58;
|
|
|
- // break;
|
|
|
- // case "Pr":
|
|
|
- // elementID = 59;
|
|
|
- // break;
|
|
|
- // case "Nd":
|
|
|
- // elementID = 60;
|
|
|
- // break;
|
|
|
- // case "Pm":
|
|
|
- // elementID = 61;
|
|
|
- // break;
|
|
|
- // case "Sm":
|
|
|
- // elementID = 62;
|
|
|
- // break;
|
|
|
- // case "Eu":
|
|
|
- // elementID = 63;
|
|
|
- // break;
|
|
|
- // case "Gd":
|
|
|
- // elementID = 64;
|
|
|
- // break;
|
|
|
- // case "Tb":
|
|
|
- // elementID = 65;
|
|
|
- // break;
|
|
|
- // case "Dy":
|
|
|
- // elementID = 66;
|
|
|
- // break;
|
|
|
- // case "Ho":
|
|
|
- // elementID = 67;
|
|
|
- // break;
|
|
|
- // case "Er":
|
|
|
- // elementID = 68;
|
|
|
- // break;
|
|
|
- // case "Tm":
|
|
|
- // elementID = 69;
|
|
|
- // break;
|
|
|
- // case "Yb":
|
|
|
- // elementID = 70;
|
|
|
- // break;
|
|
|
- // case "Lu":
|
|
|
- // elementID = 71;
|
|
|
- // break;
|
|
|
- // case "Hf":
|
|
|
- // elementID = 72;
|
|
|
- // break;
|
|
|
- // case "Ta":
|
|
|
- // elementID = 73;
|
|
|
- // break;
|
|
|
- // case "W":
|
|
|
- // elementID = 74;
|
|
|
- // break;
|
|
|
- // case "Re":
|
|
|
- // elementID = 75;
|
|
|
- // break;
|
|
|
- // case "Os":
|
|
|
- // elementID = 76;
|
|
|
- // break;
|
|
|
- // case "Ir":
|
|
|
- // elementID = 77;
|
|
|
- // break;
|
|
|
- // case "Pt":
|
|
|
- // elementID = 78;
|
|
|
- // break;
|
|
|
- // case "Au":
|
|
|
- // elementID = 79;
|
|
|
- // break;
|
|
|
- // case "Hq":
|
|
|
- // elementID = 80;
|
|
|
- // break;
|
|
|
- // case "TI":
|
|
|
- // elementID = 81;
|
|
|
- // break;
|
|
|
- // case "Pb":
|
|
|
- // elementID = 82;
|
|
|
- // break;
|
|
|
- // case "Bi":
|
|
|
- // elementID = 83;
|
|
|
- // break;
|
|
|
- // case "Po":
|
|
|
- // elementID = 84;
|
|
|
- // break;
|
|
|
- // case "At":
|
|
|
- // elementID = 85;
|
|
|
- // break;
|
|
|
- // case "Rn":
|
|
|
- // elementID = 86;
|
|
|
- // break;
|
|
|
- // case "Fr":
|
|
|
- // elementID = 87;
|
|
|
- // break;
|
|
|
- // case "Ra":
|
|
|
- // elementID = 88;
|
|
|
- // break;
|
|
|
- // case "Ac":
|
|
|
- // elementID = 89;
|
|
|
- // break;
|
|
|
- // case "Th":
|
|
|
- // elementID = 90;
|
|
|
- // break;
|
|
|
- // case "Pa":
|
|
|
- // elementID = 91;
|
|
|
- // break;
|
|
|
- // case "U":
|
|
|
- // elementID = 92;
|
|
|
- // break;
|
|
|
- // case "Np":
|
|
|
- // elementID = 93;
|
|
|
- // break;
|
|
|
- // case "Pu":
|
|
|
- // elementID = 94;
|
|
|
- // break;
|
|
|
- // case "Am":
|
|
|
- // elementID = 95;
|
|
|
- // break;
|
|
|
- // case "Cm":
|
|
|
- // elementID = 96;
|
|
|
- // break;
|
|
|
- // case "Bk":
|
|
|
- // elementID = 97;
|
|
|
- // break;
|
|
|
- // case "Cf":
|
|
|
- // elementID = 98;
|
|
|
- // break;
|
|
|
- // case "Es":
|
|
|
- // elementID = 99;
|
|
|
- // break;
|
|
|
- // case "Fm":
|
|
|
- // elementID = 100;
|
|
|
- // break;
|
|
|
- // case "Mc":
|
|
|
- // elementID = 101;
|
|
|
- // break;
|
|
|
- // case "No":
|
|
|
- // elementID = 102;
|
|
|
- // break;
|
|
|
- // case "Lr":
|
|
|
- // elementID = 103;
|
|
|
- // break;
|
|
|
- // case "Rf":
|
|
|
- // elementID = 104;
|
|
|
- // break;
|
|
|
- // case "Db":
|
|
|
- // elementID = 105;
|
|
|
- // break;
|
|
|
- // case "Sg":
|
|
|
- // elementID = 106;
|
|
|
- // break;
|
|
|
- // case "Bh":
|
|
|
- // elementID = 107;
|
|
|
- // break;
|
|
|
- // case "Hs":
|
|
|
- // elementID = 108;
|
|
|
- // break;
|
|
|
- // case "Mt":
|
|
|
- // elementID = 109;
|
|
|
- // break;
|
|
|
- // case "Ds":
|
|
|
- // elementID = 110;
|
|
|
- // break;
|
|
|
- // case "Rg":
|
|
|
- // elementID = 111;
|
|
|
- // break;
|
|
|
- // case "Unb":
|
|
|
- // elementID = 112;
|
|
|
- // break;
|
|
|
- // }
|
|
|
- // return elementID;
|
|
|
- //}
|
|
|
-
|
|
|
public int AddSTDDictionaryItem()
|
|
|
{
|
|
|
STDdata new_STDdata = new STDdata();//定义一个TreeNode节点对象
|
|
@@ -1591,8 +1224,8 @@ namespace OTSPartA_STDEditor
|
|
|
else
|
|
|
{
|
|
|
STDDictionaryInitial.Clear();
|
|
|
- }
|
|
|
- if (!EqualsBetweenDictionary(STDDictionaryInitial, STDDictionary) || IsModified)
|
|
|
+ } if (!EqualsBetweenDictionary(STDDictionaryInitial, STDDictionary) || IsModified)
|
|
|
+
|
|
|
{
|
|
|
DialogResult dr = MessageBox.Show("是否保存当前修改", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
|
if (dr == DialogResult.Yes)
|
|
@@ -1774,29 +1407,6 @@ namespace OTSPartA_STDEditor
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //public bool EqualToDictionary(Dictionary<int, STDdata> STDDictionary, Dictionary<int, STDdata> STDDictionaryInitial)
|
|
|
- //{
|
|
|
- // if(STDDictionary.Count!= STDDictionaryInitial.Count)
|
|
|
- // {
|
|
|
- // return false;
|
|
|
- // }
|
|
|
- // foreach (KeyValuePair<int, STDdata> kv in STDDictionary)
|
|
|
- // {
|
|
|
- // if (!STDDictionaryInitial.ContainsKey(kv.Key))
|
|
|
- // {
|
|
|
- // return false;
|
|
|
- // }
|
|
|
- // else
|
|
|
- // {
|
|
|
- // if (kv.Value.StrName != STDDictionaryInitial[kv.Key].StrName || kv.Value.Color != STDDictionaryInitial[kv.Key].Color || kv.Value.KeyElementList != STDDictionaryInitial[kv.Key].KeyElementList || kv.Value.SubElementList != STDDictionaryInitial[kv.Key].SubElementList || kv.Value.UsingImgPropertyList != STDDictionaryInitial[kv.Key].UsingImgPropertyList || kv.Value.UsingOtherPropertyList != STDDictionaryInitial[kv.Key].UsingOtherPropertyList || kv.Value.Expression != STDDictionaryInitial[kv.Key].Expression || kv.Value.Hardness != STDDictionaryInitial[kv.Key].Hardness || kv.Value.Density != STDDictionaryInitial[kv.Key].Density || kv.Value.Electrical_conductivity != STDDictionaryInitial[kv.Key].Electrical_conductivity || kv.Value.BSE != STDDictionaryInitial[kv.Key].BSE || kv.Value.Formula != STDDictionaryInitial[kv.Key].Formula || kv.Value.Element != STDDictionaryInitial[kv.Key].Element || kv.Value.GroupId != STDDictionaryInitial[kv.Key].GroupId || kv.Value.ListNum != STDDictionaryInitial[kv.Key].ListNum)
|
|
|
- // {
|
|
|
- // return false;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // return true;
|
|
|
- //}
|
|
|
-
|
|
|
bool EqualsBetweenDictionary(Dictionary<int, STDdata> STDDictionaryInitial, Dictionary<int, STDdata> STDDictionary)
|
|
|
{
|
|
|
if(STDDictionaryInitial.Count!= STDDictionary.Count)
|
|
@@ -1876,80 +1486,81 @@ namespace OTSPartA_STDEditor
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- #region 老方法,标识判断,总是重复性保存
|
|
|
- //if (IsModified)
|
|
|
- //{
|
|
|
- // DialogResult dr = MessageBox.Show("是否保存当前修改", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
|
- // if (dr == DialogResult.Yes)
|
|
|
- // {
|
|
|
- // if (m_STDRuleslist.Grid_Minerals.RowsCount > 1)
|
|
|
- // {
|
|
|
- // if (m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row > 0)
|
|
|
- // {
|
|
|
- // if (m_STDRuleslist.Grid_Minerals[m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0].Value.ToString().Replace(" ", "").Trim() != "")
|
|
|
- // {
|
|
|
- // if (CheckAttributes())
|
|
|
- // {
|
|
|
- // if (Checktextbox_STDEditor())
|
|
|
- // {
|
|
|
-
|
|
|
- // }
|
|
|
- // else
|
|
|
- // {
|
|
|
- // e.Cancel = true;
|
|
|
- // return;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // else
|
|
|
- // {
|
|
|
- // e.Cancel = true;
|
|
|
- // return;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // else
|
|
|
- // {
|
|
|
- // e.Cancel = true;
|
|
|
- // return;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // else
|
|
|
- // {
|
|
|
- // Position pos = new Position(1, 0);
|
|
|
- // m_STDRuleslist.Grid_Minerals[1, 0].Grid.Select();
|
|
|
- // if (m_STDRuleslist.Grid_Minerals[m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0].Value.ToString().Replace(" ", "").Trim() != "")
|
|
|
- // {
|
|
|
- // if (CheckAttributes())
|
|
|
- // {
|
|
|
- // if (Checktextbox_STDEditor())
|
|
|
- // {
|
|
|
-
|
|
|
- // }
|
|
|
- // else
|
|
|
- // {
|
|
|
- // e.Cancel = true;
|
|
|
- // return;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // else
|
|
|
- // {
|
|
|
- // e.Cancel = true;
|
|
|
- // return;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // else
|
|
|
- // {
|
|
|
- // e.Cancel = true;
|
|
|
- // return;
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- // }
|
|
|
- // rbSave_Click(this, e);
|
|
|
- // }
|
|
|
- //}
|
|
|
+ }
|
|
|
|
|
|
- #endregion
|
|
|
+ private void ribbon_ConvertOreDatabaseToOtsDatabase_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ DataTable OreDatabasedt = new DataTable();
|
|
|
+ OpenFileDialog openFileDialog = new OpenFileDialog();
|
|
|
+ openFileDialog.Title= table["message37"].ToString();
|
|
|
+ openFileDialog.Filter = "(*.db)|*.db";
|
|
|
+ openFileDialog.RestoreDirectory = true;
|
|
|
+ openFileDialog.FilterIndex = 1;
|
|
|
+ if (openFileDialog.ShowDialog() == DialogResult.OK)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ string OreDatabaseAddress = openFileDialog.FileName;
|
|
|
+ System.Data.SQLite.SQLiteConnection m_OreDatabaseConnection = new System.Data.SQLite.SQLiteConnection("data source='" + OreDatabaseAddress + "'");
|
|
|
+ m_OreDatabaseConnection.Open();
|
|
|
+ System.Data.SQLite.SQLiteDataAdapter m_OreDatabasedataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select * from STDMinerals", m_OreDatabaseConnection);
|
|
|
+ DataSet OreDatabaseds = new DataSet();
|
|
|
+ m_OreDatabasedataAdapter.Fill(OreDatabaseds);
|
|
|
+ OreDatabasedt = OreDatabaseds.Tables[0];
|
|
|
+
|
|
|
+ int listnum = 1;
|
|
|
+ SaveFileDialog saveFile = new SaveFileDialog();
|
|
|
+ saveFile.Title = table["message23"].ToString();
|
|
|
+ saveFile.Filter = table["message36"].ToString();
|
|
|
+ saveFile.OverwritePrompt = true; //是否覆盖当前文件
|
|
|
+ saveFile.RestoreDirectory = true; //还原上次目录
|
|
|
+ if (saveFile.ShowDialog() == DialogResult.OK)
|
|
|
+ {
|
|
|
+ System.Data.SQLite.SQLiteConnection.CreateFile(saveFile.FileName);
|
|
|
+ System.Data.SQLite.SQLiteConnection m_OtsDatabaseConnection = new System.Data.SQLite.SQLiteConnection("data source='" + saveFile.FileName + "'");
|
|
|
+ m_OtsDatabaseConnection.Open();
|
|
|
+ System.Data.SQLite.SQLiteCommand OtsDatabaseCommand = m_OtsDatabaseConnection.CreateCommand();
|
|
|
+ OtsDatabaseCommand.CommandText = "CREATE TABLE ClassifySTD (STDId INTEGER,StrName TEXT, Color TEXT,KeyElementList TEXT,SubElementList TEXT,UsingImgPropertyList TEXT,UsingOtherPropertyList TEXT,Expression TEXT,Hardness TEXT,Density TEXT,Electrical_conductivity TEXT,BSE INTEGER,Formula TEXT,Element TEXT,ListNum INT,GroupId INT)";
|
|
|
+ OtsDatabaseCommand.ExecuteNonQuery();
|
|
|
+ OtsDatabaseCommand.CommandText = "CREATE TABLE Constants (value TEXT)";
|
|
|
+ OtsDatabaseCommand.ExecuteNonQuery();
|
|
|
+ OtsDatabaseCommand.CommandText = "CREATE TABLE MaxEDSRules (MaxEDSTime INT,UsingElementList TEXT, UsingImgPropertyList TEXT,UsingOtherPropertyList TEXT,Expression TEXT)";
|
|
|
+ OtsDatabaseCommand.ExecuteNonQuery();
|
|
|
+ OtsDatabaseCommand.CommandText = "CREATE TABLE STDGroups (id INTEGER,name TEXT, color INTEGER,iorder INTEGER)";
|
|
|
+ OtsDatabaseCommand.ExecuteNonQuery();
|
|
|
+ OtsDatabaseCommand.CommandText = "CREATE TABLE STDMinerals (id INTEGER,SPEC BLOB)";
|
|
|
+ OtsDatabaseCommand.ExecuteNonQuery();
|
|
|
+ OtsDatabaseCommand.CommandText = "CREATE TABLE ZeroElementRules (ZeroElement TEXT,UsingElementList TEXT, UsingImgPropertyList TEXT,Expression TEXT)";
|
|
|
+ OtsDatabaseCommand.ExecuteNonQuery();
|
|
|
+ System.Data.Common.DbTransaction trans = m_OtsDatabaseConnection.BeginTransaction();
|
|
|
+
|
|
|
+ foreach (DataRow item in OreDatabasedt.Rows)
|
|
|
+ {
|
|
|
+ OtsDatabaseCommand.CommandText = "insert into ClassifySTD (Density,BSE,Formula,StrName,Color,STDId,ListNum,GroupId,KeyElementList,SubElementList,UsingImgPropertyList,UsingOtherPropertyList,Expression,Hardness,Electrical_conductivity,Element) values ( '" + item["density"].ToString() + "','" + item["BSEValue"].ToString() + "','" + item["formula"].ToString() + "','" + item["name"].ToString() + "','" + item["color"].ToString() + "'," + item["id"].ToString() + "," + listnum.ToString() + @",0,' ',' ',' ',' ',' ',' ',' ',' ')";
|
|
|
+ OtsDatabaseCommand.ExecuteNonQuery();
|
|
|
+ listnum++;
|
|
|
+ OtsDatabaseCommand.CommandText = "insert into STDMinerals (id,SPEC) values (@id,@SPEC)";
|
|
|
+ OtsDatabaseCommand.Parameters.Add("id", DbType.Int32).Value = item["id"];
|
|
|
+ OtsDatabaseCommand.Parameters.Add("SPEC", DbType.Binary).Value = item["SPEC"];
|
|
|
+ OtsDatabaseCommand.ExecuteNonQuery();
|
|
|
+ }
|
|
|
+
|
|
|
+ trans.Commit();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch(Exception ex)
|
|
|
+ {
|
|
|
+ MessageBox.Show(ex.ToString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|