private void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtItemID.Text)) { lblMsg.Text = "请输入ID"; return; } DataRow[] addItem = DataHelper.XkfyData.Tables[_tableName].Select("@iItemID$0='" + txtItemID.Text + "'"); if (addItem.Length > 0) { lblMsg.Text = "此ID在源数据中已经存在,请修改ID,并确保在该文件此ID是唯一的"; return; } DataRow dr1 = DataHelper.XkfyData.Tables[_tableName].NewRow(); _tl.CopyRowToData(gbCondition, dr1); DataHelper.CopyDataToRow(this, dr1); if (string.IsNullOrEmpty(dr1["rowState"].ToString())) { dr1["rowState"] = "1"; } DataHelper.XkfyData.Tables[_tableName].Rows.InsertAt(dr1, 0); this.Close(); }