using OTS.WinFormsUI.Docking; using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Windows.Forms; using System.Collections; using System.Text.RegularExpressions; using System.Text; using System.IO; using System.Data; using OTSCLRINTERFACE; namespace SpectrumSTDEditor { public partial class STDEditor : DockContent { #region 全局变量 public SubMidWindow m_SubMidWindow = null; public int STDId = -1; Hashtable table_STDEditor; //数据库操作对象 public SqlLiteClass m_sc = null; // 电镜设置对象 COTSControlFunExport m_cfun = null; //Xray图谱用户控件 UXrayControl XrayControl = null; //全局Xray 用于存储当前选择行的Xray信息 byte[] xrayByteData = null; // 连接状态 bool m_bConnectionState = false; //标准Xray信息列表 public List m_STDXrayList = null; #endregion public enum Result { NoMatched = 0, Success = 1, Fail = 2 } public STDEditor(SubMidWindow SubMidWindow) { InitializeComponent(); m_sc = new SqlLiteClass(); m_SubMidWindow = SubMidWindow; X = this.Width; Y = this.Height; XrayControl=new UXrayControl(); setTag(this); } public STDEditor(SubMidWindow SubMidWindow, string STDDBaddress) { InitializeComponent(); m_sc = new SqlLiteClass(STDDBaddress); m_SubMidWindow = SubMidWindow; X = this.Width; Y = this.Height; setTag(this); } private void STDEditor_Load(object sender, EventArgs e) { m_SubMidWindow.m_MainForm.lan = new Language(this); //添加Xray用户控件 XrayControl = new UXrayControl(); plXray.Controls.Add(XrayControl); XrayControl.Dock = DockStyle.Fill; //绑定数据库中的STDXray m_STDXrayList = new List(); BindSTDXray(); } float AmplificationFactor = 1; //private void button_Extend_Click(object sender, EventArgs e) //{ // if (button_Extend.BackColor == SystemColors.ControlDarkDark) // { // //groupBox_Data.Visible = true; // textbox_STDEditor.Height = (int)Math.Round(150 * AmplificationFactor); // button_Extend.BackColor = SystemColors.ControlDark; // } // else // { // button_Extend.BackColor = SystemColors.ControlDarkDark; // textbox_STDEditor.Height = (int)Math.Round(300* AmplificationFactor); // } //} #region 采集Xray 按钮事件 private void btnCollectXray_Click(object sender, EventArgs e) { m_SubMidWindow.m_MainForm.IsModified = true; string strTime = txtCollectTime.Text.Trim(); if (txtCollectTime.Equals("")) { showMessage("Please fill in the collection time name!"); txtCollectTime.Focus(); return; } if (!IsMatch(strTime, 1)) { showMessage("Error collecting time content, the format should be integer!"); txtCollectTime.Focus(); return; } if (Convert.ToInt32(strTime) < 50) { showMessage("CollectTime must not be less than 100 milliseconds!"); txtCollectTime.Focus(); return; } //显示Xray xrayByteData = IntArrToByteArr(GetCollectXray(strTime)); int color = Convert.ToInt32(m_SubMidWindow.m_MainForm.STDDictionary[STDId].Color); //根据树节点修改对应的Xray信息 UpdateSTDXray(STDId, xrayByteData); ShowXrayAtlas(color, xrayByteData); } /// /// 获取采集当前的Xray信息 /// /// protected uint[] GetCollectXray(string strTime) { try { if (null == m_cfun) { //m_cfun = COTSControlFunExport.GetControllerInstance(); } if (ConnectionSem(connectionEnumType.EDSOnlyPointXRay)) { if (EDSInit()) { int iSize = 2000; uint[] iXrayData = new uint[iSize]; //采集XRay数据 if (m_cfun.CollectSpectrum(uint.Parse(strTime), ref iXrayData)) { return iXrayData; } } } return null; } catch /*(Exception ex)*/ { return null; } finally { //EDS过程结束 //m_cfun.EDSFinishedInstance(); //关闭连接 DisConnectSem(connectionEnumType.EDSOnlyPointXRay); } } private void btnReadXray_Click(object sender, EventArgs e) { OpenFileDialog fileSel = new OpenFileDialog(); fileSel.Filter = "|*.txt"; if (DialogResult.OK == fileSel.ShowDialog()) { String str = ""; //读取Xray文件 using (StreamReader sr = new StreamReader(fileSel.FileName)) { while (!sr.EndOfStream) { str += sr.ReadLine() + ","; } str = str.Substring(0, str.Length - 1); string[] xrayData = str.Split(','); if (xrayData.Length != 2000) { return; } uint[] data = new uint[xrayData.Length]; for (int i = 0; i < xrayData.Length; i++) { data[i] = Convert.ToUInt32(xrayData[i]); } //Xray数据 xrayByteData = IntArrToByteArr(data); int color = Convert.ToInt32(m_SubMidWindow.m_MainForm.STDDictionary[STDId].Color); //根据树节点修改对应的Xray信息 UpdateSTDXray(STDId, xrayByteData); ShowXrayAtlas(color, xrayByteData); } } } /// /// 将int[] 转换为 byte[] /// /// /// public static byte[] IntArrToByteArr(uint[] intArr) { int intSize = sizeof(uint) * intArr.Length; byte[] bytArr = new byte[intSize]; //申请一块非托管内存   //IntPtr ptr = Marshal.AllocHGlobal(intSize); ////复制int数组到该内存块   //Marshal.Copy(intArr, 0, ptr, intArr.Length); ////复制回byte数组   //Marshal.Copy(ptr, bytArr, 0, bytArr.Length); ////释放申请的非托管内存   //Marshal.FreeHGlobal(ptr); for (int i = 0; i < intArr.Length; i++) { byte[] c1 = BitConverter.GetBytes(intArr[i]); c1.CopyTo(bytArr, i * 4); } return bytArr; } /// 将颜色对象转换为uint /// /// /// public uint ParseRGB(Color color) { return (uint)(((uint)color.B << 16) | (ushort)(((ushort)color.G << 8) | color.R)); } #region 显示Xray图谱 /// /// 显示Xray图谱 /// public void ShowXrayAtlas(int colorValue = 0, byte[] XrayData = null) { DataTable dt = new DataTable(); dt.Columns.Add("Color", typeof(int)); dt.Columns.Add("SPEC", typeof(byte[])); DataRow dRow = dt.NewRow(); dRow["Color"] = colorValue; if (XrayData != null) { dRow["SPEC"] = XrayData; } else { dRow["SPEC"] = new byte[8000]; } //将选择行的数据传递给Xray控件 XrayControl.Dr = dRow; XrayControl.Refresh(); XrayData = null; } #endregion #region 常用数据验证的封装,数字字符的验证 /// /// 常用数据验证的封装,数字字符的验证 /// /// 需要验证的数值【字符串,或者数字】 /// 类型为哪一个验证 /// 如果验证成功则返回True,否则返回false public bool IsMatch(string inputVal, int type) { switch (type) { case 0: return Regex.IsMatch(inputVal, @"^[1-9]d*$"); //匹配正整数 case 1: return Regex.IsMatch(inputVal, @"^-?\d+$"); //匹配整数 case 2: return Regex.IsMatch(inputVal, @"^[A-Za-z0-9]+$"); //匹配由数字和26个英文字母组成的字符串 case 3: return Regex.IsMatch(inputVal, @"^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$"); //匹配正浮点数 case 4: return Regex.IsMatch(inputVal, @"^[\u4e00-\u9fa5]{0,}$"); //匹配汉字 case 5: return Regex.IsMatch(inputVal, @"^[0-9]+(.[0-9]{1,3})?$"); //匹配1~3位小数的正实数 case 6: return Regex.IsMatch(inputVal, @"^[A-Za-z]+$"); //匹配英文字符 default: return true; } } #endregion #region 弹出提示 /// /// 弹出提示 /// /// protected void showMessage(string strContent) { MessageBox.Show(strContent, "Tip"); } #endregion #region 连接与关闭设备 public bool ConnectionSem(connectionEnumType connectionType) { //获取连接电镜类型 string connTypeStr = GetConnectionType(connectionType); //连接电镜标识 bool bDisConnResult = false; //判断连接状态 if (!m_bConnectionState) { //连接电镜设置 bDisConnResult = m_cfun.ConncetSem(); } if (bDisConnResult) { m_bConnectionState = true; } else { m_bConnectionState = false; } return bDisConnResult; } public bool DisConnectSem(connectionEnumType disConnectType) { //获取关闭电镜类型 string connTypeStr = GetConnectionType(disConnectType); bool bDisConnResult = false; if (m_bConnectionState) { bDisConnResult = m_cfun.DisconnectSem(); } if (bDisConnResult) { m_bConnectionState = false; } else { m_bConnectionState = true; } return bDisConnResult; } private string GetConnectionType(connectionEnumType connectionType) { string connString = string.Empty; switch (connectionType) { //设置单点采集文字内容 case connectionEnumType.EDSOnlyPointXRay: connString = "OnlyPointXRay"; break; //设置多点采集文字内容 case connectionEnumType.EDSMultiPointXRay: connString = "MultiPointXRay"; break; //设置面采集文字内容 case connectionEnumType.EDSAreaXRay: connString = "AreaXRay"; break; //设置图片 case connectionEnumType.ScanImage: connString = "Image"; break; default: break; } return connString; } /// /// EDS初始化 /// public bool EDSInit() { bool bResult = false; //线程调用 加载 bResult = m_cfun.EDSInit(); return bResult; } public enum connectionEnumType { EDSOnlyPointXRay = 0, EDSMultiPointXRay = 1, EDSAreaXRay = 2, ScanImage = 3 } /// /// 标准Xray状态 /// public enum STDXrayInfoState { Add = 0, Modify = 1, Delete = 2 } #endregion /// /// 记录修改后的标准中的Xray信息 /// public class STDXray { /// /// 标准编号 /// private string stdID; /// /// Xray数据 /// private byte[] xrayData; /// /// 状态 /// private int infoState = -1; public string StdID { get => stdID; set => stdID = value; } public byte[] XrayData { get => xrayData; set => xrayData = value; } public int InfoState { get => infoState; set => infoState = value; } } #endregion #region Xray 与 STDDB数据操作 /// /// 绑定数据库中已存在的Xray信息 /// public void BindSTDXray() { //清空STDXray列表中的集合 m_STDXrayList.Clear(); //查询 DataTable dt = m_sc.GetDTFormSysSTDBySQLString("select Id,SPEC from STDMinerals"); if (dt != null) { if (dt.Rows.Count > 0) { foreach (DataRow item in dt.Rows) { STDXray sXray = new STDXray(); sXray.StdID = item["Id"].ToString(); sXray.XrayData = (byte[])item["SPEC"]; sXray.InfoState = 1; m_STDXrayList.Add(sXray); } } } } bool SaveOtherDataToXray(string STDDBAddress, int id) { #region 数据库存贮方式一 System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + STDDBAddress + "'"); System.Data.SQLite.SQLiteCommand cmm = m_dbConnection.CreateCommand(); try { m_dbConnection.Open(); //string insertstr = ("insert into STDMinerals(name,formula,density,Hardness,BSEValue,Electrical_conductivity,color,Element) values(" + m_SubMidWindow.m_MainForm.STDDictionary[id].StrName + "," + m_SubMidWindow.m_MainForm.STDDictionary[id].Formula + "," + m_SubMidWindow.m_MainForm.STDDictionary[id].Density + "," + m_SubMidWindow.m_MainForm.STDDictionary[id].Hardness + "," + m_SubMidWindow.m_MainForm.STDDictionary[id].BSE + "," + m_SubMidWindow.m_MainForm.STDDictionary[id].Electrical_conductivity + "," + m_SubMidWindow.m_MainForm.STDDictionary[id].Color + "," + m_SubMidWindow.m_MainForm.STDDictionary[id].Element + ");"); string insertstr = ("insert into STDMinerals(name) values(" + m_SubMidWindow.m_MainForm.STDDictionary[id].StrName + ");"); cmm.CommandText = insertstr; cmm.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); return false; } m_dbConnection.Close(); #endregion return true; } /// /// 保存STDXray至数据库 /// public void SaveSTDXray() { ArrayList delArrayList = new ArrayList(); if (m_STDXrayList != null) { //if (m_STDXrayList.Count > 0) //{ foreach (STDXray item in m_STDXrayList) { int infoState = item.InfoState; //添加状态 根据Xray信息当前只能按照一条操作 if (infoState == (int)STDXrayInfoState.Add) { //if (item.XrayData == null) //{ // item.XrayData = new byte[8000]; //} //string strvaluename = "@data"; ////编辑添加语句 //StringBuilder strSqlAdd = new StringBuilder(); //strSqlAdd.Append("insert into STDMinerals(Id,SPEC) values(" + item.StdID + "," + strvaluename + ");"); //bool addResult = m_sc.ExecuteBlob(strSqlAdd.ToString(), strvaluename, (byte[])item.XrayData, ((byte[])item.XrayData).Length); bool addResult = false; //判断STDID在数据库中是否存在 bool selResult = SelSTDDBBySTDId(item.StdID); if (selResult) { //addResult = UpdateSTDDB(item.StdID, xrayByteData); addResult = UpdateSTDDB(item.StdID, item.XrayData); } else { addResult = AddSTDDB(item.StdID, item.XrayData); } if (!addResult) { continue; } } //修改状态 else if (infoState == (int)STDXrayInfoState.Modify) { //判断STDID在数据库中是否存在 bool selResult = SelSTDDBBySTDId(item.StdID); if (selResult) { UpdateSTDDB(item.StdID, item.XrayData); } else { AddSTDDB(item.StdID, item.XrayData); } } //删除状态 编辑批量删除语句 else if (infoState == (int)STDXrayInfoState.Delete) { //编辑删除语句 delArrayList.Add("delete from STDMinerals where id=" + item.StdID + ";"); } } //批量删除 if (delArrayList.Count > 0) { bool delResult = m_sc.DelSTDInfo(delArrayList); } //} } } /// /// 添加STD信息至数据库 /// protected bool AddSTDDB(string stdID, byte[] XrayData) { if (XrayData == null) { XrayData = new byte[8000]; } string strvaluename = "@data"; StringBuilder sqlStrAdd = new StringBuilder(); sqlStrAdd.Append("insert into STDMinerals(Id,SPEC) values(" + stdID + "," + strvaluename + ");"); bool addResult = m_sc.ExecuteBlob(sqlStrAdd.ToString(), strvaluename, (byte[])XrayData, ((byte[])XrayData).Length); return addResult; } /// /// 修改STD信息至数据库 /// protected bool UpdateSTDDB(string stdID, byte[] XrayData) { if (XrayData == null) { XrayData = new byte[8000]; } string strValueName = "@data"; StringBuilder sqlStrUpdate = new StringBuilder(); sqlStrUpdate.Append("update STDMinerals set SPEC=" + strValueName +" where id=" + stdID + ";"); bool updateResult = m_sc.ExecuteBlob(sqlStrUpdate.ToString(), strValueName, (byte[])XrayData, ((byte[])XrayData).Length); return updateResult; } /// /// 查询是否存在标准编号 /// /// protected bool SelSTDDBBySTDId(string stdID) { bool selResult = false; //编辑查询语句 StringBuilder sqlStr = new StringBuilder(); sqlStr.Append("select * from STDMinerals where id=" + stdID + ""); DataTable dt = m_sc.GetDTFormSysSTDBySQLString(sqlStr.ToString()); if (dt != null) { if (dt.Rows.Count > 0) { //已存在状态 selResult = true; } } return selResult; } /// /// 根据选择树节点显示对应的Xray信息 /// public void SelSTDXray(int Key, STDdata sT) { if (sT == null) { return; } if (m_STDXrayList != null) { //if (m_STDXrayList.Count > 0) //{ bool isExists = false; foreach (STDXray item in m_STDXrayList) { //修改XrayData信息 if (item.StdID == Key.ToString()) { string selColor = sT.Color; int colorValue = Convert.ToInt32(selColor); //显示Xray信息 if (item.XrayData != null) { isExists = true; ShowXrayAtlas(colorValue, item.XrayData); } break; } } if (!isExists) { ShowXrayAtlas(); } //} } } public void ShowEditContent(string stdID) { if (m_STDXrayList != null) { for (int i = 0; i < m_STDXrayList.Count; i++) { if (m_STDXrayList[i].StdID == stdID) { //获取修改行的信息 xrayByteData = (byte[])m_STDXrayList[i].XrayData; } } } } /// /// 根据STDId修改对应的Xray信息 /// /// protected void UpdateSTDXray(int STDId, byte[] xrayData) { if (m_STDXrayList != null) { //if (m_STDXrayList.Count > 0) //{ bool isExists = false; foreach (STDXray item in m_STDXrayList) { //修改XrayData信息 if (item.StdID == STDId.ToString()) { item.XrayData = xrayData; item.InfoState = (int)STDXrayInfoState.Modify; isExists = true; break; } } if (!isExists) { if (!STDId.ToString().Equals("")) { //添加STD XrayData信息 STDXray stdXray = new STDXray(); stdXray.StdID = STDId.ToString(); stdXray.XrayData = xrayData; stdXray.InfoState = (int)STDXrayInfoState.Add; m_STDXrayList.Add(stdXray); } } //} } } /// /// 添加STDXray信息 /// /// STDid /// Xray信息 /// protected bool AddSTDXray(int STDId, byte[] xrayData) { bool addResult = false; if (m_STDXrayList != null) { //if (m_STDXrayList.Count > 0) //{ if (!STDId.ToString().Equals("")) { //添加STD XrayData信息 STDXray stdXray = new STDXray(); stdXray.StdID = STDId.ToString(); stdXray.XrayData = xrayData; stdXray.InfoState = (int)STDXrayInfoState.Add; m_STDXrayList.Add(stdXray); addResult = true; } //} } return addResult; } /// /// 删除STDXray信息 /// /// 所选要删除的STDId /// public bool DelSTDXray(int STDId) { bool delResult = false; if (m_STDXrayList != null) { //if (m_STDXrayList.Count > 0) //{ if (!STDId.ToString().Equals("")) { foreach (STDXray item in m_STDXrayList) { //修改XrayData信息 if (item.StdID == STDId.ToString()) { item.InfoState = (int)STDXrayInfoState.Delete; delResult = true; break; } } } //} } return delResult; } #endregion #region 控制BSE、化学式、元素本文框中不能输入下划线 /// /// 控件不能输入下划线 /// /// /// private void textBox_KeyPress(object sender, KeyPressEventArgs e) { if ((e.KeyChar >= '0' && e.KeyChar <= '9') || (e.KeyChar >= 'A' && e.KeyChar <= 'Z') || (e.KeyChar >= 'a' && e.KeyChar <= 'z') || (e.KeyChar == 8) || !(e.KeyChar == '_')) { e.Handled = false; } else { e.Handled = true; } } #endregion private void btnTest_Click(object sender, EventArgs e) { XrayContrastForm xrayContrastForm = new XrayContrastForm(); xrayContrastForm.STDDictionary = m_SubMidWindow.m_MainForm.STDDictionary; xrayContrastForm.ShowDialog(); } private float X = 1; private float Y = 1; private void STDEditor_Resize(object sender, EventArgs e) { //float newx = (this.Width) / X; //float newy = this.Height / Y; //AmplificationFactor = newy; //setControls(newx, newy, this.tabSTDStandrad.TabPages[0]); ////button_Extend.BackColor = SystemColors.ControlDarkDark; } private void setTag(Control cons) { foreach (Control con in cons.Controls) { con.Tag = con.Width + ":" + con.Height + ":" + con.Left + ":" + con.Top + ":" + con.Font.Size; if (con.Controls.Count > 0) setTag(con); } } private void setControls(float newx, float newy, Control cons) { foreach (Control con in cons.Controls) { if (false) { } else { string[] mytag = con.Tag.ToString().Split(':'); float a = Convert.ToSingle(mytag[0]) * newx; con.Width = (int)a; a = Convert.ToSingle(mytag[1]) * newy; con.Height = (int)(a); a = Convert.ToSingle(mytag[2]) * newx; con.Left = (int)(a); a = Convert.ToSingle(mytag[3]) * newy; con.Top = (int)(a); Single currentSize; if (con.Name == "button_Extend") { currentSize = 6f; } else { if (Math.Max(newx, newy) < 1) { currentSize = Convert.ToSingle(mytag[4]) * 1; } else { currentSize = Convert.ToSingle(mytag[4]) * Math.Max(newx, newy); } } con.Font = new Font(con.Font.Name, currentSize, con.Font.Style, con.Font.Unit); if (con.Controls.Count > 0) { setControls(newx, newy, con); } } } } Form_PeriodicTable form_PeriodicTable; private void button_PeriodicTableSwitch_Click(object sender, EventArgs e) { if (form_PeriodicTable == null) //如果子窗体为空则创造实例 并显示 { form_PeriodicTable = new Form_PeriodicTable(); if (table_STDEditor["language"].ToString() == "EN") { form_PeriodicTable.BackgroundImage = global::SpectrumSTDEditor.Properties.Resources.PeriodicTable_EN; } else { form_PeriodicTable.BackgroundImage = global::SpectrumSTDEditor.Properties.Resources.PeriodicTable_ZH; } form_PeriodicTable.Show(); } else { if (form_PeriodicTable.IsDisposed) //若子窗体关闭 则打开新子窗体 并显示 { form_PeriodicTable = new Form_PeriodicTable(); if (table_STDEditor["language"].ToString() == "EN") { form_PeriodicTable.BackgroundImage = global::SpectrumSTDEditor.Properties.Resources.PeriodicTable_EN; } else { form_PeriodicTable.BackgroundImage = global::SpectrumSTDEditor.Properties.Resources.PeriodicTable_ZH; } form_PeriodicTable.Show(); } else { form_PeriodicTable.Activate(); //使子窗体获得焦点 } } } private void button_ImportFromResult_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "(*.db)|*.db"; openFileDialog.RestoreDirectory = true; openFileDialog.FilterIndex = 1; if (openFileDialog.ShowDialog() == DialogResult.OK) { try { System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + openFileDialog.FileName + "'"); m_dbConnection.Open(); string STDId = m_SubMidWindow.m_MainForm.m_STDRuleslist.Grid_Minerals[m_SubMidWindow.m_MainForm.m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, m_SubMidWindow.m_MainForm.m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Column].Tag.ToString(); Result ret=ImportFromResult(STDId, m_dbConnection); if(ret== Result.NoMatched) { MessageBox.Show("No matching energy spectrum data was found", "Tip"); } m_dbConnection.Close(); int color = Convert.ToInt32(m_SubMidWindow.m_MainForm.STDDictionary[int.Parse(STDId)].Color); for(int i=0;i< m_STDXrayList.Count;i++) { if(m_STDXrayList[i].StdID== STDId) { ShowXrayAtlas(color, m_STDXrayList[i].XrayData); break; } } } catch /*(Exception ex)*/ { MessageBox.Show("Failed to load Xray data!", "Tip"); } } } public Result ImportFromResult(string STDId, System.Data.SQLite.SQLiteConnection m_dbConnection) { try { System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select FieldId ,XrayId from IncAData where TypeId ="+ STDId , m_dbConnection); DataSet ds = new DataSet(); m_dataAdapter.Fill(ds); DataTable dt = ds.Tables[0]; if (dt != null) { if (dt.Rows.Count > 0) { string sqlstr = "select XrayData from XRayData where FieldId = " + dt.Rows[0]["FieldId"] + " AND XrayIndex =" + dt.Rows[0]["XrayId"]; m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter(sqlstr, m_dbConnection); ds = new DataSet(); m_dataAdapter.Fill(ds); dt = ds.Tables[0]; if (dt != null) { if (dt.Rows.Count > 0) { DialogResult dr = MessageBox.Show("ID Num:" + STDId+ ", this rule has found the first match object, is it loaded?", "Tip", MessageBoxButtons.OKCancel); if(dr == DialogResult.OK) { m_SubMidWindow.m_MainForm.IsModified = true; if (SelSTDDBBySTDId(STDId)) { if (MessageBox.Show("ID Num:" + STDId + ", the database already contains records of this rule XRay curve, is it overwritten?", "Tip", MessageBoxButtons.OKCancel) == DialogResult.OK) { UpdateSTDXray(int.Parse(STDId), (byte[])dt.Rows[0]["XrayData"]); } } else { UpdateSTDXray(int.Parse(STDId), (byte[])dt.Rows[0]["XrayData"]); } } return Result.Success; } else { return Result.NoMatched; } } else { return Result.NoMatched; } } else { return Result.NoMatched; } } else { return Result.NoMatched; } } catch /*(Exception ee)*/ { MessageBox.Show("Failed to load Xray data!", "Tip"); return Result.Fail; } } public void ShowTabXray() { tabSTDStandrad.SelectedIndex = 1; } public void ShowSTD() { tabSTDStandrad.SelectedIndex = 0; } } }