private void NuevoButton_Clicked(object sender, EventArgs e) { if (string.IsNullOrEmpty(ContentsEntry.Text)) { ContentsEntry.Focus(); return; } Note note = new Note { Contents = ContentsEntry.Text, CreatedDate = CreatedDateDatePicker.Date, ModifiedDate = ModifiedDateDatePicker.Date }; using (var datos = new DataAccess()) { datos.InsertNote(note); datosListView.ItemsSource = datos.GetNotes(); } ContentsEntry.Text = string.Empty; CreatedDateDatePicker.Date = DateTime.Now; ModifiedDateDatePicker.Date = DateTime.Now; }
public override void LoadXML(XmlNode element, FileVersion version) { try { base.LoadXML(element, version); ImageName = ReadElement(element, "ImageName"); ItmKind = (ItemKind)Enum.Parse(typeof(ItemKind), ReadElement(element, "Kind")); string signs = ReadElement(element, "Signs"); Flags = new ItemFlags(signs); string newSigns = Flags.Signature; if (!signs.Equals(newSigns)) { throw new Exception("ItemSigns not equals (" + ImageName + ")"); } EqKind = (BodypartType)Enum.Parse(typeof(BodypartType), ReadElement(element, "eqKind")); Frequency = Convert.ToSByte(ReadElement(element, "Frequency")); Satiety = Convert.ToInt16(ReadElement(element, "Satiety")); Price = Convert.ToInt16(ReadElement(element, "Price")); Weight = (float)ConvertHelper.ParseFloat(ReadElement(element, "Weight"), 0.0f, true); XmlNode ael = element.SelectSingleNode("Attributes"); for (int i = ItemAttribute.ia_First; i <= ItemAttribute.ia_Last; i++) { string atSign = dbItemAttributes[i - 1]; Attributes[i - 1] = Convert.ToInt32(ReadElement(ael, atSign)); } XmlNodeList nl = element.SelectSingleNode("Effects").ChildNodes; Effects = new EffectEntry[nl.Count]; for (int i = 0; i < nl.Count; i++) { XmlNode n = nl[i]; Effects[i] = new EffectEntry(); Effects[i].EffID = (EffectID)Enum.Parse(typeof(EffectID), n.Attributes["EffectID"].InnerText); Effects[i].ExtData = Convert.ToInt32(n.Attributes["ExtData"].InnerText); } nl = element.SelectSingleNode("Contents").ChildNodes; Contents = new ContentsEntry[nl.Count]; for (int i = 0; i < nl.Count; i++) { XmlNode n = nl[i]; Contents[i] = new ContentsEntry(); Contents[i].ItemID = n.Attributes["ItemID"].InnerText; Contents[i].Chance = Convert.ToInt32(n.Attributes["Chance"].InnerText); } Material = (MaterialKind)Enum.Parse(typeof(MaterialKind), ReadElement(element, "Material")); FramesCount = Convert.ToSByte(ReadElement(element, "FramesCount")); BonusRange.Min = Convert.ToInt32(ReadElement(element, "BonusRange_Min")); BonusRange.Max = Convert.ToInt32(ReadElement(element, "BonusRange_Max")); } catch (Exception ex) { Logger.Write("ItemEntry.loadXML(): " + ex.Message); throw ex; } }