Browse Source

Merge branch 'GSP' of http://36.129.163.148:30080/gogsadmin/OTS into GSP

gsp 1 year ago
parent
commit
d834b4486d

+ 2 - 1
OTSIncAReportApp/1-UI/Control_Grids/ParticlesGridDevidePage.cs

@@ -211,13 +211,14 @@ namespace OTSIncAReportGrids
                 //string str_libraryName = ((Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)result.ResultInfo["Sample"])["Members"])["MsrParams"])["STDName"].ToString();
                 //string str_libraryName = ((Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)result.ResultInfo["Sample"])["Members"])["MsrParams"])["STDName"].ToString();
                 string str_libraryName = result.GetSTDName();
                 string str_libraryName = result.GetSTDName();
                 userLibrary = new UserLibraryData(str_libraryName);
                 userLibrary = new UserLibraryData(str_libraryName);
-                if (userLibrary != null)
+                if (userLibrary.GetSqlHelper() != null)
                 {
                 {
                     userLibraryData = userLibrary.GetSubAttributeFromDatabase();
                     userLibraryData = userLibrary.GetSubAttributeFromDatabase();
                 }
                 }
                 else
                 else
                 {
                 {
                     userLibraryData = null;
                     userLibraryData = null;
+                    MessageBox.Show("未读取到用户标准库!");
                 }
                 }
                 //初始化底层操作类
                 //初始化底层操作类
                 m_OTSIncAReportGridsFun = new OTSReportGridsFun(m_ReportApp, this);
                 m_OTSIncAReportGridsFun = new OTSReportGridsFun(m_ReportApp, this);

+ 2 - 1
OTSIncAReportApp/1-UI/frmReMeasure.cs

@@ -468,13 +468,14 @@ namespace OTSIncAReportApp
             string str_libraryName = ReportFun.resultFile.GetSTDName();
             string str_libraryName = ReportFun.resultFile.GetSTDName();
             DataTable userLibraryData = new DataTable();
             DataTable userLibraryData = new DataTable();
             UserLibraryData userLibrary = new UserLibraryData(str_libraryName);
             UserLibraryData userLibrary = new UserLibraryData(str_libraryName);
-            if (userLibrary != null)
+            if (userLibrary.GetSqlHelper() != null)
             {
             {
                 userLibraryData = userLibrary.GetSubAttributeFromDatabase();
                 userLibraryData = userLibrary.GetSubAttributeFromDatabase();
             }
             }
             else
             else
             {
             {
                 userLibraryData = null;
                 userLibraryData = null;
+                MessageBox.Show("未读取到用户标准库!");
             }
             }
             if (userLibraryData != null)
             if (userLibraryData != null)
             {
             {

+ 1 - 1
OTSIncAReportApp/3-ServiceCenter/DataOperation/DataAccess/ParticleData.cs

@@ -807,7 +807,7 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
             else
             else
             {
             {
                 dbHelper = null;
                 dbHelper = null;
-                log.Error("Failed to load user-defined library!");
+                log.Error("Failed to load user-defined library_"+ fullPath+"!");
             }
             }
         }
         }
 
 

+ 7 - 2
OTSPartA_STDEditor/Attributes.cs

@@ -75,7 +75,12 @@ namespace OTSPartA_STDEditor
         private void EditorEvent_EditEnded(object sender, EventArgs e)
         private void EditorEvent_EditEnded(object sender, EventArgs e)
         {
         {
             SourceGrid.CellContext context = (SourceGrid.CellContext)sender;
             SourceGrid.CellContext context = (SourceGrid.CellContext)sender;
-            m_MainForm.ChangeSTDRuleName(Grid_Attributes[context.Position.Row, context.Position.Column].Value.ToString());
+            //if(Grid_Attributes[context.Position.Row, context.Position.Column].Value==null)
+            //{
+            //    MessageBox.Show("The name of rule cannot be null!", "warnning");
+            //    return;
+            //}
+            m_MainForm.ChangeSTDRuleName(Convert.ToString( Grid_Attributes[context.Position.Row, context.Position.Column].Value));
         }
         }
 
 
 
 
@@ -149,7 +154,7 @@ namespace OTSPartA_STDEditor
             Grid_Attributes[8, 1] = new SourceGrid.Cells.Cell("", typeof(int));
             Grid_Attributes[8, 1] = new SourceGrid.Cells.Cell("", typeof(int));
             Grid_Attributes[9, 1] = new SourceGrid.Cells.Cell("", typeof(string));
             Grid_Attributes[9, 1] = new SourceGrid.Cells.Cell("", typeof(string));
             Grid_Attributes[10, 1] = new SourceGrid.Cells.Cell("", typeof(string));
             Grid_Attributes[10, 1] = new SourceGrid.Cells.Cell("", typeof(string));
-            //Grid_Attributes[9, 1] = new SourceGrid.Cells.Cell("", typeof(string));
+            Grid_Attributes[11, 1] = new SourceGrid.Cells.Cell("", typeof(string));
 
 
             Grid_Attributes[0, 0].ColumnSpan = 2;
             Grid_Attributes[0, 0].ColumnSpan = 2;
             Grid_Attributes.AutoStretchColumnsToFitWidth = true;
             Grid_Attributes.AutoStretchColumnsToFitWidth = true;

+ 191 - 227
OTSPartA_STDEditor/Form_Main.cs

@@ -20,9 +20,15 @@ namespace OTSPartA_STDEditor
         public STDRuleslist m_STDRuleslist = null;
         public STDRuleslist m_STDRuleslist = null;
         public Attributes m_Attributes = null;
         public Attributes m_Attributes = null;
         public SubMidWindow m_SubMidWindow = null;
         public SubMidWindow m_SubMidWindow = null;
