コード例 #1
0
ファイル: OperationType.cs プロジェクト: lexxkrt/usno
 public OperationType Save(OperationType operation)
 {
     using (var command = new FbCommand())
     {
         command.Connection = ConnectionHelper.Connection;
         if (command.Connection.State != System.Data.ConnectionState.Open)
             command.Connection.Open();
         command.Transaction = command.Connection.BeginTransaction();
         command.CommandText =
     @"UPDATE OR INSERT INTO OPERATIONTYPE(ID,FLAGOPERATION,DESCRIPTION,ISNOTACTIVED,ISUSNO,ISPROP,BANKORKASSA)
     VALUES (@ID,@FLAGOPERATION,@DESCRIPTION,@ISNOTACTIVED,@ISUSNO,@ISPROP,@BANKORKASSA)
     MATCHING(ID)
     RETURNING(ID)";
         command.Parameters.AddWithValue("@ID", operation.Id == 0 ? null : (int?)operation.Id);
         command.Parameters.AddWithValue("@FLAGOPERATION", operation.FlagOperation);
         command.Parameters.AddWithValue("@DESCRIPTION", operation.Description);
         command.Parameters.AddWithValue("@ISNOTACTIVED", operation.IsNotActived);
         command.Parameters.AddWithValue("@ISUSNO", operation.IsUsno);
         command.Parameters.AddWithValue("@ISPROP", operation.IsProp);
         command.Parameters.AddWithValue("@BANKORKASSA", operation.BankOrKassa);
         operation.Id = (int)command.ExecuteScalar();
         command.Transaction.Commit();
     }
     this.UpdateOperationType();
     return operation;
 }
コード例 #2
0
ファイル: OperationType.cs プロジェクト: lexxkrt/usno
 public bool Delete(OperationType operation)
 {
     using (var command = new FbCommand())
     {
         command.Connection = ConnectionHelper.Connection;
         if (command.Connection.State != System.Data.ConnectionState.Open)
             command.Connection.Open();
         command.Transaction = command.Connection.BeginTransaction();
         command.CommandText = "DELETE FROM OPERATIONTYPE WHERE ID=@ID";
         command.Parameters.AddWithValue("@ID", operation.Id);
         try
         {
             command.ExecuteNonQuery();
             command.Transaction.Commit();
             return true;
         }
         catch
         {
             command.Transaction.Rollback();
             return false;
         }
         finally
         {
             UpdateOperationType();
         }
     }
 }