public void SaveScaleLine() { try { if (Status != EStatus.Working) { return; } if (LastLine.Line == string.Empty) { return; } Pesajes pesajes = Pesajes.NewList(); Pesaje item = pesajes.NewItem(); CopyFromLine(item, LastLine); pesajes.OpenNewSession(); pesajes.BeginTransaction(); pesajes.Save(); pesajes.CloseSession(); MyLogger.LogText("Line saved: " + LastLine.Line, "ScalesMng::SaveScaleLine"); Status = EStatus.Closed; } catch (Exception ex) { MyLogger.LogException(ex, "ScalesMng::SaveScaleLine"); Status = EStatus.Error; } }
/// <summary> /// Borra el registro de la base de datos /// </summary> /// <param name="parent">Lista padre</param> /// <remarks>La utiliza la BusinessListBaseEx correspondiente para borrar elementos<remarks/> internal void DeleteSelf(Pesajes parent) { // if we're not dirty then don't update the database if (!this.IsDirty) { return; } // if we're new then don't update the database if (this.IsNew) { return; } SessionCode = parent.SessionCode; Session().Delete(Session().Get <WeighingRecord>(Oid)); MarkNew(); }
/// <summary> /// Inserta el registro en la base de datos /// </summary> /// <param name="parent">Lista padre</param> /// <remarks>La utiliza la BusinessListBaseEx correspondiente para insertar elementos<remarks/> internal void Insert(Pesajes parent) { // if we're not dirty then don't update the database if (!this.IsDirty) { return; } ValidationRules.CheckRules(); if (!IsValid) { throw new iQValidationException(Library.Resources.Messages.GENERIC_VALIDATION_ERROR); } parent.Session().Save(Base.Record); MarkOld(); }
/// <summary> /// Actualiza el registro en la base de datos /// </summary> /// <param name="parent">Lista padre</param> /// <remarks>La utiliza la BusinessListBaseEx correspondiente para actualizar elementos<remarks/> internal void Update(Pesajes parent) { // if we're not dirty then don't update the database if (!this.IsDirty) { return; } ValidationRules.CheckRules(); if (!IsValid) { throw new iQValidationException(Library.Resources.Messages.GENERIC_VALIDATION_ERROR); } SessionCode = parent.SessionCode; WeighingRecord obj = Session().Get <WeighingRecord>(Oid); obj.CopyValues(this._base.Record); Session().Update(obj); MarkOld(); }