+        /// <summary>
+        /// 实际存储的字典
+        /// </summary>
         public Dictionary<int, STDdata> STDDictionary = new Dictionary<int, STDdata>();
         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>();
         public Dictionary<string, int> GroupIdDictionaryFromName = new Dictionary<string, int>();
         string STDDBAddress_backupDirectory = Application.StartupPath + "\\Config\\SysData\\LibBackup\\";
         string STDDBAddress_backupDirectory = Application.StartupPath + "\\Config\\SysData\\LibBackup\\";
         public string STDDBAddress = "";
         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
             try
             {
             {
@@ -155,9 +161,9 @@ namespace OTSPartA_STDEditor
                             new_STDdata.KeyElementList = item["KeyElementList"].ToString();
                             new_STDdata.KeyElementList = item["KeyElementList"].ToString();
                             new_STDdata.SubElementList = item["SubElementList"].ToString();
                             new_STDdata.SubElementList = item["SubElementList"].ToString();
                             new_STDdata.GroupId = item["GroupId"].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();
                             new_STDdata.GroupId = item["GroupId"].ToString();
-                            if(dt.Columns.Contains("IfElementAnalysis"))
+                            if (dt.Columns.Contains("IfElementAnalysis"))
                             {
                             {
                                 if (Convert.ToBoolean(item["IfElementAnalysis"]))
                                 if (Convert.ToBoolean(item["IfElementAnalysis"]))
                                 {
                                 {
@@ -191,76 +197,51 @@ namespace OTSPartA_STDEditor
         {
         {
             if (m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row >= 0)
             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
                     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)
         public bool ClearDb(string DBAddress, string DBTableName)
@@ -297,69 +278,56 @@ namespace OTSPartA_STDEditor
 
 
         private void rbSave_Click(object sender, EventArgs e)
         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
                 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>
         /// <summary>
@@ -374,10 +342,10 @@ namespace OTSPartA_STDEditor
             return System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.FromArgb(R, G, B));
             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", "");
                 str_RemoveBlank = str_RemoveBlank.Replace("\r\n", "");
                 //分割符号检验
                 //分割符号检验
@@ -406,37 +374,36 @@ namespace OTSPartA_STDEditor
                         return false;
                         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);
                         MessageBox.Show("First character is error!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
                         return false;
                         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分隔符,故先行去掉
                 //forth_elem干扰or分隔符,故先行去掉
                 str_RemoveBlank = str_RemoveBlank.Replace("forth_elem", "");
                 str_RemoveBlank = str_RemoveBlank.Replace("forth_elem", "");
 
 
@@ -507,56 +474,41 @@ namespace OTSPartA_STDEditor
                     return false;
                     return false;
                 }
                 }
                 //检测是否有<>= true,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);
                     MessageBox.Show("Expressions have no effect!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     return false;
                     return false;
                 }
                 }
             }
             }
+            else
+            {
+                MessageBox.Show("The expresstion is mull!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                return false;
+            }
             return true;
             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 化学式和元素暂无限制
             #region 化学式和元素暂无限制
             //if (m_Attributes.Grid_Attributes[7, 1].Value.ToString())
             //if (m_Attributes.Grid_Attributes[7, 1].Value.ToString())
             //{
             //{
@@ -579,18 +531,18 @@ namespace OTSPartA_STDEditor
 
 
         public void SaveDataOfSelRule(int PreRow, int PreColumn)
         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())].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())].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
             else
             {
             {
@@ -598,7 +550,7 @@ namespace OTSPartA_STDEditor
             }
             }
             if (m_Attributes.Grid_Attributes[10, 1].Value != null)
             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
             else
             {
             {
@@ -607,7 +559,7 @@ namespace OTSPartA_STDEditor
 
 
             if (m_Attributes.Grid_Attributes[11, 1].Value != null)
             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
             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())].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())].SubElementList = sSubElements;
+
+            STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].ListNum = PreRow.ToString();
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -648,9 +602,9 @@ namespace OTSPartA_STDEditor
         bool SaveDictionaryToClassify(string DBAddress)
         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
             try
             {
             {
@@ -794,7 +748,7 @@ namespace OTSPartA_STDEditor
                     newRow["ListNum"] = kv.Value.ListNum;
                     newRow["ListNum"] = kv.Value.ListNum;
                     dt.Rows.Add(newRow);
                     dt.Rows.Add(newRow);
                 }
                 }
-                m_dataAdapter.Update(ds,"ClassifySTD");
+                m_dataAdapter.Update(ds, "ClassifySTD");
                 m_dbConnection.Close();
                 m_dbConnection.Close();
             }
             }
             catch (Exception ex)
             catch (Exception ex)
@@ -807,11 +761,11 @@ namespace OTSPartA_STDEditor
 
 
         bool SaveAsDictionaryToClassify(string DBAddress)
         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
             try
             {
             {
                 System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + DBAddress + "'");
                 System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + DBAddress + "'");
