// return: // true 合法 // false 不合法。已经报错了 bool VerifyData() { if (this._dom == null) { return(true); } XmlNodeList nodes = _dom.DocumentElement.SelectNodes("item"); foreach (XmlElement item in nodes) { string strSeller = item.GetAttribute("seller"); string strTable = item.GetAttribute("table"); // 验证数据是否合法 try { RateItem.ParseList(strTable); } catch (Exception ex) { this.comboBox_seller.Text = strSeller; MessageBox.Show(this, "渠道(书商) '" + strSeller + "' 的汇率表格式不合法: " + ex.Message); return(false); } } return(true); }
private void button_OK_Click(object sender, EventArgs e) { // 验证数据是否合法 try { RateItem.ParseList(this.RateList); } catch (Exception ex) { MessageBox.Show(this, ex.Message); return; } this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); }