// parameters: // strValue 第一、第二字符为指示符,后面为字段内容 int SetValue(string strValue, out string strError) { strError = ""; this.Clear(); this._record = new MarcRecord(); this._record.add(new MarcField("856" + strValue)); MarcField field = _record.ChildNodes[0] as MarcField; #if NO char chIndicator1 = ' '; char chIndicator2 = ' '; if (strValue.Length >= 1) { chIndicator1 = strValue[0]; } if (strValue.Length >= 2) { chIndicator2 = strValue[1]; } #endif this.comboBox_indicator1.Text = new string(field.Indicator1, 1); this.comboBox_indicator2.Text = new string(field.Indicator2, 1); if (string.IsNullOrEmpty(field.Content) == true) { return(0); } this.textBox_f.Text = field.select("subfield[@name='f']").FirstContent; this.textBox_q.Text = field.select("subfield[@name='q']").FirstContent; this.textBox_s.Text = field.select("subfield[@name='s']").FirstContent; this.comboBox_u.Text = field.select("subfield[@name='u']").FirstContent; this.Subfield_x = field.select("subfield[@name='x']").FirstContent; this.textBox_y.Text = field.select("subfield[@name='y']").FirstContent; this.textBox_z.Text = field.select("subfield[@name='z']").FirstContent; this.textBox_2.Text = field.select("subfield[@name='2']").FirstContent; this.textBox_3.Text = field.select("subfield[@name='3']").FirstContent; this.textBox_8.Text = field.select("subfield[@name='8']").FirstContent; return(0); }
void SetSubfield(string strName, string strValue) { Debug.Assert(strName.Length == 1, ""); MarcField field = _record.ChildNodes[0] as MarcField; MarcNodeList subfields = field.select("subfield[@name='" + strName + "']"); if (subfields.count == 0) { if (string.IsNullOrEmpty(strValue) == true) { return; } // 以前不存在这个子字段,只能追加 field.add(new MarcSubfield(strName, strValue)); return; } // 原位置修改 subfields[0].Content = strValue; }