@@ -1001,7 +955,7 @@ namespace OTSPartA_STDEditor
 
 
         public void ChangeSTDRulesLISTBackColor()
         public void ChangeSTDRulesLISTBackColor()
         {
         {
-            int stdid=m_STDRuleslist.ChangeSTDRulesLISTBackColor();
+            int stdid = m_STDRuleslist.ChangeSTDRulesLISTBackColor();
         }
         }
         public void ChangeSTDRuleName(String RuleName)
         public void ChangeSTDRuleName(String RuleName)
         {
         {
@@ -1011,14 +965,24 @@ namespace OTSPartA_STDEditor
         public void SetNull()
         public void SetNull()
         {
         {
             m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text = "";
             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();
             SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
             view.BackColor = Color.White;
             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.Rows.Clear();
             m_SubMidWindow.m_STDEditor.dataGridView_KeyElements.Columns.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)
         private void ribbon_UserConstants_Click(object sender, EventArgs e)
         {
         {
             Form_UserConstants form_UserConstants = new Form_UserConstants(STDDBAddress);
             Form_UserConstants form_UserConstants = new Form_UserConstants(STDDBAddress);
-            DialogResult dialogResult=form_UserConstants.ShowDialog();
+            DialogResult dialogResult = form_UserConstants.ShowDialog();
             if (dialogResult == DialogResult.Yes)
             if (dialogResult == DialogResult.Yes)
             {
             {
                 try
                 try
@@ -1083,23 +1047,25 @@ namespace OTSPartA_STDEditor
                     {
                     {
                         GroupIdDictionaryFromId.Clear();
                         GroupIdDictionaryFromId.Clear();
                         GroupIdDictionaryFromName.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");
                             GroupIdDictionaryFromId.Add(0, "Default");
                             GroupIdDictionaryFromName.Add("Default", 0);
                             GroupIdDictionaryFromName.Add("Default", 0);
+                            ss.Add("Default");
                         }
                         }
-
-                        List<string> ss = new List<string>();
                         foreach (DataRow item in dt.Rows)
                         foreach (DataRow item in dt.Rows)
                         {
                         {
                             ss.Add(item["name"].ToString());
                             ss.Add(item["name"].ToString());
                             GroupIdDictionaryFromName.Add(item["name"].ToString(), int.Parse(item["id"].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));
                         SourceGrid.Cells.Editors.ComboBox GroupIdCBBox = new SourceGrid.Cells.Editors.ComboBox(typeof(string));
                         GroupIdCBBox.StandardValues = ss;
                         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);
                         m_Attributes.Grid_Attributes[11, 1] = new SourceGrid.Cells.Cell("Default", GroupIdCBBox);
+                        GroupIdCBBox.Control.DropDownStyle = ComboBoxStyle.DropDownList;        //设置下拉框为不可以编辑的状态
                     }
                     }
                 }
                 }
                 //string ConstantsStr = dt.Rows[0][0].ToString();
                 //string ConstantsStr = dt.Rows[0][0].ToString();
@@ -1115,7 +1081,7 @@ namespace OTSPartA_STDEditor
         {
         {
             foreach (KeyValuePair<int, STDdata> kv in STDDictionary)
             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";
                     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();
             //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()];
             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();
             DialogResult dialogResult = form_GroupId.ShowDialog();
             if (dialogResult == DialogResult.Yes)
             if (dialogResult == DialogResult.Yes)
             {
             {
@@ -1145,8 +1111,6 @@ namespace OTSPartA_STDEditor
         {
         {
             if (!Isoldversion)
             if (!Isoldversion)
             {
             {
-
-
                 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);
                     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.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);
                                 SaveDataOfSelRule(m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0);
                             }
                             }
@@ -1206,7 +1170,7 @@ namespace OTSPartA_STDEditor
             {
             {
                 try
                 try
                 {
                 {
-                    STDDBAddress = openFileDialog.FileName;                                                                                                                                                 
+                    STDDBAddress = openFileDialog.FileName;
                     InitForms(STDDBAddress);
                     InitForms(STDDBAddress);
                     this.Text = this.Text.Split(' ')[0] + "   " + STDDBAddress;
                     this.Text = this.Text.Split(' ')[0] + "   " + STDDBAddress;
                     IsModified = false;
                     IsModified = false;
@@ -1269,7 +1233,7 @@ namespace OTSPartA_STDEditor
             {
             {
                 m_SubMidWindow.m_STDEditor.m_sc.CloseDB();
                 m_SubMidWindow.m_STDEditor.m_sc.CloseDB();
             }
             }
-            
+
             m_SubMidWindow.m_STDEditor.m_sc = new SqlLiteClass(DBAddress);
             m_SubMidWindow.m_STDEditor.m_sc = new SqlLiteClass(DBAddress);
 
 
             LoadConstants(DBAddress);
             LoadConstants(DBAddress);
@@ -1292,16 +1256,16 @@ namespace OTSPartA_STDEditor
 
 
         bool EqualsBetweenDictionary(Dictionary<int, STDdata> STDDictionaryInitial, Dictionary<int, STDdata> STDDictionary)
         bool EqualsBetweenDictionary(Dictionary<int, STDdata> STDDictionaryInitial, Dictionary<int, STDdata> STDDictionary)
         {
         {
-           if(STDDictionaryInitial.Count!= STDDictionary.Count)
+            if (STDDictionaryInitial.Count != STDDictionary.Count)
             {
             {
                 return false;
                 return false;
             }
             }
-           
-           foreach(var key in STDDictionaryInitial.Keys)
+
+            foreach (var key in STDDictionaryInitial.Keys)
             {
             {
                 if (STDDictionary.Keys.Contains(key))
                 if (STDDictionary.Keys.Contains(key))
                 {
                 {
-                    if(!STDDictionaryInitial[key].Equals(STDDictionary[key]))
+                    if (!STDDictionaryInitial[key].Equals(STDDictionary[key]))
                     {
                     {
                         return false;
                         return false;
                     }
                     }
@@ -1317,20 +1281,20 @@ namespace OTSPartA_STDEditor
 
 
         private void Form_ConstantsEditor2_FormClosing(object sender, FormClosingEventArgs e)
         private void Form_ConstantsEditor2_FormClosing(object sender, FormClosingEventArgs e)
         {
         {
-            if(Isoldversion)
+            if (Isoldversion)
             {
             {
                 return;
                 return;
             }
             }
             if (m_STDRuleslist.Text != "")
             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);
                     DialogResult dr = MessageBox.Show("Whether to save the current modification", "Tip", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                     if (dr == DialogResult.Yes)
                     if (dr == DialogResult.Yes)
                     {
                     {
                         if (m_STDRuleslist.Grid_Minerals.RowsCount > 1)
                         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);
                                 SaveDataOfSelRule(m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0);
                             }
                             }
@@ -1404,7 +1368,7 @@ namespace OTSPartA_STDEditor
                     System.Data.Common.DbTransaction trans = m_OtsDatabaseConnection.BeginTransaction();
                     System.Data.Common.DbTransaction trans = m_OtsDatabaseConnection.BeginTransaction();
                     trans.Commit();
                     trans.Commit();
                 }
                 }
-                catch(Exception ex)
+                catch (Exception ex)
                 {
                 {
                     MessageBox.Show(ex.ToString());
                     MessageBox.Show(ex.ToString());
                     return;
                     return;

+ 6 - 15
OTSPartA_STDEditor/ReferenceLibrary.cs

@@ -148,7 +148,7 @@ namespace OTSPartA_STDEditor
                 DataTable dtGroup = dsGroup.Tables[0];
                 DataTable dtGroup = dsGroup.Tables[0];
                 if (dtGroup != null)
                 if (dtGroup != null)
                 {
                 {
-                    if (dtGroup.Rows.Count > 0)
+                    if (dtGroup.Rows.Count >= 0)
                     {
                     {
                         foreach (DataRow item in dtGroup.Rows)
                         foreach (DataRow item in dtGroup.Rows)
                         {
                         {
@@ -291,7 +291,7 @@ namespace OTSPartA_STDEditor
                 if (LoadClassifyToDictionary(fileSel.FileName, ref ReferenceDictionary))
                 if (LoadClassifyToDictionary(fileSel.FileName, ref ReferenceDictionary))
                 {
                 {
                    AddDataToRefereceLiberary(ReferenceDictionary);
                    AddDataToRefereceLiberary(ReferenceDictionary);
-                    this.Text += "  " + fileSel.FileName;
+                    this.Text = "  " + fileSel.FileName;
                    PropGrid.Refresh();
                    PropGrid.Refresh();
                 }
                 }
             }
             }
@@ -358,10 +358,7 @@ namespace OTSPartA_STDEditor
                 //规则名称不为空
                 //规则名称不为空
                 if (m_SubMidWindow.m_MainForm.m_STDRuleslist.Grid_Minerals[i, 0].Value.ToString().Replace(" ", "").Trim() != "")
                 if (m_SubMidWindow.m_MainForm.m_STDRuleslist.Grid_Minerals[i, 0].Value.ToString().Replace(" ", "").Trim() != "")
                 {
                 {
-                    if (m_SubMidWindow.m_MainForm.CheckAttributes())
-                    {
-                        if (m_SubMidWindow.m_MainForm.Checktextbox_STDEditor())
-                        {
+                    
                             m_SubMidWindow.m_MainForm.SaveDataOfSelRule(i, j);
                             m_SubMidWindow.m_MainForm.SaveDataOfSelRule(i, j);
 
 
                             PropGrid.Focus(true);
                             PropGrid.Focus(true);
@@ -396,9 +393,7 @@ namespace OTSPartA_STDEditor
                             m_SubMidWindow.m_MainForm.m_STDRuleslist.Refresh();
                             m_SubMidWindow.m_MainForm.m_STDRuleslist.Refresh();
 
 
                             m_SubMidWindow.m_MainForm.m_STDRuleslist.PreRow = i;
                             m_SubMidWindow.m_MainForm.m_STDRuleslist.PreRow = i;
-                        }
-
-                    }
+                       
 
 
                 }
                 }
 
 
@@ -435,15 +430,11 @@ namespace OTSPartA_STDEditor
                 //规则名称不为空
                 //规则名称不为空
                 if (m_SubMidWindow.m_MainForm.m_STDRuleslist.Grid_Minerals[i, j].Value.ToString().Replace(" ", "").Trim() != "")
                 if (m_SubMidWindow.m_MainForm.m_STDRuleslist.Grid_Minerals[i, j].Value.ToString().Replace(" ", "").Trim() != "")
                 {
                 {
-                    if (m_SubMidWindow.m_MainForm.CheckAttributes())
-                    {
-                        if (m_SubMidWindow.m_MainForm.Checktextbox_STDEditor())
-                        {
+                    
                             m_SubMidWindow.m_MainForm.SaveDataOfSelRule(i, j);
                             m_SubMidWindow.m_MainForm.SaveDataOfSelRule(i, j);
 
 
                             AddIntoMainLab();
                             AddIntoMainLab();
-                        }
-                    }
+                        
                 }
                 }
             }
             }
             else if(i==-1&&j==-1)
             else if(i==-1&&j==-1)

+ 28 - 13
OTSPartA_STDEditor/STDEditor.Designer.cs

@@ -37,6 +37,7 @@
             this.textbox_STDEditor = new System.Windows.Forms.TextBox();
             this.textbox_STDEditor = new System.Windows.Forms.TextBox();
             this.groupBox_Data = new System.Windows.Forms.GroupBox();
             this.groupBox_Data = new System.Windows.Forms.GroupBox();
             this.groupBox_CalculatingSymbols = new System.Windows.Forms.GroupBox();
             this.groupBox_CalculatingSymbols = new System.Windows.Forms.GroupBox();
+            this.button_del = new System.Windows.Forms.Button();
             this.button_0 = new System.Windows.Forms.Button();
             this.button_0 = new System.Windows.Forms.Button();
             this.button_4 = new System.Windows.Forms.Button();
             this.button_4 = new System.Windows.Forms.Button();
             this.button_5 = new System.Windows.Forms.Button();
             this.button_5 = new System.Windows.Forms.Button();
@@ -174,7 +175,6 @@
             this.textbox_STDEditor.Name = "textbox_STDEditor";
             this.textbox_STDEditor.Name = "textbox_STDEditor";
             this.textbox_STDEditor.Size = new System.Drawing.Size(1241, 189);
             this.textbox_STDEditor.Size = new System.Drawing.Size(1241, 189);
             this.textbox_STDEditor.TabIndex = 2;
             this.textbox_STDEditor.TabIndex = 2;
-            this.textbox_STDEditor.MouseLeave += new System.EventHandler(this.textbox_STDEditor_MouseLeave);
             // 
             // 
             // groupBox_Data
             // groupBox_Data
             // 
             // 
@@ -189,6 +189,7 @@
             // 
             // 
             // groupBox_CalculatingSymbols
             // groupBox_CalculatingSymbols
             // 
             // 
+            this.groupBox_CalculatingSymbols.Controls.Add(this.button_del);
             this.groupBox_CalculatingSymbols.Controls.Add(this.button_0);
             this.groupBox_CalculatingSymbols.Controls.Add(this.button_0);
             this.groupBox_CalculatingSymbols.Controls.Add(this.button_4);
             this.groupBox_CalculatingSymbols.Controls.Add(this.button_4);
             this.groupBox_CalculatingSymbols.Controls.Add(this.button_5);
             this.groupBox_CalculatingSymbols.Controls.Add(this.button_5);
@@ -218,6 +219,19 @@
             this.groupBox_CalculatingSymbols.TabStop = false;
             this.groupBox_CalculatingSymbols.TabStop = false;
             this.groupBox_CalculatingSymbols.Text = "运算符号";
             this.groupBox_CalculatingSymbols.Text = "运算符号";
             // 
             // 
+            // button_del
+            // 
+            this.button_del.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
+            this.button_del.Font = new System.Drawing.Font("楷体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.button_del.ForeColor = System.Drawing.SystemColors.ControlText;
+            this.button_del.Location = new System.Drawing.Point(468, 72);
+            this.button_del.Name = "button_del";
+            this.button_del.Size = new System.Drawing.Size(64, 35);
+            this.button_del.TabIndex = 27;
+            this.button_del.Text = "del";
+            this.button_del.UseVisualStyleBackColor = true;
+            this.button_del.Click += new System.EventHandler(this.button_del_Click);
+            // 
             // button_0
             // button_0
             // 
             // 
             this.button_0.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
             this.button_0.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
@@ -270,9 +284,9 @@
             // 
             // 
             this.button_Divide.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
             this.button_Divide.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
             this.button_Divide.Font = new System.Drawing.Font("方正舒体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.button_Divide.Font = new System.Drawing.Font("方正舒体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.button_Divide.Location = new System.Drawing.Point(396, 20);
+            this.button_Divide.Location = new System.Drawing.Point(397, 21);
             this.button_Divide.Name = "button_Divide";
             this.button_Divide.Name = "button_Divide";
-            this.button_Divide.Size = new System.Drawing.Size(42, 35);
+            this.button_Divide.Size = new System.Drawing.Size(31, 35);
             this.button_Divide.TabIndex = 8;
             this.button_Divide.TabIndex = 8;
             this.button_Divide.Text = "/";
             this.button_Divide.Text = "/";
             this.button_Divide.UseVisualStyleBackColor = true;
             this.button_Divide.UseVisualStyleBackColor = true;
@@ -307,9 +321,9 @@
             this.button_Or.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
             this.button_Or.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
             this.button_Or.Font = new System.Drawing.Font("楷体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.button_Or.Font = new System.Drawing.Font("楷体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.button_Or.ForeColor = System.Drawing.SystemColors.ControlText;
             this.button_Or.ForeColor = System.Drawing.SystemColors.ControlText;
-            this.button_Or.Location = new System.Drawing.Point(492, 20);
+            this.button_Or.Location = new System.Drawing.Point(434, 22);
             this.button_Or.Name = "button_Or";
             this.button_Or.Name = "button_Or";
-            this.button_Or.Size = new System.Drawing.Size(47, 35);
+            this.button_Or.Size = new System.Drawing.Size(46, 35);
             this.button_Or.TabIndex = 15;
             this.button_Or.TabIndex = 15;
             this.button_Or.Text = "or";
             this.button_Or.Text = "or";
             this.button_Or.UseVisualStyleBackColor = true;
             this.button_Or.UseVisualStyleBackColor = true;
@@ -332,9 +346,9 @@
             this.button_And.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
             this.button_And.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
             this.button_And.Font = new System.Drawing.Font("楷体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.button_And.Font = new System.Drawing.Font("楷体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.button_And.ForeColor = System.Drawing.SystemColors.ControlText;
             this.button_And.ForeColor = System.Drawing.SystemColors.ControlText;
-            this.button_And.Location = new System.Drawing.Point(444, 72);
+            this.button_And.Location = new System.Drawing.Point(486, 22);
             this.button_And.Name = "button_And";
             this.button_And.Name = "button_And";
-            this.button_And.Size = new System.Drawing.Size(95, 35);
+            this.button_And.Size = new System.Drawing.Size(46, 35);
             this.button_And.TabIndex = 14;
             this.button_And.TabIndex = 14;
             this.button_And.Text = "and";
             this.button_And.Text = "and";
             this.button_And.UseVisualStyleBackColor = true;
             this.button_And.UseVisualStyleBackColor = true;
@@ -368,9 +382,9 @@
             // 
             // 
             this.button_Equal.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
             this.button_Equal.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
             this.button_Equal.Font = new System.Drawing.Font("方正舒体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.button_Equal.Font = new System.Drawing.Font("方正舒体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.button_Equal.Location = new System.Drawing.Point(444, 20);
+            this.button_Equal.Location = new System.Drawing.Point(424, 71);
             this.button_Equal.Name = "button_Equal";
             this.button_Equal.Name = "button_Equal";
-            this.button_Equal.Size = new System.Drawing.Size(42, 35);
+            this.button_Equal.Size = new System.Drawing.Size(39, 35);
             this.button_Equal.TabIndex = 16;
             this.button_Equal.TabIndex = 16;
             this.button_Equal.Text = "=";
             this.button_Equal.Text = "=";
             this.button_Equal.UseVisualStyleBackColor = true;
             this.button_Equal.UseVisualStyleBackColor = true;
@@ -380,7 +394,7 @@
             // 
             // 
             this.button_Multiply.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
             this.button_Multiply.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
             this.button_Multiply.Font = new System.Drawing.Font("方正舒体", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.button_Multiply.Font = new System.Drawing.Font("方正舒体", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.button_Multiply.Location = new System.Drawing.Point(348, 20);
+            this.button_Multiply.Location = new System.Drawing.Point(348, 21);
             this.button_Multiply.Name = "button_Multiply";
             this.button_Multiply.Name = "button_Multiply";
             this.button_Multiply.Size = new System.Drawing.Size(42, 35);
             this.button_Multiply.Size = new System.Drawing.Size(42, 35);
             this.button_Multiply.TabIndex = 9;
             this.button_Multiply.TabIndex = 9;
@@ -428,9 +442,9 @@
             // 
             // 
             this.button_RightParenthesis.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
             this.button_RightParenthesis.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
             this.button_RightParenthesis.Font = new System.Drawing.Font("方正舒体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.button_RightParenthesis.Font = new System.Drawing.Font("方正舒体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.button_RightParenthesis.Location = new System.Drawing.Point(396, 72);
+            this.button_RightParenthesis.Location = new System.Drawing.Point(386, 72);
             this.button_RightParenthesis.Name = "button_RightParenthesis";
             this.button_RightParenthesis.Name = "button_RightParenthesis";
-            this.button_RightParenthesis.Size = new System.Drawing.Size(42, 35);
+            this.button_RightParenthesis.Size = new System.Drawing.Size(32, 35);
             this.button_RightParenthesis.TabIndex = 13;
             this.button_RightParenthesis.TabIndex = 13;
             this.button_RightParenthesis.Text = ")";
             this.button_RightParenthesis.Text = ")";
             this.button_RightParenthesis.UseVisualStyleBackColor = true;
             this.button_RightParenthesis.UseVisualStyleBackColor = true;
@@ -442,7 +456,7 @@
             this.button_LeftParenthesis.Font = new System.Drawing.Font("方正舒体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.button_LeftParenthesis.Font = new System.Drawing.Font("方正舒体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.button_LeftParenthesis.Location = new System.Drawing.Point(348, 72);
             this.button_LeftParenthesis.Location = new System.Drawing.Point(348, 72);
             this.button_LeftParenthesis.Name = "button_LeftParenthesis";
             this.button_LeftParenthesis.Name = "button_LeftParenthesis";
-            this.button_LeftParenthesis.Size = new System.Drawing.Size(42, 35);
+            this.button_LeftParenthesis.Size = new System.Drawing.Size(32, 35);
             this.button_LeftParenthesis.TabIndex = 12;
             this.button_LeftParenthesis.TabIndex = 12;
             this.button_LeftParenthesis.Text = "(";
             this.button_LeftParenthesis.Text = "(";
             this.button_LeftParenthesis.UseVisualStyleBackColor = true;
             this.button_LeftParenthesis.UseVisualStyleBackColor = true;
@@ -670,5 +684,6 @@
         public System.Windows.Forms.DataGridView dataGridView_KeyElements;
         public System.Windows.Forms.DataGridView dataGridView_KeyElements;
         public System.Windows.Forms.DataGridView dataGridView_SubElements;
         public System.Windows.Forms.DataGridView dataGridView_SubElements;
         private System.Windows.Forms.Button button_PeriodicTableSwitch;
         private System.Windows.Forms.Button button_PeriodicTableSwitch;
+        private System.Windows.Forms.Button button_del;
     }
     }
 }
 }

+ 26 - 98
OTSPartA_STDEditor/STDEditor.cs

@@ -23,9 +23,9 @@ namespace OTSPartA_STDEditor
 
 
         public enum Result
         public enum Result
         {
         {
-            NoMatched=0,
-            Success=1,
-            Fail=2
+            NoMatched = 0,
+            Success = 1,
+            Fail = 2
         }
         }
 
 
         public STDEditor(SubMidWindow SubMidWindow)
         public STDEditor(SubMidWindow SubMidWindow)
@@ -38,7 +38,7 @@ namespace OTSPartA_STDEditor
             Y = this.Height;
             Y = this.Height;
             setTag(this);
             setTag(this);
         }
         }
-        public STDEditor(SubMidWindow SubMidWindow,string STDDBaddress)
+        public STDEditor(SubMidWindow SubMidWindow, string STDDBaddress)
         {
         {
             InitializeComponent();
             InitializeComponent();
             m_sc = new SqlLiteClass(STDDBaddress);
             m_sc = new SqlLiteClass(STDDBaddress);
@@ -571,12 +571,12 @@ namespace OTSPartA_STDEditor
         }
         }
 
 
 
 
-        private float X=1;
-        private float Y=1;
+        private float X = 1;
+        private float Y = 1;
         private void STDEditor_Resize(object sender, EventArgs e)
         private void STDEditor_Resize(object sender, EventArgs e)
         {
         {
             float newx = (this.Width) / X;
             float newx = (this.Width) / X;
-            float newy = this.Height/ Y;
+            float newy = this.Height / Y;
             AmplificationFactor = newy;
             AmplificationFactor = newy;
             setControls(newx, newy, this.tabSTDStandrad.TabPages[0]);
             setControls(newx, newy, this.tabSTDStandrad.TabPages[0]);
             //button_Extend.BackColor = SystemColors.ControlDarkDark;
             //button_Extend.BackColor = SystemColors.ControlDarkDark;
@@ -598,7 +598,7 @@ namespace OTSPartA_STDEditor
             {
             {
                 if (false)
                 if (false)
                 {
                 {
-                    
+
                 }
                 }
                 else
                 else
                 {
                 {
@@ -616,7 +616,7 @@ namespace OTSPartA_STDEditor
                     a = Convert.ToSingle(mytag[3]) * newy;
                     a = Convert.ToSingle(mytag[3]) * newy;
                     con.Top = (int)(a);
                     con.Top = (int)(a);
 
 
-                    Single currentSize ;
+                    Single currentSize;
 
 
                     if (con.Name == "button_Extend")
                     if (con.Name == "button_Extend")
                     {
                     {
@@ -684,96 +684,7 @@ namespace OTSPartA_STDEditor
 
 
         private void textbox_STDEditor_MouseLeave(object sender, EventArgs e)
         private void textbox_STDEditor_MouseLeave(object sender, EventArgs e)
         {
         {
-            dataGridView_KeyElements.Rows.Clear();
-            dataGridView_KeyElements.Columns.Clear();
-
-
-            string str_RemoveBlank = textbox_STDEditor.Text.ToString().Replace(" ", "");
-            str_RemoveBlank = str_RemoveBlank.Replace("\r\n", "");
-            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[] { '+', '-', '*', '/', '=', '>', '<', '(', ')' }));
-            }
-            List<string> UsingElementL = new List<string>();
-            for (int i = 0; i < list_all.Count; i++)
-            {
-                if (this.comboBox_PeriodicTable.Items.Contains(list_all[i]))
-                {
-                    if (!UsingElementL.Contains(list_all[i]))
-                    {
-                        UsingElementL.Add(list_all[i]);
-                    }
-                }
-            }
 
 
-            List<string> SubElements = new List<string>();
-            for (int i = 0; i < dataGridView_SubElements.ColumnCount; i++)
-            {
-                if (UsingElementL.Contains(dataGridView_SubElements.Rows[0].Cells[i].Value))
-                {
-                    SubElements.Add(dataGridView_SubElements.Rows[0].Cells[i].Value.ToString());
-                }
-            }
-
-            dataGridView_SubElements.Rows.Clear();
-            dataGridView_SubElements.Columns.Clear();
-
-            for (int i = 0; i < SubElements.Count; i++)
-            {
-                DataGridViewButtonColumn dataGridViewButtonColumn = new DataGridViewButtonColumn();
-                dataGridViewButtonColumn.Name = dataGridView_SubElements.Columns.Count.ToString();
-                dataGridView_SubElements.Columns.Add(dataGridViewButtonColumn);
-                if (dataGridView_SubElements.Rows.Count == 0)
-                {
-                    DataGridViewRow row = new DataGridViewRow();
-                    dataGridView_SubElements.Rows.Add(row);
-                }
-                dataGridView_SubElements.Rows[0].Cells[dataGridView_SubElements.ColumnCount - 1].Value = SubElements[i];
-            }
-
-            if (SubElements.Count > 0)
-            {
-                for (int i = 0; i < UsingElementL.Count; i++)
-                {
-                    if (!SubElements.Contains(UsingElementL[i]))
-                    {
-                        DataGridViewButtonColumn dataGridViewButtonColumn = new DataGridViewButtonColumn();
-                        dataGridViewButtonColumn.Name = dataGridView_KeyElements.Columns.Count.ToString();
-                        dataGridView_KeyElements.Columns.Add(dataGridViewButtonColumn);
-                        if (dataGridView_KeyElements.Rows.Count == 0)
-                        {
-                            DataGridViewRow row = new DataGridViewRow();
-                            dataGridView_KeyElements.Rows.Add(row);
-                        }
-                        dataGridView_KeyElements.Rows[0].Cells[dataGridView_KeyElements.ColumnCount - 1].Value = UsingElementL[i];
-                    }
-                }
-            }
-            else
-            {
-                for (int i = 0; i < UsingElementL.Count; i++)
-                {
-                    DataGridViewButtonColumn dataGridViewButtonColumn = new DataGridViewButtonColumn();
-                    dataGridViewButtonColumn.Name = dataGridView_KeyElements.Columns.Count.ToString();
-                    dataGridView_KeyElements.Columns.Add(dataGridViewButtonColumn);
-                    if (dataGridView_KeyElements.Rows.Count == 0)
-                    {
-                        DataGridViewRow row = new DataGridViewRow();
-                        dataGridView_KeyElements.Rows.Add(row);
-                    }
-                    dataGridView_KeyElements.Rows[0].Cells[i].Value = UsingElementL[i];
-                }
-            }
-            dataGridView_KeyElements.ClearSelection();
-            dataGridView_SubElements.ClearSelection();
         }
         }
 
 
         public void ShowTabXray()
         public void ShowTabXray()
@@ -784,5 +695,22 @@ namespace OTSPartA_STDEditor
         {
         {
             tabSTDStandrad.SelectedIndex = 0;
             tabSTDStandrad.SelectedIndex = 0;
         }
         }
+
+        private void button_del_Click(object sender, EventArgs e)
+        {
+            if (!string.IsNullOrEmpty(textbox_STDEditor.Text))
+            {
+                if (textbox_STDEditor.SelectionLength == 0)
+                {
+                    textbox_STDEditor.Text = textbox_STDEditor.Text.Remove(textbox_STDEditor.SelectionStart - 1, 1);
+                }
+                else
+                {
+                    textbox_STDEditor.Text = textbox_STDEditor.Text.Remove(textbox_STDEditor.SelectionStart, textbox_STDEditor.SelectionLength);
+                }
+            }
+            textbox_STDEditor.Focus();
+            textbox_STDEditor.SelectionStart = textbox_STDEditor.Text.Length;
+        }
     }
     }
 }
 }

+ 33 - 47
OTSPartA_STDEditor/STDRuleslist.cs

@@ -126,31 +126,31 @@ namespace OTSPartA_STDEditor
             /// 保证鼠标点击的GRID行和列是有效的
             /// 保证鼠标点击的GRID行和列是有效的
             if (i >= 0 && j >= 0)
             if (i >= 0 && j >= 0)
             {
             {
-                //规则名称不为空
-                if (Grid_Minerals[i, 0].Value.ToString().Replace(" ", "").Trim() != "")
-                {
-                    if (m_MainForm.CheckAttributes() && m_MainForm.Checktextbox_STDEditor())
-                    {
+                ////规则名称不为空
+                //if (Grid_Minerals[i, 0].Value.ToString().Replace(" ", "").Trim() != "")
+                //{
+                //    if (m_MainForm.CheckAttributes() && m_MainForm.Checktextbox_STDEditor())
+                //    {
 
 
                         m_MainForm.SaveDataOfSelRule(PreRow, 0);
                         m_MainForm.SaveDataOfSelRule(PreRow, 0);
                         m_MainForm.ChangeSTDEditorAndGrid_Attributes(int.Parse(Grid_Minerals[i, 0].Tag.ToString()));
                         m_MainForm.ChangeSTDEditorAndGrid_Attributes(int.Parse(Grid_Minerals[i, 0].Tag.ToString()));
                         m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
                         m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
                         PreRow = i;
                         PreRow = i;
 
 
-                    }
-                    else
-                    {
-                        Position pos = new Position(PreRow, 0);
-                        Grid_Minerals.Selection.Focus(pos, true);
-                        m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
-                    }
-                }
-                else
-                {
-                    Position pos = new Position(PreRow, 0);
-                    Grid_Minerals.Selection.Focus(pos, true);
-                    m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
-                }
+                //    }
+                //    else
+                //    {
+                //        Position pos = new Position(PreRow, 0);
+                //        Grid_Minerals.Selection.Focus(pos, true);
+                //        m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
+                //    }
+                //}
+                //else
+                //{
+                //    Position pos = new Position(PreRow, 0);
+                //    Grid_Minerals.Selection.Focus(pos, true);
+                //    m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
+                //}
             }
             }
 
 
             SetOrderButtonsStatus();
             SetOrderButtonsStatus();
@@ -168,21 +168,21 @@ namespace OTSPartA_STDEditor
             /// 保证鼠标点击的GRID行和列是有效的
             /// 保证鼠标点击的GRID行和列是有效的
             if (i >= 0 && j >= 0)
             if (i >= 0 && j >= 0)
             {
             {
-                //规则名称不为空
-                if (Grid_Minerals[i, j].Value.ToString().Replace(" ", "").Trim() != "")
-                {
-                    if (m_MainForm.CheckAttributes())
-                    {
-                        if (m_MainForm.Checktextbox_STDEditor())
-                        {
+                ////规则名称不为空
+                //if (Grid_Minerals[i, j].Value.ToString().Replace(" ", "").Trim() != "")
+                //{
+                //    if (m_MainForm.CheckAttributes())
+                //    {
+                //        if (m_MainForm.Checktextbox_STDEditor())
+                //        {
                             m_MainForm.SaveDataOfSelRule(i, j);
                             m_MainForm.SaveDataOfSelRule(i, j);
 
 
                             int STDId = m_MainForm.AddSTDDictionaryItem();
                             int STDId = m_MainForm.AddSTDDictionaryItem();
                             AddNewRow(STDId, "NewRuleName", Color.Gray);
                             AddNewRow(STDId, "NewRuleName", Color.Gray);
                             m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
                             m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
-                        }
-                    }
-                }
+                //        }
+                //    }
+                //}
             }
             }
             else
             else
             {
             {
@@ -306,8 +306,7 @@ namespace OTSPartA_STDEditor
                     //规则名称不为空
                     //规则名称不为空
                     if (Grid_Minerals[i, 0].Value.ToString().Replace(" ", "").Trim() != "")
                     if (Grid_Minerals[i, 0].Value.ToString().Replace(" ", "").Trim() != "")
                     {
                     {
-                        if (m_MainForm.CheckAttributes() && m_MainForm.Checktextbox_STDEditor())
-                        {
+                        
 
 
                             m_MainForm.SaveDataOfSelRule(i, 0);
                             m_MainForm.SaveDataOfSelRule(i, 0);
                             m_MainForm.ChangeSTDEditorAndGrid_Attributes(int.Parse(Grid_Minerals[i - 1, 0].Tag.ToString()));
                             m_MainForm.ChangeSTDEditorAndGrid_Attributes(int.Parse(Grid_Minerals[i - 1, 0].Tag.ToString()));
@@ -321,13 +320,7 @@ namespace OTSPartA_STDEditor
                             {
                             {
                                 button_DownOrder.Enabled = true;
                                 button_DownOrder.Enabled = true;
                             }
                             }
-                        }
-                        else
-                        {
-                            Position pos = new Position(i + 1, 0);
-                            Grid_Minerals.Selection.Focus(pos, true);
-                            m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
-                        }
+                        
                     }
                     }
                     else
                     else
                     {
                     {
@@ -345,8 +338,7 @@ namespace OTSPartA_STDEditor
                     //规则名称不为空
                     //规则名称不为空
                     if (Grid_Minerals[i, 0].Value.ToString().Replace(" ", "").Trim() != "")
                     if (Grid_Minerals[i, 0].Value.ToString().Replace(" ", "").Trim() != "")
                     {
                     {
-                        if (m_MainForm.CheckAttributes()&& m_MainForm.Checktextbox_STDEditor())
-                        {
+                        
                            
                            
                                 m_MainForm.SaveDataOfSelRule(i, 0);
                                 m_MainForm.SaveDataOfSelRule(i, 0);
                                 m_MainForm.ChangeSTDEditorAndGrid_Attributes(int.Parse(Grid_Minerals[i + 1, 0].Tag.ToString()));
                                 m_MainForm.ChangeSTDEditorAndGrid_Attributes(int.Parse(Grid_Minerals[i + 1, 0].Tag.ToString()));
@@ -361,13 +353,7 @@ namespace OTSPartA_STDEditor
                             {
                             {
                                 button_DownOrder.Enabled = false;
                                 button_DownOrder.Enabled = false;
                             }
                             }
-                        }
-                        else
-                        {
-                            Position pos = new Position(i - 1, 0);
-                            Grid_Minerals.Selection.Focus(pos, true);
-                            m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
-                        }
+                        
                     }
                     }
                     else
                     else
                     {
                     {