|
@@ -20,9 +20,15 @@ namespace OTSPartA_STDEditor
|
|
|
public STDRuleslist m_STDRuleslist = null;
|
|
|
public Attributes m_Attributes = null;
|
|
|
public SubMidWindow m_SubMidWindow = null;
|
|
|
+ /// <summary>
|
|
|
+ /// 实际存储的字典
|
|
|
+ /// </summary>
|
|
|
public Dictionary<int, STDdata> STDDictionary = new Dictionary<int, STDdata>();
|
|
|
- private Dictionary<int, STDdata> STDDictionaryInitial=new Dictionary<int, STDdata>();
|
|
|
- public Dictionary<int,string> GroupIdDictionaryFromId = new Dictionary<int,string>();
|
|
|
+ /// <summary>
|
|
|
+ /// 原始数据字典用于在关闭时比较是否弹出保存提示
|
|
|
+ /// </summary>
|
|
|
+ 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_backupDirectory = Application.StartupPath + "\\Config\\SysData\\LibBackup\\";
|
|
|
public string STDDBAddress = "";
|
|
@@ -110,7 +116,7 @@ namespace OTSPartA_STDEditor
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- bool LoadClassifyToDictionary(string DBAddress, ref Dictionary<int, STDdata> STDDictionary)
|
|
|
+ bool LoadClassifyToDictionary(string DBAddress, ref Dictionary<int, STDdata> STDDictionary)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
@@ -155,9 +161,9 @@ namespace OTSPartA_STDEditor
|
|
|
new_STDdata.KeyElementList = item["KeyElementList"].ToString();
|
|
|
new_STDdata.SubElementList = item["SubElementList"].ToString();
|
|
|
new_STDdata.GroupId = item["GroupId"].ToString();
|
|
|
- new_STDdata.ListNum= item["ListNum"].ToString();
|
|
|
+ new_STDdata.ListNum = item["ListNum"].ToString();
|
|
|
new_STDdata.GroupId = item["GroupId"].ToString();
|
|
|
- if(dt.Columns.Contains("IfElementAnalysis"))
|
|
|
+ if (dt.Columns.Contains("IfElementAnalysis"))
|
|
|
{
|
|
|
if (Convert.ToBoolean(item["IfElementAnalysis"]))
|
|
|
{
|
|
@@ -191,76 +197,51 @@ namespace OTSPartA_STDEditor
|
|
|
{
|
|
|
if (m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row >= 0)
|
|
|
{
|
|
|
- if (CheckAttributes())
|
|
|
- {
|
|
|
- if (Checktextbox_STDEditor())
|
|
|
- {
|
|
|
- SaveDataOfSelRule(m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Column);
|
|
|
-
|
|
|
- try
|
|
|
- {
|
|
|
- SaveFileDialog saveFile = new SaveFileDialog();
|
|
|
- saveFile.Title = "Please select the path which to save the file";
|
|
|
- saveFile.Filter = "Database File(*.db)|*.db";
|
|
|
- saveFile.InitialDirectory = Application.StartupPath + "\\Config\\SysData\\";
|
|
|
- saveFile.OverwritePrompt = false; //是否覆盖当前文件
|
|
|
- //saveFile.RestoreDirectory = true; //还原上次目录
|
|
|
- if (saveFile.ShowDialog() == DialogResult.OK)
|
|
|
- {
|
|
|
- if(STDDBAddress== saveFile.FileName)
|
|
|
- {
|
|
|
- MessageBox.Show("不能另存为同名文件!", "Tip");
|
|
|
- return;
|
|
|
- }
|
|
|
- System.IO.File.Copy(STDDBAddress, saveFile.FileName, true);
|
|
|
- bool result = SaveAsDictionaryToClassify(saveFile.FileName);
|
|
|
- STDDBAddress = saveFile.FileName;
|
|
|
- this.Text = this.Text.Split(' ')[0] + " " + saveFile.FileName;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- MessageBox.Show(ex.Message);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- MessageBox.Show("The name of rulecannot be empty!", "Tip");
|
|
|
- }
|
|
|
+ SaveDataOfSelRule(m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Column);
|
|
|
}
|
|
|
- else
|
|
|
+ try
|
|
|
{
|
|
|
- try
|
|
|
+ SaveFileDialog saveFile = new SaveFileDialog();
|
|
|
+ saveFile.Title = "Please select the path which to save the file";
|
|
|
+ saveFile.Filter = "Database File(*.db)|*.db";
|
|
|
+ saveFile.InitialDirectory = Application.StartupPath + "\\Config\\SysData\\";
|
|
|
+ saveFile.OverwritePrompt = false; //是否覆盖当前文件
|
|
|
+ if (saveFile.ShowDialog() == DialogResult.OK)
|
|
|
{
|
|
|
- SaveFileDialog saveFile = new SaveFileDialog();
|
|
|
- saveFile.Title = "Please select the path which to save the file";
|
|
|
- saveFile.Filter = "Database File(*.db)|*.db";
|
|
|
- saveFile.OverwritePrompt = true; //是否覆盖当前文件
|
|
|
- saveFile.RestoreDirectory = true; //还原上次目录
|
|
|
- if (saveFile.ShowDialog() == DialogResult.OK)
|
|
|
+ if (STDDBAddress == saveFile.FileName)
|
|
|
{
|
|
|
- System.IO.File.Copy(STDDBAddress, saveFile.FileName, true);
|
|
|
- bool result = SaveDictionaryToClassify(saveFile.FileName);
|
|
|
- if (result)
|
|
|
- {
|
|
|
- MessageBox.Show("Export file successful!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- }
|
|
|
+ MessageBox.Show("不能另存为同名文件!", "Tip");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ FormForWaiting forWaiting = new FormForWaiting();
|
|
|
+ forWaiting.Show();
|
|
|
+ System.IO.File.Copy(STDDBAddress, saveFile.FileName, true);
|
|
|
+ bool result = SaveAsDictionaryToClassify(saveFile.FileName);
|
|
|
+ if (result)
|
|
|
+ {
|
|
|
+ STDDictionaryInitial.Clear();
|
|
|
+ STDDictionaryInitial = Clone(STDDictionary) as Dictionary<int, STDdata>;
|
|
|
+ STDDBAddress = saveFile.FileName;
|
|
|
+ this.Text = this.Text.Split(' ')[0] + " " + saveFile.FileName;
|
|
|
+ IsModified = false;
|
|
|
+ forWaiting.Close();
|
|
|
+ MessageBox.Show("Save successful!", "Tip");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- return;
|
|
|
+ forWaiting.Close();
|
|
|
+ MessageBox.Show("Save failed!", "Tip");
|
|
|
}
|
|
|
}
|
|
|
- catch (Exception ex)
|
|
|
+ else
|
|
|
{
|
|
|
- MessageBox.Show(ex.Message);
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ MessageBox.Show(ex.Message);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public bool ClearDb(string DBAddress, string DBTableName)
|
|
@@ -297,69 +278,56 @@ namespace OTSPartA_STDEditor
|
|
|
|
|
|
private void rbSave_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
- if (m_STDRuleslist.Grid_Minerals.RowsCount > 1)
|
|
|
+ if (m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row > 0)
|
|
|
{
|
|
|
- if (m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row > 0)
|
|
|
+ SaveDataOfSelRule(m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0);
|
|
|
+ }
|
|
|
+ if (RuleformatcheckAndSave())
|
|
|
+ {
|
|
|
+ FormForWaiting forWaiting = new FormForWaiting();
|
|
|
+ forWaiting.Show();
|
|
|
+ bool result = SaveDictionaryToClassify(STDDBAddress);
|
|
|
+ if (result)
|
|
|
{
|
|
|
- if (m_STDRuleslist.Grid_Minerals[m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0].Value.ToString().Replace(" ", "").Trim() != "")
|
|
|
- {
|
|
|
- if (CheckAttributes())
|
|
|
- {
|
|
|
- if (Checktextbox_STDEditor())
|
|
|
- {
|
|
|
- FormForWaiting forWaiting = new FormForWaiting();
|
|
|
- forWaiting.Show();
|
|
|
- SaveDataOfSelRule(m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0);
|
|
|
- bool result = SaveDictionaryToClassify(STDDBAddress);
|
|
|
- if (result)
|
|
|
- {
|
|
|
- STDDictionaryInitial.Clear();
|
|
|
- STDDictionaryInitial = Clone(STDDictionary) as Dictionary<int, STDdata>;
|
|
|
- forWaiting.Close();
|
|
|
- IsModified = false;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- forWaiting.Close();
|
|
|
- MessageBox.Show("Save failed!", "Tip");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ STDDictionaryInitial.Clear();
|
|
|
+ STDDictionaryInitial = Clone(STDDictionary) as Dictionary<int, STDdata>;
|
|
|
+ forWaiting.Close();
|
|
|
+ IsModified = false;
|
|
|
+ MessageBox.Show("Save successful!", "Tip");
|
|
|
}
|
|
|
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())
|
|
|
- {
|
|
|
- FormForWaiting forWaiting = new FormForWaiting();
|
|
|
- forWaiting.Show();
|
|
|
- SaveDataOfSelRule(m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0);
|
|
|
- bool result = SaveDictionaryToClassify(STDDBAddress);
|
|
|
- if (result)
|
|
|
- {
|
|
|
- STDDictionaryInitial.Clear();
|
|
|
- STDDictionaryInitial = new Dictionary<int, STDdata>(STDDictionary);
|
|
|
- forWaiting.Close();
|
|
|
- IsModified = false;
|
|
|
- MessageBox.Show("Save successful!", "Tip");
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- forWaiting.Close();
|
|
|
- MessageBox.Show("Save failed!", "Tip");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ forWaiting.Close();
|
|
|
+ MessageBox.Show("Save failed!", "Tip");
|
|
|
}
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ bool RuleformatcheckAndSave()
|
|
|
+ {
|
|
|
+ foreach (var ite in STDDictionary)
|
|
|
+ {
|
|
|
+ if (CheckExpression(ite.Value.Expression))
|
|
|
+ {
|
|
|
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Position pos = new Position(Convert.ToInt32(ite.Value.ListNum), 0);
|
|
|
+ m_STDRuleslist.Grid_Minerals[Convert.ToInt32(ite.Value.ListNum), 0].Grid.Select();
|
|
|
+ m_STDRuleslist.Grid_Minerals.Selection.Focus(pos, true);
|
|
|
+ m_STDRuleslist.Grid_Minerals.Refresh();
|
|
|
+ ChangeSTDEditorAndGrid_Attributes(ite.Key);
|
|
|
+ m_STDRuleslist.PreRow = Convert.ToInt32(ite.Value.ListNum);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -374,10 +342,10 @@ namespace OTSPartA_STDEditor
|
|
|
return System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.FromArgb(R, G, B));
|
|
|
}
|
|
|
//表达式规则检查
|
|
|
- public bool Checktextbox_STDEditor()
|
|
|
+ public bool CheckExpression(string Expression)
|
|
|
{
|
|
|
- string str_RemoveBlank = m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text.ToString().Replace(" ", "");
|
|
|
- if (str_RemoveBlank != "")
|
|
|
+ string str_RemoveBlank = Expression.Replace(" ", "");
|
|
|
+ if (!string.IsNullOrEmpty(str_RemoveBlank))
|
|
|
{
|
|
|
str_RemoveBlank = str_RemoveBlank.Replace("\r\n", "");
|
|
|
//分割符号检验
|
|
@@ -406,37 +374,36 @@ namespace OTSPartA_STDEditor
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
- if ((str_RemoveBlank != null) && (str_RemoveBlank != ""))
|
|
|
+
|
|
|
+ //左右括号匹配检验
|
|
|
+ int BracketsNum = 0;
|
|
|
+ for (int i = 0; i < str_RemoveBlank.Length; i++)
|
|
|
{
|
|
|
- //左右括号匹配检验
|
|
|
- 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("Number of left and right parentheses does not match!", "Tip", 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] == '('))
|
|
|
+ if (str_RemoveBlank[i] == '(') BracketsNum++;
|
|
|
+ if (str_RemoveBlank[i] == ')') BracketsNum--;
|
|
|
+ }
|
|
|
+ if (BracketsNum != 0)
|
|
|
+ {
|
|
|
+ MessageBox.Show("Number of left and right parentheses does not match!", "Tip", 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("First character is error!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (str_RemoveBlank.Length >= 3)
|
|
|
+ {
|
|
|
+ if ((str_RemoveBlank.Substring(0, 3) == "and") || (str_RemoveBlank.Substring(0, 3) == "end"))
|
|
|
{
|
|
|
MessageBox.Show("First character is error!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
- if (str_RemoveBlank.Length >= 3)
|
|
|
- {
|
|
|
- if ((str_RemoveBlank.Substring(0, 3) == "and") || (str_RemoveBlank.Substring(0, 3) == "end"))
|
|
|
- {
|
|
|
- MessageBox.Show("First character is error!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
//forth_elem干扰or分隔符,故先行去掉
|
|
|
str_RemoveBlank = str_RemoveBlank.Replace("forth_elem", "");
|
|
|
|
|
@@ -507,56 +474,41 @@ namespace OTSPartA_STDEditor
|
|
|
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")
|
|
|
+ if (!Expression.Contains("<") && !Expression.Contains(">") && !Expression.Contains("=") && Expression.ToLower() != "true" && Expression.ToLower() != "false")
|
|
|
{
|
|
|
MessageBox.Show("Expressions have no effect!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ MessageBox.Show("The expresstion is mull!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- //属性检测
|
|
|
- public bool CheckAttributes()
|
|
|
+ /// <summary>
|
|
|
+ /// 属性检测
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="ddata"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public bool CheckAttributes(STDdata ddata)
|
|
|
{
|
|
|
- //if (double.Parse(m_Attributes.Grid_Attributes[4, 1].Value.ToString()) <= 0)
|
|
|
- //{
|
|
|
- // Position pos = new Position(4, 1);
|
|
|
- // m_Attributes.Grid_Attributes.Selection.Focus(pos, true);
|
|
|
- // MessageBox.Show(table["message10"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- // return false;
|
|
|
- //}
|
|
|
- //if (double.Parse(m_Attributes.Grid_Attributes[5, 1].Value.ToString()) <= 0)
|
|
|
- //{
|
|
|
- // Position pos = new Position(5, 1);
|
|
|
- // m_Attributes.Grid_Attributes.Selection.Focus(pos, true);
|
|
|
- // MessageBox.Show(table["message11"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- // return false;
|
|
|
- //}
|
|
|
- //if (double.Parse(m_Attributes.Grid_Attributes[6, 1].Value.ToString()) <= 0)
|
|
|
- //{
|
|
|
- // Position pos = new Position(6, 1);
|
|
|
- // m_Attributes.Grid_Attributes.Selection.Focus(pos, true);
|
|
|
- // 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 (m_Attributes.Grid_Attributes[10, 1].Value != null)
|
|
|
+ if (string.IsNullOrEmpty(ddata.StrName))
|
|
|
{
|
|
|
- if (!GroupIdDictionaryFromName.ContainsKey(m_Attributes.Grid_Attributes[11, 1].Value.ToString()))
|
|
|
- {
|
|
|
- Position pos = new Position(11, 1);
|
|
|
- m_Attributes.Grid_Attributes.Selection.Focus(pos, true);
|
|
|
- MessageBox.Show("This group name is not included, please fill in again!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return false;
|
|
|
- }
|
|
|
+ MessageBox.Show("Rule name can not be null !", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
}
|
|
|
+ //if (string.IsNullOrEmpty(ddata.g)
|
|
|
+ //{
|
|
|
+ // if (!GroupIdDictionaryFromName.ContainsKey(m_Attributes.Grid_Attributes[11, 1].Value.ToString()))
|
|
|
+ // {
|
|
|
+ // Position pos = new Position(11, 1);
|
|
|
+ // m_Attributes.Grid_Attributes.Selection.Focus(pos, true);
|
|
|
+ // MessageBox.Show("This group name is not included, please fill in again!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
+ // return false;
|
|
|
+ // }
|
|
|
+ //}
|
|
|
#region 化学式和元素暂无限制
|
|
|
//if (m_Attributes.Grid_Attributes[7, 1].Value.ToString())
|
|
|
//{
|
|
@@ -579,18 +531,18 @@ namespace OTSPartA_STDEditor
|
|
|
|
|
|
public void SaveDataOfSelRule(int PreRow, int PreColumn)
|
|
|
{
|
|
|
- STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].StrName = m_Attributes.Grid_Attributes[2, 1].Value.ToString();
|
|
|
+ STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].StrName = Convert.ToString(m_Attributes.Grid_Attributes[2, 1].Value);
|
|
|
STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Color = colorRGBtoHx16(m_Attributes.Grid_Attributes[3, 1].View.BackColor.R, m_Attributes.Grid_Attributes[3, 1].View.BackColor.G, m_Attributes.Grid_Attributes[3, 1].View.BackColor.B);
|
|
|
STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].IfElementAnalysis = Convert.ToBoolean(m_Attributes.Grid_Attributes[4, 1].Value);
|
|
|
- STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Hardness = m_Attributes.Grid_Attributes[5, 1].Value.ToString();
|
|
|
- STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Density = m_Attributes.Grid_Attributes[6, 1].Value.ToString();
|
|
|
- STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Electrical_conductivity = m_Attributes.Grid_Attributes[7, 1].Value.ToString();
|
|
|
- STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].BSE = m_Attributes.Grid_Attributes[8, 1].Value.ToString();
|
|
|
-
|
|
|
+ STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Hardness = Convert.ToString(m_Attributes.Grid_Attributes[5, 1].Value);
|
|
|
+ STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Density = Convert.ToString(m_Attributes.Grid_Attributes[6, 1].Value);
|
|
|
+ STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Electrical_conductivity = Convert.ToString(m_Attributes.Grid_Attributes[7, 1].Value);
|
|
|
+ STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].BSE = Convert.ToString(m_Attributes.Grid_Attributes[8, 1].Value);
|
|
|
+
|
|
|
|
|
|
- if (m_Attributes.Grid_Attributes[9, 1].Value!= null)
|
|
|
+ if (m_Attributes.Grid_Attributes[9, 1].Value != null)
|
|
|
{
|
|
|
- STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Formula = m_Attributes.Grid_Attributes[9, 1].Value.ToString();
|
|
|
+ STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Formula = Convert.ToString(m_Attributes.Grid_Attributes[9, 1].Value);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -598,7 +550,7 @@ namespace OTSPartA_STDEditor
|
|
|
}
|
|
|
if (m_Attributes.Grid_Attributes[10, 1].Value != null)
|
|
|
{
|
|
|
- STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Element = m_Attributes.Grid_Attributes[10, 1].Value.ToString();
|
|
|
+ STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Element = Convert.ToString(m_Attributes.Grid_Attributes[10, 1].Value);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -607,7 +559,7 @@ namespace OTSPartA_STDEditor
|
|
|
|
|
|
if (m_Attributes.Grid_Attributes[11, 1].Value != null)
|
|
|
{
|
|
|
- STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].GroupId = GroupIdDictionaryFromName[m_Attributes.Grid_Attributes[11, 1].Value.ToString()].ToString();
|
|
|
+ STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].GroupId = GroupIdDictionaryFromName[Convert.ToString(m_Attributes.Grid_Attributes[11, 1].Value)].ToString();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -638,6 +590,8 @@ namespace OTSPartA_STDEditor
|
|
|
|
|
|
STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].KeyElementList = sKeyElements;
|
|
|
STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].SubElementList = sSubElements;
|
|
|
+
|
|
|
+ STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].ListNum = PreRow.ToString();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -648,9 +602,9 @@ namespace OTSPartA_STDEditor
|
|
|
bool SaveDictionaryToClassify(string DBAddress)
|
|
|
{
|
|
|
//保存列表顺序
|
|
|
- for(int i=1;i<m_STDRuleslist.Grid_Minerals.RowsCount;i++)
|
|
|
+ for (int i = 1; i < m_STDRuleslist.Grid_Minerals.RowsCount; i++)
|
|
|
{
|
|
|
- STDDictionary[(int)m_STDRuleslist.Grid_Minerals[i,0].Tag].ListNum = i.ToString();
|
|
|
+ STDDictionary[(int)m_STDRuleslist.Grid_Minerals[i, 0].Tag].ListNum = i.ToString();
|
|
|
}
|
|
|
try
|
|
|
{
|
|
@@ -794,7 +748,7 @@ namespace OTSPartA_STDEditor
|
|
|
newRow["ListNum"] = kv.Value.ListNum;
|
|
|
dt.Rows.Add(newRow);
|
|
|
}
|
|
|
- m_dataAdapter.Update(ds,"ClassifySTD");
|
|
|
+ m_dataAdapter.Update(ds, "ClassifySTD");
|
|
|
m_dbConnection.Close();
|
|
|
}
|
|
|
catch (Exception ex)
|
|
@@ -807,11 +761,11 @@ namespace OTSPartA_STDEditor
|
|
|
|
|
|
bool SaveAsDictionaryToClassify(string DBAddress)
|
|
|
{
|
|
|
- //保存列表顺序
|
|
|
- for (int i = 1; i < m_STDRuleslist.Grid_Minerals.RowsCount; i++)
|
|
|
- {
|
|
|
- STDDictionary[(int)m_STDRuleslist.Grid_Minerals[i, 0].Tag].ListNum = i.ToString();
|
|
|
- }
|
|
|
+ ////保存列表顺序
|
|
|
+ //for (int i = 1; i < m_STDRuleslist.Grid_Minerals.RowsCount; i++)
|
|
|
+ //{
|
|
|
+ // STDDictionary[(int)m_STDRuleslist.Grid_Minerals[i, 0].Tag].ListNum = i.ToString();
|
|
|
+ //}
|
|
|
try
|
|
|
{
|
|
|
System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + DBAddress + "'");
|
|
@@ -1001,7 +955,7 @@ namespace OTSPartA_STDEditor
|
|
|
|
|
|
public void ChangeSTDRulesLISTBackColor()
|
|
|
{
|
|
|
- int stdid=m_STDRuleslist.ChangeSTDRulesLISTBackColor();
|
|
|
+ int stdid = m_STDRuleslist.ChangeSTDRulesLISTBackColor();
|
|
|
}
|
|
|
public void ChangeSTDRuleName(String RuleName)
|
|
|
{
|
|
@@ -1011,14 +965,24 @@ namespace OTSPartA_STDEditor
|
|
|
public void SetNull()
|
|
|
{
|
|
|
m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text = "";
|
|
|
- for (int i = 1; i<m_Attributes.Grid_Attributes.RowsCount-1; i++)
|
|
|
+ for (int i = 1; i < m_Attributes.Grid_Attributes.RowsCount - 1; i++)
|
|
|
{
|
|
|
- m_Attributes.Grid_Attributes[i, 1].Value = "";
|
|
|
+ if (m_Attributes.Grid_Attributes[i, 1].Value != null)
|
|
|
+ {
|
|
|
+ if (m_Attributes.Grid_Attributes[i, 1].View is SourceGrid.Cells.Views.CheckBox)
|
|
|
+ {
|
|
|
+ m_Attributes.Grid_Attributes[i, 1].Value = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ m_Attributes.Grid_Attributes[i, 1].Value = "";
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
|
|
|
view.BackColor = Color.White;
|
|
|
- m_Attributes.Grid_Attributes[2, 1].View= view;
|
|
|
+ m_Attributes.Grid_Attributes[2, 1].View = view;
|
|
|
|
|
|
m_SubMidWindow.m_STDEditor.dataGridView_KeyElements.Rows.Clear();
|
|
|
m_SubMidWindow.m_STDEditor.dataGridView_KeyElements.Columns.Clear();
|
|
@@ -1041,7 +1005,7 @@ namespace OTSPartA_STDEditor
|
|
|
private void ribbon_UserConstants_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
Form_UserConstants form_UserConstants = new Form_UserConstants(STDDBAddress);
|
|
|
- DialogResult dialogResult=form_UserConstants.ShowDialog();
|
|
|
+ DialogResult dialogResult = form_UserConstants.ShowDialog();
|
|
|
if (dialogResult == DialogResult.Yes)
|
|
|
{
|
|
|
try
|
|
@@ -1083,23 +1047,25 @@ namespace OTSPartA_STDEditor
|
|
|
{
|
|
|
GroupIdDictionaryFromId.Clear();
|
|
|
GroupIdDictionaryFromName.Clear();
|
|
|
- if (dt.Select("id='0'").Length==0)
|
|
|
+
|
|
|
+ List<string> ss = new List<string>();
|
|
|
+ if (dt.Select("id='0'").Length == 0)
|
|
|
{
|
|
|
GroupIdDictionaryFromId.Add(0, "Default");
|
|
|
GroupIdDictionaryFromName.Add("Default", 0);
|
|
|
+ ss.Add("Default");
|
|
|
}
|
|
|
-
|
|
|
- List<string> ss = new List<string>();
|
|
|
foreach (DataRow item in dt.Rows)
|
|
|
{
|
|
|
ss.Add(item["name"].ToString());
|
|
|
GroupIdDictionaryFromName.Add(item["name"].ToString(), int.Parse(item["id"].ToString()));
|
|
|
- GroupIdDictionaryFromId.Add(int.Parse(item["id"].ToString()),item["name"].ToString());
|
|
|
+ GroupIdDictionaryFromId.Add(int.Parse(item["id"].ToString()), item["name"].ToString());
|
|
|
}
|
|
|
SourceGrid.Cells.Editors.ComboBox GroupIdCBBox = new SourceGrid.Cells.Editors.ComboBox(typeof(string));
|
|
|
GroupIdCBBox.StandardValues = ss;
|
|
|
- GroupIdCBBox.EditableMode = SourceGrid.EditableMode.SingleClick| SourceGrid.EditableMode.Focus;
|
|
|
+ GroupIdCBBox.EditableMode = SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.Focus;
|
|
|
m_Attributes.Grid_Attributes[11, 1] = new SourceGrid.Cells.Cell("Default", GroupIdCBBox);
|
|
|
+ GroupIdCBBox.Control.DropDownStyle = ComboBoxStyle.DropDownList; //设置下拉框为不可以编辑的状态
|
|
|
}
|
|
|
}
|
|
|
//string ConstantsStr = dt.Rows[0][0].ToString();
|
|
@@ -1115,7 +1081,7 @@ namespace OTSPartA_STDEditor
|
|
|
{
|
|
|
foreach (KeyValuePair<int, STDdata> kv in STDDictionary)
|
|
|
{
|
|
|
- if(!GroupIdDictionaryFromId.Keys.Contains(int.Parse(kv.Value.GroupId)))
|
|
|
+ if (!GroupIdDictionaryFromId.Keys.Contains(int.Parse(kv.Value.GroupId)))
|
|
|
{
|
|
|
kv.Value.GroupId = "0";
|
|
|
}
|
|
@@ -1126,7 +1092,7 @@ namespace OTSPartA_STDEditor
|
|
|
{
|
|
|
//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();
|
|
|
int selGroupId = GroupIdDictionaryFromName[m_Attributes.Grid_Attributes[11, 1].Value.ToString()];
|
|
|
- Form_GroupId form_GroupId = new Form_GroupId(STDDBAddress,this);
|
|
|
+ Form_GroupId form_GroupId = new Form_GroupId(STDDBAddress, this);
|
|
|
DialogResult dialogResult = form_GroupId.ShowDialog();
|
|
|
if (dialogResult == DialogResult.Yes)
|
|
|
{
|
|
@@ -1145,8 +1111,6 @@ namespace OTSPartA_STDEditor
|
|
|
{
|
|
|
if (!Isoldversion)
|
|
|
{
|
|
|
-
|
|
|
-
|
|
|
if (!EqualsBetweenDictionary(STDDictionaryInitial, STDDictionary) || IsModified)
|
|
|
{
|
|
|
DialogResult dr = MessageBox.Show("Whether to save the current modification?", "Tip", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
@@ -1154,7 +1118,7 @@ namespace OTSPartA_STDEditor
|
|
|
{
|
|
|
if (m_STDRuleslist.Grid_Minerals.RowsCount > 1)
|
|
|
{
|
|
|
- if ((m_STDRuleslist.Grid_Minerals[m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0].Value.ToString().Replace(" ", "").Trim() != "") && CheckAttributes() && Checktextbox_STDEditor())
|
|
|
+ if ((m_STDRuleslist.Grid_Minerals[m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0].Value.ToString().Replace(" ", "").Trim() != ""))
|
|
|
{
|
|
|
SaveDataOfSelRule(m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0);
|
|
|
}
|
|
@@ -1206,7 +1170,7 @@ namespace OTSPartA_STDEditor
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- STDDBAddress = openFileDialog.FileName;
|
|
|
+ STDDBAddress = openFileDialog.FileName;
|
|
|
InitForms(STDDBAddress);
|
|
|
this.Text = this.Text.Split(' ')[0] + " " + STDDBAddress;
|
|
|
IsModified = false;
|
|
@@ -1269,7 +1233,7 @@ namespace OTSPartA_STDEditor
|
|
|
{
|
|
|
m_SubMidWindow.m_STDEditor.m_sc.CloseDB();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
m_SubMidWindow.m_STDEditor.m_sc = new SqlLiteClass(DBAddress);
|
|
|
|
|
|
LoadConstants(DBAddress);
|
|
@@ -1292,16 +1256,16 @@ namespace OTSPartA_STDEditor
|
|
|
|
|
|
bool EqualsBetweenDictionary(Dictionary<int, STDdata> STDDictionaryInitial, Dictionary<int, STDdata> STDDictionary)
|
|
|
{
|
|
|
- if(STDDictionaryInitial.Count!= STDDictionary.Count)
|
|
|
+ if (STDDictionaryInitial.Count != STDDictionary.Count)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
- foreach(var key in STDDictionaryInitial.Keys)
|
|
|
+
|
|
|
+ foreach (var key in STDDictionaryInitial.Keys)
|
|
|
{
|
|
|
if (STDDictionary.Keys.Contains(key))
|
|
|
{
|
|
|
- if(!STDDictionaryInitial[key].Equals(STDDictionary[key]))
|
|
|
+ if (!STDDictionaryInitial[key].Equals(STDDictionary[key]))
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
@@ -1317,20 +1281,20 @@ namespace OTSPartA_STDEditor
|
|
|
|
|
|
private void Form_ConstantsEditor2_FormClosing(object sender, FormClosingEventArgs e)
|
|
|
{
|
|
|
- if(Isoldversion)
|
|
|
+ if (Isoldversion)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
if (m_STDRuleslist.Text != "")
|
|
|
{
|
|
|
- if (!EqualsBetweenDictionary(STDDictionaryInitial, STDDictionary)|| IsModified)
|
|
|
+ if (!EqualsBetweenDictionary(STDDictionaryInitial, STDDictionary) || IsModified)
|
|
|
{
|
|
|
DialogResult dr = MessageBox.Show("Whether to save the current modification", "Tip", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
|
if (dr == DialogResult.Yes)
|
|
|
{
|
|
|
if (m_STDRuleslist.Grid_Minerals.RowsCount > 1)
|
|
|
{
|
|
|
- if ((m_STDRuleslist.Grid_Minerals[m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0].Value.ToString().Replace(" ", "").Trim() != "") && CheckAttributes() && Checktextbox_STDEditor())
|
|
|
+ if (m_STDRuleslist.Grid_Minerals[m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0].Value.ToString().Replace(" ", "").Trim() != "")
|
|
|
{
|
|
|
SaveDataOfSelRule(m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0);
|
|
|
}
|
|
@@ -1404,7 +1368,7 @@ namespace OTSPartA_STDEditor
|
|
|
System.Data.Common.DbTransaction trans = m_OtsDatabaseConnection.BeginTransaction();
|
|
|
trans.Commit();
|
|
|
}
|
|
|
- catch(Exception ex)
|
|
|
+ catch (Exception ex)
|
|
|
{
|
|
|
MessageBox.Show(ex.ToString());
|
|
|
return;
|